Skip to content

test(models): measure and falsify the #2852 default-device lead - #2866

Merged
inureyes merged 1 commit into
mainfrom
fix/issue-2852-nemotron-nvfp4-order-dependence
Nov 6, 2026
Merged

inureyes merged 1 commit into
mainfrom
fix/issue-2852-nemotron-nvfp4-order-dependence

Conversation

@inureyes

@inureyes inureyes commented Nov 6, 2026

Copy link
Copy Markdown
Member

Summary

Test-only change. The last unmeasured candidate for the single #2852 miss, a process-global MLX default device left on the CPU by an earlier test, is measured and falsified. The failure message now also names the device, the backend, and how many elements actually missed the bound.

What changed

  • src/models/nemotron_h_tests.rs: new nemotron_h_nvfp4_experts_parity_is_independent_of_the_default_device runs both routing arms on the ambient device, again with the default device forced to the CPU, and again after the CPU span is restored. At 40 tokens the CPU arm's max absolute error is 5.7e-6 against 7.6e-6 on the GPU, and the restored arm reproduces the GPU baseline's measured errors exactly, so neither the device nor a cross-device cache explains the miss.
  • The case construction is split into run_nvfp4_expert_arms and ExpertParityError::measure, so the parity assertion and the device test share one definition and the message can report max_abs, max_rel, out-of-bound count, non-finite count, default device, and GPU backend.
  • The test doc records the falsification. The 1e-3 bound, both arms, and the guards from test(models): diagnose the Nemotron NVFP4 expert parity test #2854 are unchanged.

Test plan

  • cargo test --profile test-fast --features metal,accelerate -p mlxcel --lib models::nemotron_h::tests:: -- --test-threads=1
  • Two consecutive serial lib runs: 11367 passed, 0 failed, 239 ignored each (cargo test --profile test-fast --features metal,accelerate -p mlxcel --lib -- --test-threads=1)
  • cargo fmt --all -- --check
  • cargo clippy --profile test-fast --features metal,accelerate -p mlxcel --lib --tests -- -D warnings

The issue stays open: no leaking global was demonstrated, so there is no failing-first regression test for the numeric miss itself. This PR closes the default-device lead with a measurement and leaves the diagnostic in place for the next occurrence.

Refs #2852

The single #2852 miss never reproduced. The last unmeasured candidate was a process-global MLX default device left on the CPU by an earlier test, which would move the quantized gather off the backend where the 1e-3 bound was measured.

Forcing the default device to the CPU for the whole case, the nvfp4 quantize and the f32 dequantize reference included, measures 5.7e-6 max absolute error at 40 tokens against 7.6e-6 on the GPU, and the arm after the CPU span reproduces the GPU baseline exactly. The lead is falsified, so no leaked device can produce the observed miss. The new test pins the device independence so a future CPU-path divergence fails there.

The failure message now also reports the out-of-bound and non-finite element counts, the default device, and the GPU backend. The 1e-3 bound and both arms are unchanged.

Refs #2852
@inureyes inureyes added status:review Under review type:test Test related changes priority:medium Medium priority area:models Model architectures, weights, loading, metadata area:core mlxcel-core: MLX FFI, primitives, KV cache, layers labels Nov 6, 2026
@inureyes
inureyes marked this pull request as ready for review November 6, 2026 01:48
@inureyes
inureyes merged commit 1615062 into main Nov 6, 2026
31 checks passed
@inureyes
inureyes deleted the fix/issue-2852-nemotron-nvfp4-order-dependence branch November 6, 2026 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core mlxcel-core: MLX FFI, primitives, KV cache, layers area:models Model architectures, weights, loading, metadata priority:medium Medium priority status:review Under review type:test Test related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant