Repository navigation
Stage 1 correctness and device qualification - #329
Draft
JeffreySarnoff wants to merge 100 commits into
Draft
JeffreySarnoff wants to merge 100 commits into
JeffreySarnoff wants to merge 100 commits into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This draft stacks Stage 1 on
stage0(#328) and records the Gate 1 checks for2.0.0-alpha.1.devicecheck, the CUDA compilation survey, and the gradual and flushed word suites.Verification
devicecheckassertion. Eight Double32 quotient and remainder cases matched the CPU bit for bit.divremandfldmodbecame native.Gate 2 text
repruses the appropriate string macro, compact output uses six significant digits, andPrintfformats both words.stringsample 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 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 is2.0.0-alpha.2.