Repository navigation
Certified low-precision head: exact reference, envelope, contracts and Lean lemmas - #7
Conversation
precision_reference.py emulates BF16/FP32/FP64 rounding exactly on Fractions and implements the self-evidence certificates: quantized-head envelopes (Cauchy-Schwarz, blockwise, Hoelder, exact outlier columns), the tree accumulation bound for sequential, pairwise, blocked, split-K and a fused tensor-core adder model, outward rounding of the computed interval, certified argmax and top-k with an FP32 -> FP64 -> exact refinement ladder, certified races under a counter-based noise field, sampled acceptance with partition intervals, residual and sibling races, and an emulation of the stock BF16-output head for the stock-equality contract. test_precision.py checks every bound and decision against real arithmetic on generated heads, including near-ties, exact ties, forced race ties, adversarial uniforms and witnesses that each envelope term is needed.
CertifiedArgmax.lean proves, over scaled integers, the certified argmax and its candidate filter, uniqueness of certificates across refinement levels, enclosure transport under noise shifts and temperature scaling, acceptance and rejection guards with an enclosed numerator, residual intervals via truncated subtraction, the l_inf/l_1 Hoelder bound, and the sequential accumulation bound |error| <= ((1 + 1/K)^n - 1) sum|t|. check_lean.sh now elaborates every file in formal/. Both files pass under Lean 4.19.0 with only the built-in propext and Quot.sound axioms. STATUS.md records this and what remains unformalized. DecisionGuards.lean is unchanged; STATUS.md and check_lean.sh now differ from SHA256SUMS.
The stock head rounds logits to BF16 and torch.argmax takes the lowest index among equal values, so stock-to-stock divergences sit at BF16 ties. certify_argmax(contract='bf16') certifies the argmax of the BF16-rounded exact logits with lowest-index ties; rounding is monotone, so the ladder applies to rounded endpoints, and point intervals now end the ladder without exact arithmetic. The integer pass quantizes h with a power-of-two scale, accumulates codes exactly and bounds weight error, activation error and the three rescale roundings. Its envelope needs no model of floating-point accumulation.
…self-evidence Per-row quantization error ratios (int8 and int4 per row, int8 with 128-column groups) and 64-row tile radii and diameters of the Qwen3.5-4B head, and from them the relative hidden-state drift below which the transport bound is narrower than the self-evidence bound.
Under flush-to-zero, D squared entries of h can each lose 2^-126, so the norm recipe needs an absolute term of 2^-50 rather than 2^-60 for D up to 2^14; the docstring now states the depth and square-root tolerances.
…test evidence sources/manuscript_review.md lists every theorem, example and numerical claim in paper.tex with a verdict and correction; Table 4 was re-executed and reproduces exactly.
The test report and log come from commit 1c55a2de; the head constants from e2d1e822 (script unchanged since). The README gives each command.
Rebasing onto main rewrote the commit hashes recorded in the evidence. The code is unchanged and the results are identical apart from the recorded hash and timings.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8e3208f8a8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if not is_representable(t, self.fmt): | ||
| raise ValueError('accumulated leaves must be exact in the accumulator format') |
There was a problem hiding this comment.
Handle underflowed products in the accumulation model
When valid BF16 operands are subnormal, their exact product may not be representable in FP32 (for example, 2^-133 * 2^-133). Evaluator accepts both operands under contract C1, but the FP32 refinement ladder reaches this check and raises ValueError instead of refining the decision; an exact tie between two such rows reproduces the failure in certify_argmax. Round the product according to the modeled accumulator and include that error in the bound, or reject this input range when constructing the evaluator.
Useful? React with 👍 / 👎.
| for f in *.lean; do | ||
| echo "checking $f" | ||
| lean "$f" |
There was a problem hiding this comment.
Refresh checksums for the changed artifact sources
This commit changes scripts/check_lean.sh and formal/STATUS.md without updating their existing SHA256SUMS entries. Running sha256sum -c SHA256SUMS on the reviewed tree reports both files as FAILED, so consumers can no longer verify the supplied bundle against its manifest; regenerate the affected checksum entries after the source/evidence update.
AGENTS.md reference: AGENTS.md:L25-L27
Useful? React with 👍 / 👎.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Verdict: REQUEST CHANGES Reviewed at The decision logic in What I ran and checked
BlockingB1. R-bf16 is presented as the stock-equality contract. It is not, and the 900/900 figure cannot support it.
B2. The 0.85 % threshold is not defined where it appears.
B3. The stock divergence statistics are stated as a mechanism.
B4.
B5. Committed files cite derivations that are not in the repository.
B6. The norm recipe's validity range is too wide for
Suggestions (non-blocking)
Checklist status
|
Review of PR #7 found that the branch presented R-bf16 as stock equality. It is not: the stock head rounds its own FP32 accumulation, which can land on the other side of a BF16 boundary. Add the reviewer's witness as a test and say that R-real and R-bf16 are batch-invariant references only, while R-stock (gap condition, fallback to the stock head at the same batch shape) is the adopted contract. Define the 0.85% drift threshold wherever it appears and scope it as a weights-only envelope-width comparison (0.30% in the manuscript's l_inf/l_1 family). Report stock divergences as observations pending a mechanism analysis. Correct the Lean axiom list (Classical.choice through omega), restrict N1's validity to reduction depth 2^13, restrict outward_interval's constants to precision >= 24, and replace references to notes outside the repository.
Test report and Lean log at 8296b58 (20 methods, 39,761 checks, Lean 4.19.0 clean). The README relabels the 900/900 stock-emulation figure as a tie-rule check, names R-stock as the contract, defines the drift threshold and corrects the Python version.
|
Verdict: APPROVE Re-reviewed at
Rerun at this commit:
Non-blocking:
|
The manuscript was a research design centred on transport, with CPU evidence only. This revision keeps the question (what work does a verifier need?) and reorganizes the paper around what the team is testing on SGLang, Qwen3.5-4B and one GH200. - Structure: one file per section under paper/sections/. Transport is presented as the tested hypothesis and self-evidence (a certified low-precision head) as the alternative, followed by exact sampling and speculative decisions, drafting, repair, the stack on every axis and the serving frontiers. The compiler, selector, scheduling and GPU tiling material is condensed into an appendix of untested mechanisms. - Exactness: the contract is the stock head kernel's decision at the same batch shape, certified through the gap condition with fallback to that kernel. R-bf16 is shown not to be the contract with the witness from tests/test_precision.py. Adds the three contracts, the commit rule, the directional margin and the dead/deferred/enclosed accounting (P1), and what an exact recurrent state must retain (P4). - Theory from PR #7 with proofs: accumulation trees, the envelope, the integer pass, outward rounding, the refinement ladder, candidate counts, certified races, fixed-noise verification, guards with enclosures, residual races, and the transport-versus-self-evidence crossover with the drift ratio defined exactly. New with proofs: the common-mass characterization, the bounded-range sampler, and the KL and sequence total-variation bounds for the approximate mode. - Citations: natbib with paper/references.bib from PR #6, the audit's text corrections applied (DSpark and D-cut for the sampled-depth counterexample, prior art for the certified greedy head, CSV-Decode, NanoSpec, the public DFlash-4B drafter), and a narrowed novelty claim. Long code paths in the bibliography may now break across lines. - Evidence status: \pending, \underreview and \pendingfigure macros; every GPU result is a marked pending item; a hypothesis table and a claim ledger list each claim with its status and evidence path. - Figures: TikZ diagrams for the two evidence sources and the contract; PGFPlots for the synthetic drift work counts (read from data/synthetic_drift.csv), the candidate-count bound, derived bytes per step and the batch-union model. - README and RUNBOOK rewritten to match the paper and the commands on main; SETUP no longer quotes a page count.
- Remove private coordination paths from pending items and comments. - Computed norms: the N2 proof now counts the rounding of the squares, and N1 is stated for summation depth 2^13 (the margin is negative at 2^14), as in PR #7's reference. - R-stock: a competitor is excluded only when hi_j < lo_a - delta_aj, with delta_aj from enclosures; the level-0 filter is widened by delta_max so that dropped rows meet the gap; Figure 2 shows both. - Minimal state: the bound uses the span of differences of reachable states and needs the reachable set to contain a relatively open subset of its affine hull; the one-state counterexample is noted. Storage is d_v r per request when the key subspace is shared. - Fixed-noise verification: equal in law, drafter-invariant, and token-identical to the seeded sampler on the verify pass's own logits; equality with plain seeded decoding needs verify and plain logits to agree, which the engine does not guarantee. - P1 is stated as rejected by its kill test, with the evidence pending in the geometry pull request. - Define the repair gate's symbols, note that the directional margin is followed by the gap condition, say that SGLang logs the reset to 48, and scope the independent-review statement to the cited work.
Why
H3 (TASKS.md) needs a rigorous error envelope for a cheap LM-head pass, a precise statement of which reference the certified head reproduces, and an exact CPU reference the kernel work can be checked against. This PR supplies those, reviews the manuscript's mathematics, and compares transport (the paper's mechanism) with self-evidence on the real Qwen3.5-4B head.
What changed
src/precision_reference.py: exact reference with BF16/FP32/FP64 rounding emulated on Fractions. Quantized-head envelopes (Cauchy-Schwarz, blockwise, Hoelder, exact outlier columns), the accumulation-tree bound for sequential, pairwise, blocked, split-K and a fused tensor-core adder model, outward rounding of the computed interval, a certified argmax/top-k refinement ladder (approximate pass, FP32, FP64, exact), races under a counter-based noise field, sampled acceptance with partition intervals, residual and SGLang-style sibling races, a W8A8 integer pass, and an emulation of the stock BF16-output head.tests/test_precision.py: 20 test methods, 39,761 generated checks against real arithmetic, including near-ties, exact ties, forced race ties, adversarial uniforms, refusals, witnesses that each envelope term is needed, and a witness that R-bf16 is not stock equality.formal/CertifiedArgmax.lean: certified argmax and candidate filter, uniqueness across refinement levels, guards with an enclosed numerator, residual intervals, the l_inf/l_1 Hoelder bound and the sequential gamma_n bound, in scaled integers.scripts/check_lean.shnow checks every file informal/;formal/STATUS.mdupdated (both files elaborate under Lean 4.19.0; only Lean's standard axiomspropext,Quot.soundand, throughomega,Classical.choice; nothing added).experiments/precision_head_constants/head_constants.pyandevidence/precision/: test report and log, Lean log, weight-only head constants, README with commands.sources/manuscript_review.md: every theorem, example and numerical claim inpaper.texwith a verdict and correction.pyproject.toml:precision_referenceadded to known-first-party.Main results
torch.argmaxtakes the lowest index among equal values. The adopted contract is R-stock: the certified head returns the token the stock head kernel returns for this hidden state at this batch shape. It certifies a candidate only when the gap condition (stock_gap,stock_agrees) holds for every value the stock kernel could produce, and otherwise runs the stock head at the same shape with its own argmax and tie rule.Gbounds the stock kernel's accumulation error; on sm_90 it rests on the Khattak-Mikaitis tensor-core model, which is an assumption. Reduced-precision split-K (the PyTorch default) has no such bound, so the stock baseline must disable it or the fallback must cover it (witness in the tests). R-real (argmax of the exact logits of the BF16 operands) and R-bf16 (argmax of those logits rounded to BF16) are batch-invariant references only; neither is stock equality. Witness:W = [[16,0,0],[16,1/16,2^-30]],h = [1,1,1]: R-bf16 picks token 1, the emulated stock head (FP32 sequential, BF16 output) picks token 0, and the gap condition refuses to certify (test_bf16_contract_is_not_stock). The earlier 900/900 agreement figure only exercised the tie rule: in all 900 comparisons the emulated stock rounding coincided with exact rounding.|z - zt| <= Q + gamma_d ||w_bar|| ||h|| + (underflow), with computable per-token norms and outward rounding constants for FP32; the tensor-core case rests on the published Khattak-Mikaitis model (gamma about 1e-4 at D = 2560; conservative default 6.1e-4). The W8A8 path needs no accumulator model.||h_t - h_d||_2 / ||h_t||_2at the head input (after the final norm). For row i, transport's l2 half-widthr_c(i) ||Delta||_2is narrower than the int8 per-row round-to-nearest self-evidence half-width||e_i||_2 ||h_t||_2if and only if rho <||e_i||_2 / r_c(i), withr_c(i)the l2 radius about the mean of row i's 64-row tile of contiguous token ids. The median of that threshold over rows is 0.85% (p10 0.67%, p90 1.15%; 15.5% against int4); in the manuscript's own l_inf/l_1 family it is 0.30%. This compares envelope width only, not certification rate, candidate counts or runtime, and it ignores the BF16 rounding of draft logits that transport also carries. No measured rho distribution is in this PR; the geometry workstream's measurement decides this width comparison. 64-row tiles in token-id order are barely tighter than random tiles.e^(4 beta / T)rows. Fixed-noise (drafter-invariant) verification makes sampled verification a perturbed argmax with no partition function; its per-position acceptance lies between half and all of1 - TV(p, q).The replacement statements are derivations without a committed written proof in this repository. Their decision logic is implemented and tested here, and the written proofs will appear in the revised
paper/paper.tex.Validation
python tests/test_precision.py: 20/20 pass (35 s);pytest tests/: 54 passed (after mergingmain).bash scripts/check_lean.sh(with~/.elan/binon PATH): both files elaborate; a deliberately false variant is rejected.experiments/synthetic_drift.pyre-run on a scratch copy reproduces the manuscript's Table 4 exactly.Notes for review
N1valid to reduction depth 2^13 (N2to 2^14); also theoutward_intervalprecision range and contract names.mainwas merged in, so the mypy hook (fixed onmainin PR Silence mypy on the supplied bundle's files so the hook checks new code #8) now passes and no commit skips it.formal/STATUS.mdandscripts/check_lean.shnow differ fromSHA256SUMS, which records the supplied bundle;DecisionGuards.leanis unchanged (its "NOT COMPILED" header comment is stale).