Skip to content

perf(core): hardware-gated MLX_MAX_OPS_PER_BUFFER default (Gemma3n +11-13% on M1 Ultra, regresses on M5) #353

Closed

Description

@inureyes

Problem / Background

Follow-up to #329 (decode profile, merged PR #345). The Gemma3n decode profile in docs/benchmark_results/gemma3n-decode-profile.md found that raising MLX_MAX_OPS_PER_BUFFER from its default to ~1000 yields +11-13% decode throughput on M1 Ultra (gemma3n-e2b 82.7 -> 93.2, e4b 63.0 -> 70.0) by closing command-buffer dispatch-gap idle, with a plateau around 1000. The profile deferred this as a separate follow-up because it is a scheduling knob, not a fusion, and because M5 regresses with larger command buffers (the prior M5 investigation found the default fastest on M5-class hardware). A single global default change is therefore unsafe.

Proposed Solution

  • Implement a hardware-gated default for MLX_MAX_OPS_PER_BUFFER (gate on hardware class, for example has_neural_accelerator / Apple-Silicon generation) rather than a single global value.
  • Re-bench across M1 Ultra, M5, and GB10 before landing.
  • Check whether the win generalizes beyond Gemma3n or is model-specific.
  • Keep the env var as a manual override in all cases.

Acceptance Criteria

  • A hardware-gated default that improves M1 Ultra decode with no M5 regression.
  • Cross-hardware bench (M1 Ultra + M5 + GB10) recorded in the profile doc (or a linked doc).
  • The MLX_MAX_OPS_PER_BUFFER env var preserved as a manual override.
  • A note on whether the gain is Gemma3n-specific or generalizes to other families.

Technical Considerations

The profile's "Recommended follow-up" section frames this exactly: make MLX_MAX_OPS_PER_BUFFER a Gemma3n-aware default around 1000, gated on hardware, with a cross-hardware re-bench required before it lands. The sweep showed a monotonic climb to a plateau near 1000 (e2b +12.7%, e4b +11%), then a slight regression at 2000. The gate must leave M5 on its current default, where larger buffers measured slower. See docs/benchmark_results/gemma3n-decode-profile.md.

Activity

  1. added
    type:performance
    area:core
    area:inference
    priority:medium
    status:ready
    status:in-progress
    status:review
    status:done
    and removed
    status:ready
    status:in-progress
    status:review
    on Jun 18, 2026
  2. added this to the 0.3 milestone on Jun 21, 2026
  3. self-assigned this
    on Jun 21, 2026
  4. added a commit that references this issue on Jun 23, 2026
    469ce9b
  5. added a commit that references this issue on Oct 27, 2026
    16dec52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:corearea:inferencepriority:mediumstatus:donetype:performance

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions