Repository navigation
fix(models): keep Raon DFlash2 verify blocks byte-exact on CUDA - #3476
Conversation
The Raon-1 mini exactness probe failed on CUDA (GB10), so `mtp_exactness_gate` declined the DFlash2 drafter there. Output was unchanged (fail-closed), but speculative decoding was off. Two products made a verify row differ from its decode step in the last bit: - The mHC route, aggregate and mix multiply batched over the positions (`basis @ z @ basis_t`, `h_pre @ streams`, `h_res @ streams`). CUDA picks the batched kernel, and so the summation order, by the block length. Inside a verify block they now run one position at a time; prefill and decode keep one matmul. - Since #3461 a decode step takes the compiled mHC site graphs, while a verify block took the eager ops. On CUDA the fused graph can contract a multiply and an add into one FMA, so the two differ by rounding. A verify block now runs the same compiled graphs once per position, so its rows equal the decode steps by construction on every backend. `compiled_site_equals_the_eager_site_bit_for_bit` stays bit-exact off CUDA and allows rounding-level differences on CUDA (observed worst 1.6e-7 relative). New `a_compiled_verify_block_equals_its_decode_steps_bit_for_bit` covers the invariant exactness now relies on. Validated on GB10 (`--features cuda`): `raon` 53/53 under every `MLXCEL_RAON_DECODE_FUSION` setting (default, off, selector, mhc), `speculative` 207, `exactness` 36, `gated_delta` 14. Metal and ROCm runs are pending. No Raon-1 mini checkpoint is on this host, so the real-checkpoint probe was not run. Closes #3474
Metal validation (M1 Ultra, head
|
| Suite | Result |
|---|---|
raon, MLXCEL_RAON_DECODE_FUSION unset |
53 passed, 0 failed |
raon, off |
53 passed, 0 failed |
raon, selector |
53 passed, 0 failed |
raon, mhc |
53 passed, 0 failed |
speculative |
205 passed, 1 failed, 6 ignored |
exactness |
36 passed, 4 ignored |
gated_delta |
14 passed, 11 ignored |
Named tests, each ok in all four raon runs (the raon1_mini::speculative ones also ok in the speculative run):
raon1_mini::speculative::tests::a_verify_block_equals_the_decode_chain_byte_for_byte: okraon1_mini::speculative::tests::a_steered_verify_block_applies_the_alpha_exactly_as_decode_does: okraon1_mini::speculative::tests::rollback_after_a_partial_accept_equals_a_fresh_decode_of_the_accepted_tokens: okraon1_mini::speculative::tests::the_exactness_probe_passes_on_the_tiny_model: okraon_mhc::tests::compiled_site_equals_the_eager_site_bit_for_bit(byte comparison on Metal): okraon_mhc::tests::a_compiled_verify_block_equals_its_decode_steps_bit_for_bit: ok
The one speculative failure is unrelated to this PR: models::inkling2::speculative::tests::the_verify_block_matches_the_chain_on_metal panics at src/models/inkling2_speculative_tests.rs:192:13 with passes 1 width 2: Diverges { position: 0, differing_bytes: 28, total_bytes: 120 }. It fails identically 3 of 3 times on this head and 3 of 3 times on the base 89425173, and this PR touches only raon_mhc*.rs. It is the M1 Ultra failure already tracked in #3468.
Not run: the real-checkpoint DFlash2 exactness probe, the temperature-0 drafter on/off output comparison, and the decode tok/s comparison against 89425173. No Raon-1 mini checkpoint (raon-1-mini, raon-1-mini-mlx, raon-1-mini-nvfp4) or DFlash2 drafter for it is present on this host, so the cost of running the compiled site graphs per position in the verify block is still unmeasured on Metal.
ROCm gfx1151 validation at
|
| run | result |
|---|---|
make test-fast-rocm FILTER=raon, MLXCEL_RAON_DECODE_FUSION unset |
52 passed, 1 failed |
same, =off |
51 passed, 2 failed |
same, =selector |
52 passed, 1 failed |
same, =mhc |
51 passed, 2 failed |
FILTER=speculative |
PASS: 206 + 4 passed, 0 failed |
FILTER=exactness |
PASS: 36 passed, 0 failed |
FILTER=gated_delta |
PASS: 14 passed, 0 failed |
Requested tests, per fusion mode (unset / off / selector / mhc):
| test | result |
|---|---|
raon1_mini::speculative::tests::a_verify_block_equals_the_decode_chain_byte_for_byte |
ok / ok / ok / ok |
raon1_mini::speculative::tests::a_steered_verify_block_applies_the_alpha_exactly_as_decode_does |
ok / ok / ok / ok |
raon1_mini::speculative::tests::rollback_after_a_partial_accept_equals_a_fresh_decode_of_the_accepted_tokens |
ok / ok / ok / ok |
raon1_mini::speculative::tests::the_exactness_probe_passes_on_the_tiny_model |
ok / ok / ok / ok |
raon_mhc::tests::a_compiled_verify_block_equals_its_decode_steps_bit_for_bit |
ok / ok / ok / ok |
raon_mhc::tests::compiled_site_equals_the_eager_site_bit_for_bit |
FAILED / FAILED / FAILED / FAILED |
The four DFlash2 tests that failed on ROCm at main 894251735 now pass, so the fix holds on gfx1151.
Both remaining failures already exist on main. At main 894251735, run twice per mode, they fail the same way. compiled_site_equals_the_eager_site_bit_for_bit fails in all four modes. native_batched_decode_matches_per_sequence_decode fails under off and mhc and passes under unset and selector. The PR does not cause them.
compiled_site_equals_the_eager_site_bit_for_bit: the assertion is identical in all four modes. One byte differs (203 vs 204), a 1-ulp difference in the first f32 of h_res:
thread 'models::raon_mhc::tests::compiled_site_equals_the_eager_site_bit_for_bit' panicked at src/models/raon_mhc_tests.rs:232:9:
assertion `left == right` failed: d 64 seed 0 dtype 12 rows 1: h_res
left: [203, 221, 79, 63, 174, 176, 181, 60, 149, 119, 71, 61, 171, 233, 239, 61, 38, 88, 85, 61, 201, 242, 87, 63, 133, 179, 213, 61, 138, 174, 161, 55, 121, 34, 98, 60, 128, 152, 190, 61, 108, 16, 75, 63, 207, 159, 204, 61, 63, 33, 250, 61, 16, 202, 40, 61, 157, 26, 92, 61, 141, 109, 72, 63]
right: [204, 221, 79, 63, 174, 176, 181, 60, 149, 119, 71, 61, 171, 233, 239, 61, 38, 88, 85, 61, 201, 242, 87, 63, 133, 179, 213, 61, 138, 174, 161, 55, 121, 34, 98, 60, 128, 152, 190, 61, 108, 16, 75, 63, 207, 159, 204, 61, 63, 33, 250, 61, 16, 202, 40, 61, 157, 26, 92, 61, 141, 109, 72, 63]
raon1_mini::tests::native_batched_decode_matches_per_sequence_decode (off and mhc only). The other panics in its output are the harness's expected-panic subcases. The failing assertion:
off: panicked at src/models/batched_decode_harness.rs:665:9:
mixed=true step 1 row 0 exceeds absolute tolerance 0.00001: max |diff| 1.1205673e-5, values [8.106232e-6, -7.1525574e-7, 2.9802322e-7, 3.0994415e-6, 6.914139e-6, -4.708767e-6, -4.887581e-6, 1.1324883e-6, 3.8444996e-6, 8.940697e-7, -1.9073486e-6, 1.1205673e-5, 1.66893e-6, -1.0728836e-6, -4.7683716e-7, -6.5118074e-6, 5.2452087e-6, -4.2915344e-6, -4.7683716e-7, -1.4305115e-6, -8.34465e-7, 5.841255e-6, 4.7683716e-6, 4.7683716e-7, -4.2915344e-6, -6.556511e-7, -1.1250377e-6, 5.9604645e-8, 7.867813e-6, -5.4836273e-6, -5.364418e-6, -5.00679e-6]
mhc: panicked at src/models/batched_decode_harness.rs:665:9:
mixed=true step 1 row 0 exceeds absolute tolerance 0.00001: max |diff| 1.168251e-5, values [8.46386e-6, -8.940697e-7, 1.3709068e-6, 2.503395e-6, 8.34465e-6, -4.2915344e-6, -5.2452087e-6, -3.5762787e-7, 4.7832727e-6, 6.556511e-7, -1.66893e-6, 1.168251e-5, 9.536743e-7, 2.3841858e-7, -4.7683716e-7, -6.1765313e-6, 4.7683716e-6, -3.6358833e-6, 1.4305115e-6, -1.2516975e-6, -1.0728836e-6, 5.2452087e-6, 4.2915344e-6, 0.0, -5.722046e-6, 1.7881393e-7, -1.4975667e-6, 3.427267e-7, 8.404255e-6, -5.364418e-6, -4.351139e-6, -4.529953e-6]
The raon runs stopped at the lib binary because it failed. No integration test matches the raon filter, so no coverage was lost.
Metal real-checkpoint validation (M1 Ultra), follow-upThis covers the items my previous comment listed as not run. Checkpoints were downloaded for this: Exactness probe. Temperature-0 equality. Decode tok/s (round 1 / round 2, default width 3, arms interleaved base plain, base drafted, head plain, head drafted per prompt; load average 5.7 at 14:30 and 7.7 at 14:34, background load present):
Acceptance is identical between the binaries (rate 0.502 / 0.833 / 0.537, 128 / 96 / 123 rounds). Verify time per round, base against head: short prose 44.4 / 44.1 ms, code 44.4 / 45.8 ms, long prompt 46.4 / 46.9 ms. The head's code round 2 is low in both its plain and drafted arms, which points to machine load and not the verify path. On Metal the per-position compiled site graphs cost within run-to-run noise, at most about 1% per verify round, at width 3. Not measured: other widths ( |
ROCm gfx1151 showed the same 1-ulp `h_res` difference between the compiled site graph and the eager ops that CUDA does (also on main), so `compiled_site_equals_the_eager_site_bit_for_bit` now applies its rounding tolerance on ROCm builds too. Metal and CPU builds still compare bytes. The verify-block test that exactness relies on is unchanged and passes on ROCm. Refs #3474
|
Metal verification of head
These six tests report
Real checkpointTarget Greedy output ( ThroughputThe arms were interleaved and rotated per round: 3 rounds x 2 reps x 2 prompts, medians of 6 runs, load average about 2.1. Drafter-on arms set
With the drafter off, the PR matches main. With the drafter on, the PR is 3.2% and 3.0% below main, and the min-max ranges of the two builds do not overlap. That gap is the measured cost of running the compiled site graphs once per position in the verify block. Acceptance per run: prompt 0 at 0.50 (128 rounds), prompt 1 at 0.77 (75 rounds). The drafter still pays for itself on both prompts (+11% and +39% over drafter off). Nothing was pushed or merged. |
|
ROCm validation of the new head
Not re-run on this head: the |
Hardening reviewReviewed against #3474. The fix is on the real path ( Pushed (
|
On CUDA the Raon-1 mini DFlash2 exactness probe failed, so the drafter was declined (output unchanged, speculative decoding off). Two causes, both fixed so each verify row equals its decode step on every backend:
basis @ z @ basis_t, aggregate, mix) pick their CUDA kernel by block length. Inside a verify block they now run per position; prefill and decode keep one matmul.compiled_site_equals_the_eager_site_bit_for_bitstays bit-exact on Metal and CPU and allows rounding-level differences on CUDA and ROCm (worst observed 1.6e-7 relative on CUDA, 1 ulp on ROCm, the ROCm case also on main). Newa_compiled_verify_block_equals_its_decode_steps_bit_for_bitcovers the invariant exactness now relies on.Validation
--features cuda):raon53/53 under everyMLXCEL_RAON_DECODE_FUSIONvalue (default, off, selector, mhc);speculative207,exactness36,gated_delta14; clippy-D warningsclean. The fourraon1_mini::speculativetests failed on main before this change.raon53/53 under every fusion value,exactness36,gated_delta14;speculativehas one failure that is the pre-existing test(models): two Metal block-vs-chain byte-identity tests fail on M1 Ultra #3468 (same on base).060dfeb5: the four DFlash2 tests that failed on main pass;speculative210,exactness36,gated_delta14. Thecompiled_sitebyte failure (also on main) is covered by the ROCm tolerance in29e67acd.native_batched_decode_matches_per_sequence_decodeexceeds its 1e-5 tolerance by about 1.2e-6 underoffandmhc, also on main, unrelated to this PR.Raon-1-mini-mlxwithRaon-1-mini-dflash2): probe passes, temperature-0 output with the drafter equals plain decode and the base, decode tok/s within noise of the base at width 3. Not run on CUDA (no checkpoint on the GB10 host).Closes #3474