Skip to content

Scope the 1e-4 target to block fixtures and model outputs - #42

Merged
noelEOS merged 1 commit into
mainfrom
docs/numerical-comparison-scope
Nov 3, 2026
Merged

noelEOS merged 1 commit into
mainfrom
docs/numerical-comparison-scope

Conversation

@noelEOS

@noelEOS noelEOS commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Base: 7eb3e47. Docs only: CONTRIBUTING.md and AGENTS.md.

What changes

  • The 1e-4 target's scope. The 1e-4 absolute target against float32 PyTorch applies to every block fixture's outputs and to a model's final outputs (logits, and probabilities where produced). CONTRIBUTING already called it the "logit target"; this states the scope explicitly.
  • Intermediate outputs of a model are recorded and checked against a float64 run of the same PyTorch model, with the same float32 weights and input. The mirror's largest absolute error against float64 must be no larger than float32 PyTorch's own.
  • Every comparison records its scale:
    • the largest absolute value;
    • the float32 step at that value;
    • the errors against float32 and float64 PyTorch;
    • argmax flips.
  • Random-weight model references use integer-generated weights, as fixtures already do, never a library's native random initialization. Their BatchNorm running statistics are calibrated from fixed integer-generated inputs, by a procedure fixed in advance and run once. Trained models keep their trained weights, and records made with native initialization stay as history.
  • Claims: CONTRIBUTING now keeps four claims apart, as AGENTS.md already does.

Why

The full-width SMP DPT target, built with its native random initialization, reaches activations near 190 in its late decoder. There, one float32 step is about 1.5e-5. The offline mirror misses 1e-4 against float32 PyTorch (fusion3 6.03e-4), but float32 PyTorch is itself 6.13e-4 from float64 PyTorch, while the mirror is 1.18e-4 from it (docs/evidence/dpt-dtype-offline.json).

Offline diagnostics (not committed) showed that:

  • with BatchNorm statistics calibrated from data, the logits come within 1e-4 of float32 PyTorch, and every output comes within 1e-4 of float64 PyTorch;
  • the remaining misses are in intermediate fusion maps, where float32 PyTorch is as far from float64 as the mirror is from float32 PyTorch;
  • native initialization builds different weights on macOS and Linux from the same seed.

The DPT reference will be moved to the new procedure in a follow-up.

Checks

  • tests/test_docs.py, tests/test_history_citations.py, tests/test_x08_docs_and_api.py: 25 passed.
  • No code, test, golden or evidence change, so G1, G1-ext and the catalogue are unaffected.

The 1e-4 absolute target against float32 PyTorch now states what it applies
to: every block fixture's outputs and a model's final outputs. A model's
intermediate outputs are recorded and checked against a float64 run of the
same PyTorch model: the mirror must be no farther from it than float32
PyTorch is. Large intermediate values put 1e-4 out of reach of any float32
implementation, PyTorch's included.

Every comparison records its scale: the largest value, the float32 step
there, the errors against float32 and float64 PyTorch, and argmax flips.

Random-weight model references take integer-generated weights, as fixtures
already do, with BatchNorm running statistics calibrated from fixed
integer-generated inputs by a procedure fixed in advance and run once.
Native initialization is not bit-identical across platforms and can let
activations grow far beyond a trained model's. Records made with native
initialization stay as history.
@noelEOS
noelEOS merged commit 2ab98b7 into main Nov 3, 2026
3 checks passed
@noelEOS
noelEOS deleted the docs/numerical-comparison-scope branch November 3, 2026 15:41
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