Repository navigation
Description
Context
PR #692 keeps the ModelOpt NVFP4 repair CUDA-targeted: CUDA builds repack the local gemma-4-31b-it-nvfp4 ModelOpt triplets into MLX native NVFP4, while non-CUDA builds keep the affine fallback. This avoids changing Apple Silicon behavior before it is measured on real M-series hardware.
Issue #693 should come first. It tracks direct ModelOpt triplet -> MLX native NVFP4 transcode with an explicit global-scale sidecar for weight_scale_2, removing the current dense f16 cold-load step and preserving the source two-level scale semantics. Apple Silicon should be evaluated after that direct path exists, so the Metal benchmark reflects the intended production path rather than the temporary dense f16 -> MLX quantize bridge.
Goal
Benchmark the direct native NVFP4 path on Apple Silicon and decide whether Metal/non-CUDA should switch from the affine fallback to native NVFP4 for ModelOpt Gemma 4 checkpoints.
Benchmark plan
Use an Apple Silicon host with the local gemma-4-31b-it-nvfp4 checkpoint available. Run the same harness and prompt set used by PR #692.
cargo build --release --bin mlxcel --bin mlxcel-bench-decode
./target/release/mlxcel-bench-decode -m models/gemma-4-31b-it-nvfp4 -p "Hello, how are you today?" -n 100 --warmup-tokens 20
./target/release/mlxcel-bench-decode -m models/gemma-4-31b-it-nvfp4 -p "Hello, how are you today?" --prompt-tokens 2048 -n 32 --warmup-tokens 20Record at least two variants on the same host:
- Current non-CUDA affine fallback from PR fix(cuda): repack ModelOpt NVFP4 to native MLX layout #692.
- Direct native NVFP4 path from perf(nvfp4): direct-transcode ModelOpt triplets to MLX native #693.
For each variant record short-prompt prefill/decode, 2048-prompt prefill/decode, MLX peak memory, and wall-clock cold-load time. Existing Metal baselines are useful context but must not replace same-branch A/B results: benchmarks/metal_m1ultra_2026-06-15.csv reported 38.90 prefill tok/s and 8.90 decode tok/s, benchmarks/metal_m5max_2026-06-15.csv reported 91.73 prefill tok/s and 7.16 decode tok/s, and benchmarks/metal_m1ultra_2026-07-06.csv later failed this checkpoint on v0.3.3.
Acceptance criteria
- perf(nvfp4): direct-transcode ModelOpt triplets to MLX native #693 is merged or the direct-transcode branch is available for Apple Silicon testing.
- Apple Silicon native NVFP4 direct path is benchmarked against the current affine fallback on short and 2048-token prompts.
- Enable the native path for Metal/non-CUDA only if 2048-token prefill improves by at least 20% and decode does not regress by more than 5% versus the affine fallback on the same host. Result: not enabled; 2048-token prefill regressed by 7.2% on M1 Ultra, so the gate did not pass.
- Cold-load wall time and peak load-time memory are reported separately from steady-state prefill/decode throughput.
- Greedy continuation parity is spot-checked against the affine fallback for at least 40 generated tokens, allowing only expected FP8 rounding drift.
- Results are recorded under
benchmarks/and summarized underdocs/benchmark_results/.
Outcome (2026-07-09)
Ran the A/B on Mac Studio M1 Ultra (128 GB, macOS 26.5.2) at commit 9be591346. Raw data is in benchmarks/metal_m1ultra_issue694_nvfp4_native_vs_affine_2026-07-09.csv; the summary is in docs/benchmark_results/nvfp4-native-metal-m1ultra-2026-07-09.md.
The direct native NVFP4 opt-in improved cold-load wall time (221.06 s to 82.74 s on the 2048-token run) and decode throughput (4.92 tok/s to 12.93 tok/s), but 2048-token prefill regressed from 124.58 tok/s to 115.61 tok/s. Because the required 20% long-prompt prefill improvement was not met, Metal/non-CUDA keeps the affine fallback default and MLXCEL_NVFP4_NATIVE_REPACK=1 remains opt-in.
Out of scope
This issue does not block PR #692. CUDA repair should ship first, then #693 should remove the dense cold-load bridge, then this issue decides whether the native path should be enabled on Apple Silicon.
Activity
fix(cuda): use native NVFP4 repack for ModelOpt Gemma 4
fix(cuda): repack ModelOpt NVFP4 to native MLX layout (#692)
inureyes commentedon Jul 8, 2026
Issue #693 is merged (PR #697), so the direct ModelOpt-triplet NVFP4 transcode is the CUDA default in main and the first acceptance criterion here is done.
PR #699 adds the opt-in override this benchmark plan needs: a new
MLXCEL_NVFP4_NATIVE_REPACKenv var (same case-insensitive 1/true/on/yes parsing asMLXCEL_NVFP4_DENSE_REPACK) that lets a non-CUDA build take the same direct transcode CUDA already uses, without any code change. All three NVFP4 repack decision sites insrc/models/sanitize.rsnow go through one pure function,nvfp4_repack_strategy, so they can never disagree, and it documents an Apple Silicon A/B runbook indocs/benchmark_results/nvfp4-direct-transcode-gb10-2026-07-08.md. This machine is GB10 Linux CUDA, so the PR does not run the benchmark or flip any default; both remain open on this issue.The remaining work is the M-series A/B run itself. On an Apple Silicon host with the local
gemma-4-31b-it-nvfp4checkpoint, build withcargo build --release --bin mlxcel --bin mlxcel-bench-decode, then run each of these once with no override (the current affine fallback) and once withMLXCEL_NVFP4_NATIVE_REPACK=1(the direct transcode):Record cold-load wall time, MLX peak memory, short-prompt and 2048-token prefill/decode tok/s, and a 40+ token greedy parity spot-check between the two paths. The decision gate from the acceptance criteria: enable the direct transcode as the Metal/non-CUDA default only if 2048-token prefill improves by at least 20% and decode does not regress by more than 5% versus the affine fallback on the same host.
perf(nvfp4): add opt-in native repack override for non-CUDA builds (#699
docs: record Metal NVFP4 native benchmark (#694) (#702)
perf: default Metal NVFP4 to native transcode (#705) (#706)
fix(cuda): repack ModelOpt NVFP4 to native MLX layout (lablup#692)
perf(nvfp4): add opt-in native repack override for non-CUDA builds (l…
docs: record Metal NVFP4 native benchmark (lablup#694) (lablup#702)
perf: default Metal NVFP4 to native transcode (lablup#705) (lablup#706)