theformalera-conformance serves two purposes:
- Trust in the specs. The official Hugging Face implementation of every supported model is checked against its spec, so “is the spec right?” becomes “does the spec equal the official implementation?”.
- Verify your own implementation. Pass any PyTorch implementation of a supported model (a from-scratch rewrite, a port, an agent-generated model) and get the same verdict, with the first layer at which it disagrees.
The checks
How the comparison works
1
Draw weights from the spec's manifest
The spec lists every parameter tensor with its shape and an init kind (
linear, embedding, norm_scaled, norm_offset, …). Weights are drawn so that activations stay O(1) through the network. Norm weights are perturbed away from their identity value, so a wrong formula cannot hide behind w = 1.2
Evaluate the spec with the Lean oracle
theformalera-spec oracle evaluates the Model Spec in binary64. Its evaluators are proved equal to the spec definitions (runTrace_fst, linear_eq_linearPar, seqMap_eq_seqMapPar).3
Run the implementation in float64
The implementation is built and run with float32 requests promoted to float64: tensors created as
float32, .float(), .to(torch.float32), softmax(…, dtype=float32). That way both sides evaluate the same real-number expression, up to rounding and summation order.4
Compare every block
For each tensor, the relative error
max |impl − spec| / max |spec| must be at most --rtol (default 1e-9). A failure reports the first block that disagrees: every earlier block agrees with the spec, so the bug is in that block.Floating-point non-associativity is disregarded by design. Measured agreement for correct implementations is around
1e-15; a real bug shows up at 1e-6 (a misplaced ε) to 1e0 (a wrong head mapping).The reduced-width profile
By default, conformance uses a reduced-width configuration of the same architecture. It has the same layer-type pattern, attention variants, norms, RoPE variant and multipliers, at a small width (hidden size 64–160, 4–8 layers, vocabulary 512). The theoremreduced_same_architecture proves the correspondence for every model. So a run takes seconds, even for 30B architectures.
--fulluses the full-size configuration on random weights.--pretrainedalso loads the published checkpoint and compares on a real prompt.
Next
Verify your implementation
What your implementation must expose, and how to read a failure.
Results for the official implementations
All eight models, measured.
