You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(core): hardware-gated MLX_MAX_OPS_PER_BUFFER default (Gemma3n +11-13% on M1 Ultra, regresses on M5) #353
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
perf(core): hardware-gated MLX_MAX_OPS_PER_BUFFER decode default (lab…
fix(bench): apply the CUDA graph-cache default in speculative_bench t…
perf(cuda): raise the MLX graph budgets on GB10 for measured families (…
perf(metal): raise the command-buffer input budget for decode only (#…
perf(core): hardware-gated MLX_MAX_OPS_PER_BUFFER decode default (lab…