Repository navigation
perf(cuda): raise the MLX graph budgets on GB10 for measured families - #1832
Merged
Merged
Conversation
Pure policy over the compute capability plus the env-wins applier for MLX_MAX_OPS_PER_BUFFER and MLX_MAX_MB_PER_BUFFER, in its own module because hardware.rs is already past the file-size limit. Not yet called from any entry point: the measurement that decides whether it ships runs on a binary whose behavior is identical to main, so the call sites follow the record. Refs #1798
…1798) Calls apply_cuda_graph_budget_default from mlxcel generate, mlxcel-server, mlxcel-bench-decode and mlxcel-speculative-bench right after the graph-cache and SDPA-cache siblings, and documents MLX_MAX_OPS_PER_BUFFER and MLX_MAX_MB_PER_BUFFER in the runtime variables table, including that the byte budget counts elements rather than bytes. Refs #1798
…ck (#1798) The sweep found the sign of raising both budgets depends on model shape, not only the device: Laguna +17%, Qwen 3.5 4B +4%, Llama 3.1 8B -9% with disjoint ranges, so a device-only default is not viable. The policy now reads config.json before any MLX op and applies the raised budgets only when one stacked routed-expert projection (experts x moe_intermediate x hidden at the checkpoint's packed width) exceeds MLX's 25 << 20 element budget for compute capability 12.1, which is the shape on which every expert matmul commits its own graph. Every entry point passes the -m path it was given; a repo id, router mode or a dense checkpoint leaves MLX's defaults alone. Refs #1798
…list (#1798) Four more MoE checkpoints disproved the expert-stack-size rule in both directions: gpt-oss-20b (32 experts, over the byte cap) loses 7% with +7 GB of peak memory, qwen3-30b-a3b (128 experts, under the cap) gains 21%, qwen3.5-35b-a3b gains 22% and gemma-4-26b-a4b is flat. The gate is now the model_type allowlist of the families measured to gain on sm_121 (laguna, qwen3_moe, qwen3_5_moe), read from config.json, the same shape as the Metal silicon-generation allowlist of #353. The stack-size machinery is removed; the environment-variables rows say what is applied for which families and name the memory cost. Refs #1798
The batched-serving phase, stopped mid-way by a host-protection halt, ran qwen3-30b-a3b negative at concurrency 4 and 8 under the raised budgets (partial, n of 1 to 2) while its single-stream result was +21% with disjoint ranges, and Laguna stayed positive on every workload measured (single-stream, CLI, serialized serving, the DFlash round, long prefill). The default therefore ships for the one family whose every measured workload gains; qwen3_moe and qwen3_5_moe wait on a server-path measurement in a follow-up. Docs rows and tests updated to match. Refs #1798
The measurement binary had the policy module compiled but uncalled, so nothing yet showed that the shipped `mlxcel` reaches the raised budget rather than only the environment sweep. This is the same-binary A/B that closes that: three arms on Laguna after a fresh boot, no environment at all against an operator-restored 20/25 against an explicit 100/1000, plus a dense checkpoint outside the allowlist as the negative control. Adds the post-reboot chain drivers (`sweep7.sh` phases ab and startup, `sweep8.sh` phases abcli, absrv, qbatched, q35, qprefill) and teaches `bench_srv.py` a `--wrap` argument so the batched path can be profiled under nsys the way the single-stream path already is.
Adds the section the record was missing: the three arms run against the wired binary rather than against MLX plus environment variables, so the claim that the shipped default reaches the raised budget is measured rather than assumed. On Laguna the no-environment arm (37.42 tok/s, 37.22 to 37.71) overlaps the explicit 100/1000 arm across its whole range and is disjoint from an operator-restored 20/25 (31.76, 31.09 to 32.31), +17.8%. MLX peak memory separates the same way with no timing involved, 22.03 GB against 21.66 GB. On the dense checkpoint outside the allowlist both arms overlap at MLX's own numbers, so the allowlist and not the compute capability is what fires. The startup lines from `mlxcel generate` and `mlxcel-server` are tabulated for the same arms, including the per-variable case where the operator sets only the op budget and the policy fills in the byte budget alone.
The bench binary and the production command are different entry points, so the A/B is repeated through `mlxcel generate` itself: no environment 34.13 tok/s (33.96 to 34.27) overlapping an explicit 100/1000 (33.81, 33.69 to 34.03), both disjoint from an operator-restored 20/25 (29.29, 29.04 to 29.67). The restored arm reproduces the pre-wiring CLI classic rate of the DFlash table, 29.40, which is what makes it a control rather than a third measurement. Token identity is not compared across arms because Laguna's classic decode is not reproducible across its own repeats on this host (#1799 measured that first); the budget moves graph boundaries, not arithmetic.
Third and last entry point of the A/B. One `mlxcel-server` per arm and round at concurrency 1, n = 3: no environment 29.03 tok/s aggregate (28.50 to 29.40) and an explicit 100/1000 at 29.23 (29.00 to 29.60), both disjoint from an operator-restored 20/25 at 27.70 (27.20 to 28.20), which reproduces the pre-wiring server row (26.90). Per-request decode agrees with the server's prefill and queueing removed, 32.50 and 32.40 against 30.63. These rows are a serialized workload, not a B > 1 measurement, because Laguna does not support batching; what they establish is that the default reaches the serving binary, which the single-stream and CLI arms cannot show.
…ot (#1798) The first pass of this arm was cut short by the host-protection halt at n = 1 to 2, which is why `qwen3_moe` was held out of the allowlist rather than listed on its +21% single-stream result. This is the full n = 3 re-run on a freshly booted host, all three rounds of all three arms. The held-out sign holds up. Raising both budgets gains at concurrency 1 (52.00 tok/s aggregate, 51.60 to 52.60, against 46.17, 44.70 to 48.00, disjoint) and does nothing measurable at 4 and 8 (+0.8% and -2.4%, ranges overlapping in both). The largest effect in the table is not the budget at all: graphs off is +32.4% at concurrency 8 (78.00 to 85.90 against 60.30 to 62.20, disjoint), so on this path capture itself is the cost and the budget is the wrong lever.
…#1798) Both families were held out of the allowlist for missing evidence rather than for losing: `qwen3_moe` had batched rows only at n = 1 to 2 before the host-protection halt, and `qwen3_5_moe` had no server measurement at all. Both are now measured at n = 3 on a freshly booted host, and neither joins. `qwen3_moe` gains where the server is doing single-stream work (+12.6% at concurrency 1, disjoint) and does nothing at 4 or 8 (+0.8%, -2.4%, both overlapping), so its first pass's apparent regression there was mostly its n of 1 to 2. `qwen3_5_moe` is the sharper case: +22.5% on single-stream decode, nothing at concurrency 1 and 4, and -10.7% at concurrency 8 with disjoint ranges. A family that gains on `mlxcel-bench-decode` can regress on the path a server actually runs, which is why the bar is every measured workload and why the allowlist stays `["laguna"]`. Also records that graphs off, worth +32.4% at concurrency 8 on qwen3-30b-a3b, is uniformly worse on qwen3.5-35b-a3b: the sign of a capture-policy change does not carry even within one architecture family.
Fourth measured workload for the two held-out families, and the one that prices the memory. A 2048-token prefill chunk gains on decode (+13.1% and +15.0%) but is slower on prefill itself (+14.4% and +8.0%, disjoint) and costs +16.3 GB on qwen3-30b-a3b and +8.2 GB on qwen3.5-35b-a3b, against Laguna's +7.0 GB. Peak memory is identical across all three repeats of every arm, so those are not noise. Also updates the policy module and the environment-variable rows, which still said the Qwen families were waiting on a follow-up measurement, and rewrites the chain-status section to separate what the host-protection halt stopped from what the reboot completed. The allowlist is unchanged at `["laguna"]`; what changed is that its two candidate additions are now measured rather than deferred. Adds the bilingual technical report for the unit.
7 tasks done
`Commands::SplitMtp` exists only under `feature = "surgery"` (`src/main.rs:237`), which is on by default but off in the feature sets CI compiles separately. The model-dir helper matched it unconditionally, so `cargo check --no-default-features --features xla-diagnostics --all-targets` failed with E0599 on the OpenXLA compile job while the default-feature build was green. Gates the arm the same way the variant and its dispatch arm are gated. Verified with `cargo check --no-default-features --all-targets`, the narrowest feature set that reproduces the error without needing IREE_DIST.
A default that has to reach every entry point touches the command enum, and that enum is feature-gated in places, so the match arm added for the model-dir helper compiled in every default build and failed only on a CI job that compiles without `surgery`. Worth a paragraph in the report because the failure mode is invisible to a local build and will recur for the next default of this shape.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MLX gives compute capability 12.1 (GB10 / DGX Spark) the tightest CUDA graph capture budgets in its table, 20 ops and 25 "MB", where every other Hopper and Blackwell part gets 100 and 1000. The byte counter is not bytes but an element count (
array::data_size()), so any op reading over 26.2M elements commits its own graph: a Laguna token at those defaults is 200 committed graphs of under 12 nodes each, and raising both budgets makes it 24 and buys 17% of the token.There is no global default to be had. Same binary, idle host, n = 3, single-stream decode: Laguna +17%, qwen3-30b-a3b +21%, qwen3.5-35b-a3b +22%, Qwen 3.5 4B +4%, gemma-4-26b-a4b flat, gpt-oss-20b -7%, Llama 3.1 8B -9%, several with disjoint ranges, and no config-level shape rule separates the winners from the losers. So this ships a
model_typeallowlist gated on cc 12.1, the shape #353 used for the Metal knob, with per-variable operator override. The list is["laguna"], the one family positive on every workload measured.What changed
mlxcel-coremodulecuda_graph_budget: a pure policy over the compute capability plus the checkpoint'sconfig.json, and an applier that setsMLX_MAX_OPS_PER_BUFFER/MLX_MAX_MB_PER_BUFFERbefore any MLX op runs, leaving alone any variable the operator already set. Re-exported throughhardwarebeside its graph-cache and SDPA-cache siblings.docs/environment-variables.mdrows for both variables, and the full record underdocs/benchmark_results/with raw per-run JSONL, nsys output and the harness.-mpath it was given, so the default reachesmlxcel generate,run,serve,embed,rerank,tune,mlxcel-serverand the two bench binaries. A repo id not yet on disk, router mode and a command with no model apply nothing.mlxcel generateprints the applied budget beside its compute-capability line;mlxcel-serverlogs it at info, since it moves both throughput and peak memory.Measurement
Seven checkpoints, five workloads, environment variables as the only difference between arms, GPU held under a lock, host idleness gated per run and recorded per row,
MLX_ENABLE_TF32=0.The default actually lands. Every table was taken with the policy compiled but uncalled, so a separate A/B measures the wired binary on three arms: no environment, an operator-restored 20/25, an explicit 100/1000. Through
mlxcel-bench-decodethe no-environment arm is 37.42 tok/s (37.22 to 37.71) and the explicit arm 37.50 (37.24 to 37.64), overlapping throughout, against a restored 31.76 (31.09 to 32.31), disjoint, +17.8%; MLX peak memory separates the same way with no timing involved (22.03 GB against 21.66 GB). Throughmlxcel generate34.13 against 29.29, throughmlxcel-server29.03 against 27.70, disjoint in both. A dense checkpoint outside the allowlist has all three arms overlapping on MLX's own numbers, so the gate is the allowlist and not the device.The two Qwen MoE families were measured and do not qualify. They gained +21% and +22% on single-stream decode, which is why they were candidates. On the serving path at n = 3, qwen3_moe gains at concurrency 1 and does nothing at 4 or 8; qwen3_5_moe is flat at 1 and 4 and loses 10.7% at concurrency 8 with disjoint ranges. Long prefill agrees: both are slower (+14.4%, +8.0%) at +16.3 GB and +8.2 GB of peak memory. Neither is listed, and the numbers and the reason are in the record.
Cost and blast radius
The default fires only on cc 12.1 and only for an allowlisted family, so the families measured worse (gpt-oss -7%, Llama -9%) cannot be regressed by it, and every other capability keeps MLX's table value by construction. Laguna's cost is +0.4 GB at a short prompt and +7 GB per 2048-token prefill chunk on a 128 GB unified-memory machine, and its graph instantiation is 0.34 ms per token against a 5.6 ms per token gain. Measured families: Laguna, qwen3-30b-a3b, qwen3.5-35b-a3b, Qwen 3.5 4B, Llama 3.1 8B, gpt-oss-20b, gemma-4-26b-a4b. Unmeasured families share only the code path and are unchanged.
Test plan
cargo fmt --all -- --checkcargo test -p mlxcel-core --release --features cuda --lib cuda_graph_budget(the policy, both gates, the env-wins contract and the config parsing, all without a device)metal,accelerategate (make verify-test) was not run: this is a Linux CUDA host with neither backendCloses #1798