Repository navigation
test(rocm): complete the #1809 matrix rows with Metal M5 traces - #2083
Merged
Merged
Conversation
Compare the sixteen ROCm traces from PR #2059 against the Apple M5 Max traces with compare_logit_traces.py --decided 2.0, Metal as the reference, and fill in each row of the 2026-09-30 matrix doc: top-1 disagreement, decided mismatches, largest gap at a disagreement, logit delta percentiles, perplexity delta and verdict. Fifteen pairs pass with zero decided mismatches; nemotron-3-nano-30b-a3b w1 is inconclusive (0 / 0 decided positions). The largest gap at any disagreement is 1.250 (Nemotron-H w256). The doc states what is not like-for-like: the M5 reference takes NAX kernels where the M1 Ultra of the first run could not, Nemotron-H compares fused_moe_forward with forward_nonfused, and the VLM rows cover the language model only. The expected fused-SSM-kernel against SSD-graph pairing at w1 does not occur, because logit_trace starts every chunk with an empty cache, so no trace reaches that kernel on Metal. The Nemotron-H traces carry five loader lines on stdout that the compare script rejects; those comparisons ran on filtered copies. The ROCm trace README now points to ../metal_m5_d1128266/. Part of #1809
The w1 rows run every single-token forward on a fresh cache, so the hybrid SSM models take the SSD graph path and the fused ssm_update_kernel never runs on Metal. Add granite-4.0-h-tiny and nemotron-3-nano-30b-a3b traces at '1 128 8 512' with MLXCEL_TRACE_START_TOKEN=512, which prefill state before each single-token forward and therefore exercise the fused decode kernel.
The hybrid w1 rows run graph against graph: logit_trace builds a fresh cache per chunk, so without a prefill no single-token step has SSM state and Metal never takes ssm_update_kernel. The w1ctx512 rows (1 128 8 512 with MLXCEL_TRACE_START_TOKEN=512) prefill before each single-token forward, so Metal runs its fused SSM update and ROCm runs the SSD graph with state. Adds benchmarks/logit_traces/rocm_gfx1151_3c9edea0/ with the granite-4.0-h-tiny and nemotron-3-nano-30b-a3b traces, built at 3c9edea on gfx1151 (logit_trace sha256 00686315...), and compares them with the Metal M5 traces at the same commit. Both pass at --decided 2.0 and are zero at 0.5 and 1.0: granite 0 / 60 decided mismatches, largest gap 0.125, perplexity 7.090 vs 7.234; nemotron 0 / 71, largest gap 0.250, 7.489 vs 7.489. The correctness doc and the c5fe9a1 README record the commit difference from the other sixteen rows, the ROCm fixes merged in between, and that Apple has no switch to A/B the fused kernel against the graph. Refs #1809
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.
Part of #1809
Brings in the Apple M5 Max Metal traces for the five checkpoints PR #2059 traced on ROCm (commit 9830bd6 from
data/issue-1809-metal-traces, cherry-picked with its authorship) and completes every row ofdocs/benchmark_results/rocm-correctness-gfx1151-2026-09-30.mdagainst them, Metal as the reference, with the 2026-09-12 criterion (zero mismatches on positions decided at--decided 2.0). It also adds twow1ctx512rows that cover Metal's fused SSM update kernel (commits d2043c9 and c570666 from the same branch for the Metal half, plus new ROCm traces).Result
No pair fails. Over the first sixteen pairs top-1 disagrees at 155 of 6720 positions, 0 of 2696 decided; the largest reference gap at a disagreement is 1.250 (Nemotron-H w256, rank 2). The doc also has the logit delta percentiles, perplexity deltas, a 0.5/1.0/2.0 threshold sweep and the rank distribution.
The w1ctx512 rows
The earlier caveat "w1: Metal runs the fused SSM update kernel, ROCm runs the SSD graph" was wrong. The fused step needs
seq_len == 1,ssm_kernel_available()and an existingssm_state, andlogit_tracebuilds fresh caches per chunk, so w1 without prefill runs the graph on both backends: w1 is graph against graph.w1ctx512(1 128 8 512,MLXCEL_TRACE_START_TOKEN=512) prefills 512 tokens before each single-token forward, so Metal runsssm_update_kernel(insidefused_mamba2_forwardfor Nemotron-H) and ROCm runs the SSD graph with state.metal_m5_3c9edea0/,rocm_gfx1151_3c9edea0/), a later commit than the other sixteen pairs. The ROCm binary (sha25600686315...) was built on this branch at 8e65051, which differs from 3c9edea only in data and docs. The Metal d112826 w1ctx512 traces have byte-identical data rows.Not like-for-like (stated in the doc)
fused_moe_forwardwith ROCmforward_nonfusedat every width.Findings for follow-up
src/models/nemotron_h.rsprints five loader lines to stdout, so every Nemotron-H trace (both backends) makescompare_logit_traces.pyraiseValueError. Those pairs were compared on copies filtered withgrep -v '^\[NemotronH\] '; committed traces are unchanged. The# deviceheader line of newer traces is read as metadata and needs no filter.Verification
On the gfx1151 host:
sha256sum -c SHA256SUMSin all three new or updated trace directories;cargo build --release --features rocm --example logit_traceat 8e65051 and the two w1ctx512 ROCm traces (exit 0, 128 data rows, no NaN), each started with no other process in/sys/class/kfd/kfd/proc; all 18 comparisons run;make verify-versions verify-kernel-dtype-keys verify-kernel-port-dispatch verify-llama-compat verify-rocm-overlay verify-fmt verify-binary-assetspass;cargo test --features rocm --test dead_doc_pointerspass (2 tests).Not verified: Metal and CUDA are not available on this host. The Metal traces were produced on the M5 Max and are taken on their METADATA.txt, RUNS.txt and checksums. No code on the Metal or CUDA paths changes.