Skip to content

Stage 1 correctness and device qualification - #329

Draft
JeffreySarnoff wants to merge 100 commits into
stage0from
stage1
Draft

JeffreySarnoff wants to merge 100 commits into
stage0from
stage1

Conversation

@JeffreySarnoff

@JeffreySarnoff JeffreySarnoff commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Summary

This draft stacks Stage 1 on stage0 (#328) and records the Gate 1 checks for 2.0.0-alpha.1.

  • Close all 392 conformance properties and enable Aqua, JET, and the qualified-access checks.
  • Compute exact integer quotients and remainders. The Double32 path uses fixed UInt32 storage and preserves native CUDA compilation.
  • Add devicecheck, the CUDA compilation survey, and the gradual and flushed word suites.
  • Record the corpus and CPU benchmark audits in the checkpoint and release notes.

Verification

  • Julia 1.13.3 full suite passed. Julia 1.12.7 host suite passed. The local 1.12 depot lacked the LLVM artifact for the CPU backend probe.
  • RTX 5090 passed every devicecheck assertion. Eight Double32 quotient and remainder cases matched the CPU bit for bit.
  • All previously native CUDA survey entries remained native. divrem and fldmod became native.
  • Gradual word tests passed. The flushed division residual cases retain their expected-failure markers for N-23.

Gate 2 text

  • Decimal output reads back to the same normalized value, including pairs with remote subnormal low words. Scalar repr uses the appropriate string macro, compact output uses six significant digits, and Printf formats both words.
  • The local suites pass 404 conformance properties. The six golden corpus changes cover only decimal text and decimal round trips. The documentation examples build.
  • The 64-value string sample now takes 241 μs for Double32 and 284 μs for Double64 locally. Double64 parsing fell from 76 to 26 μs. The CI comparison uses individual limits for documented costs and keeps its 1.3× default elsewhere.
  • The ARM flushed-word test records the confirmed Float16 divisor-tail loss alongside the earlier flushed-division exceptions.

The nine-job platform matrix passed at bfeb1a20. The Linux Julia 1.12.0 ordering property passed on a retry of the same commit. Documentation, the hosted benchmark comparison, and the RTX 5090 checks passed. The published tag is 2.0.0-alpha.2.

JeffreySarnoff and others added 30 commits November 25, 2026 18:42
…isted

266 properties over the three types: order and hash, construction,
conversion, parsing, promotion, approximation, and random numbers. 154
hold. The 112 that do not are listed by key in
test/conformance/broken.txt and recorded as broken, not failed. A fix
removes its keys from the list; a listed property that starts to pass is
an error.

Each property restores the global BigFloat precision, which some of the
defects under test change.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Double64(hi, lo) stored its two words as given, so a caller could hold a
value that broke the one invariant the arithmetic relies on. It now
returns the normalized pair. A normalized pair comes back bit for bit,
signed zeros included: the first version of this change used two_sum
alone and turned a high word of -0.0 into 0.0, which the corpus caught on
125 subjects. A high word that is not finite is the value and the low
word is stored as zero, because internal code passes whatever its
arithmetic left there.

Corpus: parse of six Double16 values now returns a normalized pair with
the same sum. modf returns -0.0 as the integer part of some negative
fractions where it returned 0.0; modf is corrected in the next commit.

Conformance: nine properties now hold.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
modf added the parts of the two words separately. For a value just below
an integer, such as Double64(1.0, -1.0e-17), it returned the integer 1
and a negative fraction. It now takes the fraction from whichever word
holds it and moves one unit across when the low word pulls the value
inside the integer. Both parts carry the sign of the argument, zeros
included, and non-finite arguments follow Base.

Found by the corpus while changing the constructor.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
docs/apoth_remains.md checks every requirement of apothecary.md and
apothic.md against src/ by probe and by search. docs/apoth_completing.md
orders the remaining work into forty steps, each with design,
implementation sites, tests to write first, predicted corpus change, and
review points. The checkpoint records the findings and the next step.

No source change.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
apothic_gpu32.md: measurements on a CUDA device, the device contract,
rulings D21 to D25, and a thirteen-step plan. gpu32.md and gpu32_gpt.md
are two further designs for the same question. KernelAbstractions is
added as a dependency and imported; nothing uses it yet. The checkpoint
records all of this and the decisions left open.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
gpu32_meld.md draws on apothic.md, apothic_gpu32.md, gpu32.md, and
gpu32_gpt.md: seven levels of abstraction from the machine model to the
back ends, their concretion, verification per level, budgets, and
fourteen steps. It proposes two carriers, Double32 on the host and
GPUDouble32 on the device, over one layer of word kernels, and records
the measurements made for it. The checkpoint records the meld and the
rulings it leaves open.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Ruling D28. Nothing in the package uses it; the extension that will,
with the device probe, comes with step M1 of docs/gpu32_meld.md. The
suite passes from a fresh resolve without it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Word functions, their check against BigFloat, the comparison of guarded
and select-only schedules on a device, and carrier overhead. They are
measurements; nothing loads them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The device carrier GPUDouble32 is ruled, gates 2.0 for every real
family, and has a string macro. The arithmetic corrections reach all
three types. D17 to D20 are ruled as recommended. apothecary, apothic,
and apoth_completing carry the rulings, the stage placement of steps M0
to M14, release criterion 9, and the kernel rules, which are also in
CONTRIBUTING. The three earlier GPU documents are marked superseded by
gpu32_meld.md. The checkpoint records all of it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
No constructor produces DoubleFloat{Double32} or its relatives, and no
test or corpus subject names one. Removed: four convert methods, two
hash methods, HI/LO/HILO on tuples of pairs, and the widened elementary
methods for the nested types.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
DoubleFloat{T} is bounded by T<:IEEEFloat, so a pair of pairs cannot be
named. MultipartFloat is defined beside the struct, whose docstring now
states the invariant.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Nearest normalized pair from wide rationals, wide BigFloat values,
irrationals, wide integers, wider machine floats; exact widening of a
narrower pair; no allocation from Int64. Four do not hold yet and are
keyed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
==, <, <=, isequal, and isless are lexicographic on the words and never
read the low word of a value that is not finite. NaN is unequal to
itself, the zeros are equal and ordered by isless, equal infinities
compare equal whatever their low words. Twenty-eight properties now
hold. Corpus: comparison subjects only.

Done ahead of exact construction (step 2): that step stores a zero low
word in every non-finite value, and the old <= then called two NaN
values ordered.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Ruling D18. The methods compared words as given, without normalizing
the tuple.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
One constructor for each kind of argument: a machine float of another
width, an integer, a BigFloat, a rational, an irrational, any other
real, a pair of another width. Each forms the remainder exactly and
rounds it once. Integers above 2^53 are exact in Double64. Widening a
pair keeps the sign of zero. A value just below the overflow threshold
is the largest pair, not infinity. The convert methods that did the same
work by other routes are gone; Base's convert calls the constructor.

Thirteen properties now hold, among them that hash follows isequal:
every non-finite value now has a zero low word. One property is added
with the fix, for the overflow threshold. The unit test that required
(Inf, Inf) as the stored form of infinity now requires (Inf, 0), as
ruling R7 says.

Corpus: fromint; functions of Double32 and Double16 at -0.0; pairs that
were not normalized; low words of -0.0.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Rulings D18 and D19. A pair is built from two word arguments by one
parametric method that converts the words and normalizes. The internal
callers that passed a tuple (four word operations, the pi constants,
rem2pi) pass its elements to that method, with the same bits. Two
methods that could only recurse are removed with them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Ruling D17. The old name stays as an alias until it is deprecated.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A pair converted to a narrower machine float is correctly rounded, and
to a narrower pair is the nearest pair, on midpoints of the narrower
type with low words of both signs, on both sides of its overflow
threshold, and in its subnormal range. Four do not hold yet and are
keyed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Same results. Against the branch-free forms a sort of 64 or 512 values
is twice as fast, and within a quarter of the 1.13 time, which it bought
by misordering NaN and the zeros.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Float32(x) and Float16(x) of a wider pair round the value once, with the
low word deciding a midpoint and the overflow threshold. A pair
converted to a narrower pair is the nearest one: the high word is the
value rounded, the low word the exact remainder rounded. Four properties
now hold. Conversion to a pair's own word type is one method for all
three types.

Corpus: fifty Double32 subjects, each a conversion or a function
computed in Double64.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Base.decompose returns integers whose product with a power of two is
the pair exactly, for all three types; it threw. Rational(x) is the
exact value as a Rational{BigInt}. Six properties now hold. Corpus
unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Same results. Whether a high word is a midpoint of the narrower type is
one test on its bits, and the error-free sum of the remainder is formed
only when that test or the range requires it. Double32(::Double64) takes
2.9 ns where the first form took about 10.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A pair against a machine float is one subtraction in the wider machine
type; against a machine integer the same when the integer is a Float64
and otherwise in Double64; against a pair of another width in the wider
pair type; against other integers and rationals by integers from
decompose; against a BigFloat at a precision that holds the pair.
Double32 == Double64 no longer errors. The package's mixed isequal and
isless are gone; Base's are built on == and <. BigFloat(x) is exact.

Six properties now hold and nine are added: pairs of different widths,
machine numbers no pair of the type holds, no allocation. Ambiguities
fall from 12 to 5. Corpus unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A pair with a zero low word hashes as its high word; any other by
Base's hash of a real number, from the exact decomposition. Twelve
properties now hold: equal Float64 and BigFloat values hash alike, and
Dict and Set find a pair under an equal key of another type.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
two_sum_ord_ orders its operands by magnitude, so no intermediate
exceeds the result and a finite sum at the top of the range is exact.
Each branch-free transformation now has a docstring stating where it is
exact, with gradual underflow and on a device that flushes subnormal
numbers.

test/eft32.jl checks every identity against exact values built from the
bits of the words, for the three word types, and runs the same cases
again in a child process with subnormal numbers flushed to zero.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
test/conformance/arith.jl: + - * / over a grid of special values, the
top binade, and pairs whose product or quotient crosses the overflow
threshold; floor, ceil, trunc on integers at and above 2^p with a
fractional low word; round at ties; the sign of zero. Seventeen of the
twenty-seven properties do not hold and are keyed: NaN for finite and
for overflowing results, lost signs of zero, a quotient of the wrong
class and one of half precision, and the integer functions above 2^p.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
arith/totals.jl holds them as functions of the two words: where the high
word is an integer the low word is the fraction, and otherwise the low
word can only break a tie. They select and do not branch, are generic in
the word type, and name no wider type. round is to nearest with ties to
even; ties away and ties up are two more rules of the same function.
spread is ceil or floor by sign.

Thirteen properties now hold. ceil(0.0) and trunc(-0.0) were 1.0; values
of 2^p and more with a fractional low word were not rounded; zero
results lost their sign. mod, rem, fld, cld, and rationalize change with
them: mod falls outside [0, y) a ninth as often.

LinearAlgebra.floatmin2 for Double32 and Double64 was one binade above
its defining formula, having been computed when trunc(-40.0) was -39.

Corpus: floor, ceil, trunc, round, mod, rem and their mixed forms.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Use the existing BigFloat kernel for the wide Double64 complex asin and acos paths after Julia 1.12.0 on macOS produced different low words through Float128. Exercise the current unit-pair kernel in SIMD tests so deprecation logging does not affect allocation checks.
Use explicit Float32 FMAs because CUDA contracts the split residual in the original reciprocal kernel. Cover all six circular and hyperbolic reciprocal methods at CUDA rounding and range boundaries.
Guard the Float32 word schedule once so CUDA avoids repeated checked transforms in ordinary FMA and zero lanes. Preserve the Double32 rounding sequence and keep cancellation, overflow, underflow, and nonfinite handling in the checked path. Both RTX 5090 Gate 4 trials cleared all throughput floors.
Check the scalar ordinary range once per block, then apply the same corrected Float32 root in the vector loop. Keep rejected blocks on the scalar path so special values and partial writes retain scalar behavior.

This branch has not been deployed

No deployments
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.

1 participant