Skip to content

perf(models): gate nemotron_h Mamba2 per-mixer eval to M5 Max (follow-up to #266) #267

Closed

Description

@inureyes

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-4bit is 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_eval path 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

  1. added
    status:ready
    type:performance
    priority:medium
    area:models
    area:inference
    platform:macos
    status:in-progress
    status:review
    and removed
    status:ready
    status:in-progress
    on Jun 13, 2026
  2. added this to the 0.3 milestone on Jun 21, 2026
  3. self-assigned this
    on Jun 21, 2026
  4. added
    status:done
    and removed
    status:review
    on Sep 6, 2026
  5. added 2 commits that reference this issue on Oct 27, 2026
    7977094
    a8ccd04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:inferencearea:modelsplatform:macospriority:mediumstatus:donetype:performance

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions