Repository navigation
Description
Problem / Background
PR #266 fixed an unconditional mlxcel_core::eval(&result) at the end of every SSM/Mamba2 mixer forward in falcon_h1.rs, granitemoehybrid.rs, and plamo2.rs. That eval was an M5 Max (Metal GPU Family 4) NaN-avoidance workaround but was never hardware-gated, so on non-M5 Apple Silicon it forced a per-layer GPU sync that blocked decode pipelining, causing a 3-5x decode regression on those hybrids. The fix gates it on mlxcel_core::hardware::is_m5_neural_accelerator().
src/models/nemotron_h.rs carries the SAME unconditional per-mixer eval at roughly line 648, so it almost certainly has the same regression on non-M5 hardware. However, nemotron_h is more involved than the other three: it ALSO has a separate needs_chunked_eval / eval_interval materialization path in its main layer loop (around line 2042) that additionally evals the Mamba conv/ssm cache states, plus a debug-timing eval path (around line 2033). So this is not a blind copy of #266.
This was discovered while benchmarking newly ported model families against mlx-lm 0.31.3 on an Apple M1 Ultra (128 GB, macOS 26.5.1, MLX commit a6ec712). Decode throughput was measured with mlxcel-bench-decode (warmup pass + measured pass in one process, --no-chat-template) versus scripts/bench_mlxlm.py (mlx-lm's own prompt_tps/generation_tps), identical checkpoint, raw continuation prompt, 100 decode tokens, best-of-3 with cooldown, temp-0 greedy.
Proposed Solution / Scope
- Gate the per-mixer eval (~line 648) on
is_m5_neural_accelerator()like perf(models): gate Mamba2 mixer eval boundary to M5 Max #266. - Analyze the interaction with the chunked-eval path: make sure non-M5 hardware still materializes conv/ssm cache states correctly (the chunked path exists partly for that) and that we don't double-materialize.
- Validate on a real Nemotron-H checkpoint (
models/nemotron-h-30b-4bitis available locally; the recommended set also lists Nemotron-H 8B): decode tok/s before/after, and confirm greedy temp-0 output is byte-identical before/after.
Acceptance Criteria
- Per-mixer eval (~line 648) gated on
is_m5_neural_accelerator(). - Interaction with the chunked-eval /
needs_chunked_evalpath analyzed; non-M5 hardware still materializes conv/ssm cache states correctly with no double-materialization. - nemotron_h decode improves on non-M5 hardware with byte-identical greedy temp-0 output before/after.
- M5 Max behaviour unchanged (gate returns true there).
Activity
docs(benchmarks): MoE decode gap investigation (#268)
docs(benchmarks): MoE decode gap investigation (#268) (#273)
perf(models): gate nemotron_h Mamba2 per-mixer eval to M5 Max (lablup…
docs(benchmarks): MoE decode gap investigation (lablup#268) (lablup#273)