Skip to content

V3.96: mixed-precision ArXiv paper prep and UNUM2 number system#506

Merged
Ravenwater merged 15 commits intomainfrom
v3.96
Feb 11, 2026
Merged

V3.96: mixed-precision ArXiv paper prep and UNUM2 number system#506
Ravenwater merged 15 commits intomainfrom
v3.96

Conversation

@Ravenwater
Copy link
Contributor

@Ravenwater Ravenwater commented Feb 11, 2026

mixed-precision ArXiv paper prep and UNUM2 number system

Summary by CodeRabbit

  • New Features

    • Added complete posit2 arithmetic operations (subtraction, multiplication, division)
    • Introduced mixed-precision attention head implementation with KV cache management
    • Added comprehensive test suites for posit2 conversion, assignment, and logic operators
  • Documentation

    • Added arXiv systems and position papers with feasibility-focused narratives
    • Included LaTeX scaffolding and reproducibility artifacts for research papers
    • Expanded mixed-precision solver case studies documentation
  • Chores

    • Bumped minor version to v3.96
    • Updated CI workflow triggers

Ravenwater and others added 15 commits February 9, 2026 13:18
When exponent is a large negative (e.g. -72), the shift `1ull << -exponent`
exceeds 63 bits, causing undefined behavior. Add `exponent > -64` guard
so both positive and negative extremes fall through to the safe ipow() path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Create self-contained papers/ directory for systems and position paper
artifacts that can be zipped and shared with reviewers:

- papers/systems-paper/iterative_refinement.cpp: Carson & Higham
  three-precision LU-IR across IEEE, posit, cfloat, dd, cross-family
- papers/systems-paper/conjugate_gradient.cpp: CG for SPD systems with
  single-precision and two-precision (low preconditioner) configurations
- papers/systems-paper/idrs.cpp: IDR(s) for non-symmetric systems with
  shadow space dimension sweep and number system comparison

Move paper docs from docs/papers/ to papers/docs/ for co-location.
Add UNIVERSAL_BUILD_PAPERS CMake option (wired into BUILD_ALL cascade).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Plain article class (12pt) with full section structure, TODO placeholders,
29 BibTeX references (14 from JOSS + 15 new), and Makefile for local builds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ites

Add all four arithmetic operations (sub, mul, div plus existing add) via
blocktriple pipeline, port conversion/assignment/logic regression tests
from original posit, and fix three bugs discovered during testing:

- convert_ieee754() extractBits too small: nbits+4 lost IEEE sticky bits
  causing false midpoint ties; now uses max(numeric_limits<Real>::digits, nbits+4)
- Integer assignment via blocktriple had hidden-bit off-by-one in round();
  rerouted through convert_ieee754(static_cast<double>(rhs))
- Literal comparison operators accessed private _block member; replaced
  with delegation to posit-posit comparison operators

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
positRegime::value() used manual division (1.0l / uint64_t(1) << -e2)
for negative exponents, which produced wrong results under clang due
to a codegen issue in this template context. Replace with std::ldexp()
matching the original posit implementation.

posit::setbits(uint64_t) used an uninitialized blockbinary temporary
leaving upper MSU bits as garbage. Replace with _block.setbits(value)
which properly masks the MSU.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
On MSVC, LONG_DOUBLE_SUPPORT is 0 but the long double comparison
operators were not guarded, causing ambiguous conversion errors since
the posit(long double) constructor was correctly excluded. Add
matching #if LONG_DOUBLE_SUPPORT guards to friend declarations,
operator implementations, and test code.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Skeletal implementation of Unum 2.0

* Fix point multiplication bug and add support for reverse interval

* Added pow() and abs() + some optimizations

* Refactor according to Codacy suggestions

* Added op table/matrix for efficient operations

* Fix unum2 includes

* Fix operation matrix bug in unum2_impl.hpp

* unum2_fwd.hpp, static test and improvements

* Change bitset::_Find_first() to manually finding the bit for compatibility reasons

* Make unum2 friend class a little more specific on class lattice

* Make lattice parameters public to bypass MSVC build fails
@Ravenwater Ravenwater self-assigned this Feb 11, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 11, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR adds extensive new mixed-precision applications and solver case studies, a large redesign and feature expansion of unum2 and posit2 (including arithmetic, conversion, and rounding fixes), numerous new tests and test runners, paper artifacts/LaTeX scaffolding, CMake build options for paper artifacts, and various small internal fixes (block boundaries, includes, exponent handling).

Changes

Cohort / File(s) Summary
CI / Versioning
/.github/workflows/cmake.yml, CMakeLists.txt
Bumped workflow trigger (v3.95→v3.96); added UNIVERSAL_BUILD_PAPERS option, auto-enable behavior when UNIVERSAL_BUILD_ALL is ON, and conditional inclusion of paper/application subdirs.
Mixed-Precision Attention App
applications/mixed-precision/attention/CMakeLists.txt, applications/mixed-precision/attention/attention.cpp, applications/mixed-precision/attention_head.md
New attention application and docs: templated AttentionHead with KV cache, benchmarking across numeric types, energy/latency/accuracy estimation, and build wiring.
Posit2 Core & Tests
include/sw/universal/number/posit2/posit_impl.hpp, include/sw/universal/number/posit2/positRegime.hpp, static/posit2/...
Major posit2 overhaul: frexp-based IEEE→posit path, unified convert paths, new normalizeMultiplication/Division, operator updates, rounding/boundary fixes, copy/construct semantics, extensive new/existing test suites for conversion, assignment, logic, addition, subtraction, multiplication, division.
Block-format Boundary Fixes
include/sw/universal/internal/blockbinary/blockbinary.hpp, include/sw/universal/internal/blocksignificand/blocksignificand.hpp
Changed anyAfter() to iterate up to min(bitIndex, nbits) to correct out-of-range behavior and unify control flow.
Unum2 Lattice Redesign
include/sw/universal/number/unum2/*, static/unum2/*
Replaced old unum2 API with a lattice-based SORN design: added lattice<...>, op_matrix<T>, new unum2<lattice<...>> specialization, forward headers, removed legacy manipulators/math headers, and updated tests to new model.
Solver Case Studies (papers)
papers/systems-paper/iterative_refinement.cpp, papers/systems-paper/conjugate_gradient.cpp, papers/systems-paper/idrs.cpp
Added mixed-precision iterative refinement, preconditioned CG (including two-precision variants), and IDR(s) solver implementations with reporting and experiments across many numeric types.
Paper Artifacts & Build
papers/systems-paper/paper/*, papers/position-paper/CMakeLists.txt, papers/systems-paper/CMakeLists.txt
Added LaTeX manuscript (main.tex), references.bib, Makefile, and CMake globs to build paper artifacts; position-paper CMake entry added.
Documentation & Changelog
CHANGELOG.md, docs/*, papers/docs/*
Large additions: changelog entries, mixed-precision findings, plans/roadmaps for systems and position papers, session notes, and iterative refinement docs.
Small API/Include Fixes
include/sw/universal/number/areal/areal_impl.hpp, include/sw/universal/number/posit/posit_parse.hpp, include/sw/universal/number/shared/blocktype.hpp, include/sw/universal/number/support/decimal.hpp, applications/precision/ubit/thin_triangle.cpp
Added <cstdint> includes, adjusted areal exponent fast-path bounds, updated cfloat instantiations to include ubit flag, and minor parse/format tweaks.
Removed / CMake cleanup
include/sw/universal/number/unum2/CMakeLists.txt, include/sw/universal/number/unum2/manipulators.hpp, include/sw/universal/number/unum2/math_functions.hpp
Removed old unum2 CMake glob and deleted legacy manipulators/math_functions headers as part of unum2 redesign.

Sequence Diagram(s)

(Skipped — changes are broad and include multiple independent features rather than a single multi-component sequential flow that benefits from a sequence diagram.)

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

  • V3.86 #481 — touches the same internal multi-limb routines (blockbinary/blocksignificand anyAfter behavior); likely closely related to posit2 rounding/boundary fixes.
  • V3.83 #475 — overlaps with version/CMake bump and CI workflow updates (UNIVERSAL_VERSION_MINOR and workflow triggers).
  • V3.94: interval arithmetic for mixed-precision algorithm SDK #501 — overlaps in mixed-precision energy/instrumentation infrastructure used by the new attention benchmark and energy estimators.

Poem

🐰 I hopped through lattice, bit and byte,
I cached each KV token bright,
Posit2 rounded, unum danced,
Papers sprouted, tests advanced,
Energy counted, metrics light ✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch v3.96

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Ravenwater Ravenwater merged commit 6daf46f into main Feb 11, 2026
14 of 16 checks passed
@Ravenwater Ravenwater deleted the v3.96 branch February 11, 2026 17:05
@coveralls
Copy link

Pull Request Test Coverage Report for Build 21914780216

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 495 of 570 (86.84%) changed or added relevant lines in 9 files are covered.
  • 14 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.09%) to 84.914%

Changes Missing Coverage Covered Lines Changed/Added Lines %
include/sw/universal/number/posit2/posit_impl.hpp 97 101 96.04%
include/sw/universal/number/unum2/op_matrix.hpp 30 35 85.71%
include/sw/universal/number/unum2/lattice.hpp 69 79 87.34%
include/sw/universal/number/unum2/unum2_impl.hpp 291 347 83.86%
Files with Coverage Reduction New Missed Lines %
include/sw/universal/number/posit2/positExponent.hpp 1 83.61%
include/sw/universal/internal/blocktriple/blocktriple.hpp 3 87.12%
include/sw/universal/number/posit2/posit_impl.hpp 10 94.61%
Totals Coverage Status
Change from base Build 21833272337: 0.09%
Covered Lines: 36345
Relevant Lines: 42802

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants