Repository navigation
Done
Labels
area:architectureArchitecture and code structure changesarea:inferenceGeneration, sampling, decoding (incl. speculative, DRY)priority:mediumMedium prioritystatus:doneCompletedtype:enhancementNew features, capabilities, or significant additions
Milestone
Description
Part of #564
Problem
models/mlx/nvidia-nemotron-3-nano-30b-a3b-4bit (nemotron_h, 52 layers, 128 experts top-6 sigmoid, relu2, 17 GB at 4-bit) expands to 117.6 GiB of f32 weights at load, 111 GiB of it the expert bank. GB10 has 121 GiB unified memory (110 GiB available), so the 30B gates of #3350 are blocked.
Current Behavior (main 4d09a1b, src/lib/mlxcel-xla/src)
Config::supports_packed_quant(emitter/config.rs:2122) requiresself.moe.is_none()andself.ssm.is_none(), so the packed path (WeightSpec::QuantRaw,weights.rs:65;push_proj,weights.rs:125) never reaches an expert bank.- The MoE block (
weights.rs:547) pushes everyswitch_mlptensor asWeightSpec::Whole, andtake_moe_weights(emitter/model.rs:926) declares them f32 at any precision. pins_f32_precision(emitter/recurrent_config.rs:233) pins recurrent-state configs such asnemotron_hto F32.routed_experts(emitter/moe.rs:378) broadcastshnto[E, N, H](line 391), computes all E experts, then combines top-k.
Proposed Solution
- Keep an MLX affine-quantized expert bank packed on device (U32 packed plus f16 scales/biases per expert, about 14 GiB here) and dequantize in the graph.
- Compute only the top-k selected experts: gather their packed rows by index and combine with the routing weights. No
iree_linalg_ext.scatter. - Cover relu2 fc1/fc2 and SwiGLU gate/up/down, the shared expert, and the decode, prefill and ragged batch graphs, with one gate mirrored between loader and emitter as
supports_packed_quantdoes today. - Non-quantized checkpoints, and quantized MoE checkpoints with the feature off, stay byte-identical to current goldens.
Acceptance Criteria
- Existing MoE emitter structural goldens unchanged when the path is off; a new golden for the packed expert path. (feat(xla): keep the quantized MoE expert bank packed on device #3588; the sigmoid-router argmax fix changes the Nemotron-H MoE graph on both paths, no registered golden had it)
- Jamba and the
qwen2-moe-tinyfixture token-exact vs their oracles on cuda and ROCm with the path on. (feat(xla): keep the quantized MoE expert bank packed on device #3588: 4-bit Jamba and Nemotron-H MoE fixtures pass on cuda;qwen2-moe-tinyhas no checkpoint to run; ROCm pending) - No scatter in the CUDA dispatch dump. (feat(xla): keep the quantized MoE expert bank packed on device #3588: 30B and packed Jamba fixture, all production modules)
-
nvidia-nemotron-3-nano-30b-a3b-4biton cuda: CLI ids equal the MLX eager oracle (approved f32 substitute, see test(xla): validate Phase 3 hybrids on IREE-CUDA incl. Nemotron-3-Nano #3350 comments) for 40 tokens, andxla_batch_bench --batch 4 --requests 8is reference-exact. (feat(xla): keep the quantized MoE expert bank packed on device #3588: serve gate PASS; token gate diverges at index 5 on an exact bf16 tie in the MLX oracle, and EOS ends the oracle at 16 tokens) - Peak memory, compile time and tok/s at B=1/4 recorded in
spike/openxla/FINDINGS_ssm.md. (feat(xla): keep the quantized MoE expert bank packed on device #3588)
Verification
Run on GB10 with gpu-lock run for every GPU command; re-run on ROCm gfx1151 for the shared emitter change.
#3350 keeps its five-family gates; its 30B gates wait on this issue.
Metadata
Metadata
Assignees
Labels
area:architectureArchitecture and code structure changesarea:inferenceGeneration, sampling, decoding (incl. speculative, DRY)priority:mediumMedium prioritystatus:doneCompletedtype:enhancementNew features, capabilities, or significant additions
Activity
docs(xla): record the Phase 3 hybrid gates on IREE-CUDA (#3587)
docs(xla): correct the #3585 prefill and CLI measurements
feat(xla): keep the quantized MoE expert bank packed on device (#3588)