tests: un-xfail torch↔JAX goldens under the embed-internal token contract#936
Open
ocg-goodfire wants to merge 1 commit into
Open
tests: un-xfail torch↔JAX goldens under the embed-internal token contract#936ocg-goodfire wants to merge 1 commit into
ocg-goodfire wants to merge 1 commit into
Conversation
…ntract The frozen equivalence + stacked-parity goldens were generated against the residual-fed contract (a float residual injected at the first decomposed layer) and xfailed since the residual-start removal (3883362): the model now takes token ids and embeds them itself. Rather than resurrecting a torch venv at the torch-oracle tag, regenerate the FIXTURES so `embed[tokens]` reproduces the committed residual bit-exactly (one distinct token per position, its embed row set to that position's residual - a pure integer gather, no arithmetic). The loss terms are a function of the residual entering the first decomposed layer, so every committed golden (torch_reference.json, all stacked_fixtures pins) stays valid UNCHANGED - the goldens still come from the torch oracle, never the JAX side. fixtures.npz gains only `tokens` + `embed`; every pre-existing array is byte-identical (verified). - equivalence: harness feeds tokens, model uses the fixture embed; all four numeric terms (faith/imp/stoch/ppgd) + the sc-broadcast test un-xfailed and pass at fp32 tolerance (rel err <= 9e-7) vs the frozen golden (SPEC S1/S3/S16). - stacked_parity: the fixtures' suffix (absolute layers 3..7, residual injected at 3) is rebuilt as the full 8-layer embed-internal model with identity prefix layers (zeroed attn + zeroed MLP -> block(x) == x), so site names keep their absolute indices and layer 3 sees the identical residual. The four CI-independent forward pins (clean / site_input+wd / masked / chunk-plan static live set, SPEC S2/S4/N2) un-xfailed and pass; masked_output calls go through prepare_compute_weights (the current API). The CI-numerics trajectory xfail (CIArch -> chunkwise transformer) is untouched - genuinely torch-oracle-dependent, out of scope. - test_chunk_plan_static_live_gate DELETED (not un-xfailed): it pinned S2 under a layer-SPLITTING chunk plan, a capability deliberately dropped by the static segmented masked forward (2f9af23 - "Drops partial-layer recon support"); the layer-aligned S2 realization stays pinned by the whole-layer stoch term and stacked test_chunk_plan_static_live_set_matches. Its dead helpers (_forward_with_split_mlp, chunk_plan_static_gate_kl) removed with it. - prose swept: the fixture generators + harnesses no longer speak in "suffix weights"/"suffix forward" terms - the last live remnant of the residual-fed design's terminology. Validation: both suites green at default device count and XLA_FLAGS=--xla_force_host_platform_device_count=4 (15 passed, 1 xfailed); basedpyright + ruff clean; gen_fixtures.py re-run confirmed byte-stable. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
Fast-follow to the residual-start removal (3883362) and the #923 terminology sweep: the frozen torch↔JAX equivalence goldens (
param_decomp/tests/equivalence/) and stacked-parity fixtures were generated under the old residual-fed contract and have been xfailed since the model went embed-internal (token ids in,embed[tokens]inside). This regenerates the fixtures — not the goldens — under the token contract and un-xfails the 10 pending tests.Key move: the goldens are preserved bit-for-bit, no torch-oracle re-run needed. The loss terms are a pure function of the residual entering the first decomposed layer. The fixtures now carry
tokens+embedwhereembed[tokens]reproduces the committed residual bit-exactly (one distinct token per position, its embed row set to that position's residual — a pure integer gather, no arithmetic). The JAX side now exercises the real token→embed forward, and its outputs still pin against the frozen torch-oracle values — which is exactly the parity these tests assert. Every pre-existing array infixtures.npzis byte-identical (verified programmatically); onlytokens+embedwere added.equivalence/ (6 tests un-xfailed)
test_jax_matches_torch_reference[faith/imp/stoch/ppgd]: all four terms match the frozentorch_reference.jsonat fp32 tolerance (rel err ≤ 9e-7). SPEC S1/S3.test_sc_source_broadcasts_over_batch_in_masked_forward: token-fed, passes (S1/S16).test_chunk_plan_static_live_gatedeleted, not un-xfailed: it pinned SPEC S2 under a layer-splitting chunk plan — a capability deliberately dropped by the static segmented masked forward (2f9af23: "Drops partial-layer (per_site / layerwise) recon support"). The residual-fed xfail masked that real blocker (the test now trips the layer-aligned assertion, not a numeric mismatch). The layer-aligned S2 realization remains pinned by the whole-layerstochterm and stackedtest_chunk_plan_static_live_set_matches. Dead helpers (_forward_with_split_mlp,chunk_plan_static_gate_kl) removed with it.stacked_parity/ (4 tests un-xfailed)
The fixtures pinned a residual-fed suffix (absolute layers 3..7 of an 8-layer tiny cfg, residual injected at layer 3), and site names carry absolute indices.
_loadnow rebuilds the target as the full 8-layer embed-internal model with identity prefix layers (zeroed attn + zeroed MLP ⇒block(x) == x):embed[tokens](== the fixtures' residual) passes through the prefix unchanged, so layer 3 sees the identical residual and all CI-independent goldens hold. Calls migrated to the current API (prepare_compute_weightsbeforemasked_output).test_clean_output_matches,test_site_inputs_and_weight_deltas_match,test_masked_output_match,test_chunk_plan_static_live_set_matches(SPEC S2/S4/N2).test_train_trajectory_matchesstays xfailed (strict) — its staleness is CI-numerics (old per-site-concatCIArch→ chunkwise transformer), genuinely torch-oracle-dependent and out of scope here.Prose sweep
gen_fixtures.py/jax_equivalence.py/test_equivalence.py/gen_stacked_fixtures.pyno longer speak in "suffix weights" / "suffix forward" terms — the last live remnant of the residual-fed design's terminology in the repo. (References to the torch oracle's residual-fed design remain where they describe that historical contract accurately.)Validation
pytest param_decomp/tests/equivalence/ param_decomp/tests/stacked_parity/: 15 passed, 1 xfailed at default device count ANDXLA_FLAGS=--xla_force_host_platform_device_count=4.python -m param_decomp.tests.equivalence.jax_equivalence: all 4 terms PASS vs the frozen golden.gen_fixtures.pyre-run: byte-stable (all arrays identical across runs); pre-existing arrays byte-identical to the previously committed npz.🤖 Generated with Claude Code