Skip to content

docs(benchmarks): record GB10/CUDA fused QK-norm decode result (#326) - #357

Merged
inureyes merged 1 commit into
mainfrom
docs/326-cuda-fused-qk-norm-benchmark
Jun 19, 2026
Merged

inureyes merged 1 commit into
mainfrom
docs/326-cuda-fused-qk-norm-benchmark

Conversation

@inureyes

Copy link
Copy Markdown
Member

Summary

Completes the deferred validation for #326 (generic fused QKV+RMSNorm+RoPE, merged in #341) by running the decode benchmark on the one backend it was never measured on: GB10 / CUDA.

The fused QK-norm decode primitive ships default-OFF. Its doc comment said it was gated off "pending a per-backend win (e.g. CUDA, where op-dispatch/FFI cost differs)". This PR answers that open question.

Result: CUDA is not a per-backend win

Same binary, MLXCEL_FUSED_QK_NORM=1 (fused) vs =0 (graph/split), best-of-3, GB10 SM 12.1, --no-chat-template + 256 tokens so decode rate resolves the small per-op effect.

Model Role fused ON graph OFF fused/graph
qwen3-0.6b-4bit wired dense 372.8 387.2 0.96x
qwen3-8b-4bit wired dense 52.6 52.4 1.00x
qwen3-30b-a3b-4bit wired MoE 83.8 90.7 0.92x
apertus-8b-2509-4bit not wired 43.0 43.2 flag inert
llama-3.1-8b-4bit regression guard 48.0 48.2 flag inert

Slower on every wired model, worst on the 48-layer MoE. The primitive assembles the same MLX ops as the graph path in one C++ call, so the GPU work is identical; it only cuts FFI crossings and norms after the head transpose. Decode is GPU/bandwidth-bound, so that buys nothing and the reorder costs a little. Same direction as M1 Ultra (1-3.4% slower) and consistent with M5 Max preferring the split path.

The two control models (apertus is QK-norm but not wired; llama has no QK-norm) show the flag is inert: the regression-guard check that common attention is untouched.

Correctness / determinism

  • RMS < 5e-3 vs graph reference: covered by the existing fused_qkv_split_norm_rope_standard_rmsnorm_matches_graph unit test.
  • Greedy temp-0 over 256 tok: qwen3-8b byte-identical; qwen3-0.6b/30b diverge at a near-tie argmax into coherent equal-quality text. Not a fused-path regression: on CUDA the graph path is itself non-deterministic run-to-run, while the fused path is deterministic, so its divergence stays inside the graph baseline's own envelope.

Changes

  • New docs/benchmark_results/fused-qk-norm-decode-gb10.md (method, table, determinism analysis).
  • Correct the fused_qk_norm_enabled doc comment: drop the stale "byte-identical" claim and the "pending a per-backend win (e.g. CUDA)" note, record the CUDA numbers.

No code behavior change. The flag stays default-OFF; the graph/split path remains the decode default on every measured backend (M1 Ultra, M5 Max, GB10/CUDA).

Answer the open per-backend question left when the fused QKV+QK-norm+RoPE
decode primitive (#326, #341) merged default-OFF: whether CUDA, with its
different op-dispatch cost, is the per-backend win that would justify enabling
it. On GB10 (SM 12.1) it is not. The fused path is slower on every wired model
(qwen3-0.6b 0.96x, qwen3-8b ~1.0x, qwen3-30b-a3b 0.92x fused/graph), worst on
the 48-layer MoE where the per-layer norm/transpose reorder accumulates.

The primitive assembles the same MLX ops as the graph path in one C++ call, so
the GPU work is identical; it only cuts FFI crossings (about 14 to 1) and norms
after the head transpose. Decode is GPU/bandwidth-bound, so collapsing FFI calls
buys nothing and the reorder costs a little. Same direction as M1 Ultra
(1-3.4% slower) and consistent with M5 Max preferring the split decode path.

Correctness holds: RMS < 5e-3 (unit test); greedy temp-0 diverges only at a
near-tie argmax over long generation, and the graph path is itself
non-deterministic run-to-run on CUDA while the fused path is deterministic, so
the divergence stays inside the graph baseline's own envelope. Corrects the
stale "byte-identical" claim and the "pending a per-backend win (e.g. CUDA)"
note in the fused_qk_norm_enabled doc comment.

Add docs/benchmark_results/fused-qk-norm-decode-gb10.md with the full method,
on/off table, and determinism analysis. No code behavior change; the flag stays
default-OFF.
@inureyes inureyes added area:benchmark Benchmark harness and performance measurement (bench_*.sh, /update-benchmarks) area:core mlxcel-core: MLX FFI, primitives, KV cache, layers area:models Model architectures, weights, loading, metadata type:docs Documentation improvements or additions labels Jun 18, 2026
@inureyes
inureyes merged commit de6dace into main Jun 19, 2026
4 checks passed
@inureyes inureyes self-assigned this Jun 19, 2026
inureyes added a commit that referenced this pull request Jun 19, 2026
… (#372)

A default `cargo build --release` on Linux omits the `cuda` feature and produces a CPU-only binary that still runs but executes MLX on the host CPU at single-digit tok/s, with only `Runtime device: CPU` as a hint. This bit a GB10 benchmarking session for #326.

At startup, when the user wanted the GPU but a CPU-only binary fell back to CPU on a host that has an NVIDIA GPU (detected via `/dev/nvidiactl` or `/proc/driver/nvidia/version`, which need no CUDA linkage), print a one-line warning pointing at the `--features cuda` rebuild or the new `cargo cuda` alias. An explicit `MLXCEL_DEVICE=cpu` suppresses it, and a cuda-capable build that fell back to CPU is a genuine no-GPU host, not the footgun. The decision is a pure function with a unit test.

Also adds the `cargo cuda` alias in `.cargo/config.toml` and documents the footgun in the README build section and installation.md. No behavior change on a correctly built GPU binary. Follow-up to #326 and #357.
@inureyes inureyes added this to the 0.3 milestone Jun 21, 2026
inureyes added a commit that referenced this pull request Jun 25, 2026
CUDA (GB10/SM 12.1) was the last open backend question after the M1 Ultra regression (#326, #341). The GB10 benchmark (#357) found the fused path is also slower there (qwen3-0.6b 0.96x, qwen3-8b ~1.0x, qwen3-30b-a3b 0.92x fused/graph), so there is no per-backend win on any measured backend (M1 Ultra, M5 Max, GB10/CUDA). The default stays off on all backends; no code changes.

Two stale claims in the MLXCEL_FUSED_QK_NORM table row in docs/environment-variables.md are corrected:

1. The byte-identical overclaim is replaced with the canonical precision from the layers.rs doc comment: the fused path matches within RMS < 5e-3, but greedy temp-0 is not byte-identical over long generation. The determinism note is added: on CUDA the graph path is non-deterministic run-to-run from GPU FP-reduction order, while the fused path is deterministic, so its divergence from the graph stays inside the graph baseline's own envelope.

2. The CUDA-pending rationale is replaced with the settled verdict: GB10/CUDA was measured and is also slower, so the flag stays opt-in on every measured backend.

CHANGELOG.md gets a Docs entry under [Unreleased] recording the decision finalization.
@inureyes inureyes added the status:done Completed label Sep 6, 2026
be-free-snowboy pushed a commit to freestylejs/snowbrain-mlxcel that referenced this pull request Oct 27, 2026
…p#326) (lablup#357)

Answer the open per-backend question left when the fused QKV+QK-norm+RoPE
decode primitive (lablup#326, lablup#341) merged default-OFF: whether CUDA, with its
different op-dispatch cost, is the per-backend win that would justify enabling
it. On GB10 (SM 12.1) it is not. The fused path is slower on every wired model
(qwen3-0.6b 0.96x, qwen3-8b ~1.0x, qwen3-30b-a3b 0.92x fused/graph), worst on
the 48-layer MoE where the per-layer norm/transpose reorder accumulates.

The primitive assembles the same MLX ops as the graph path in one C++ call, so
the GPU work is identical; it only cuts FFI crossings (about 14 to 1) and norms
after the head transpose. Decode is GPU/bandwidth-bound, so collapsing FFI calls
buys nothing and the reorder costs a little. Same direction as M1 Ultra
(1-3.4% slower) and consistent with M5 Max preferring the split decode path.

Correctness holds: RMS < 5e-3 (unit test); greedy temp-0 diverges only at a
near-tie argmax over long generation, and the graph path is itself
non-deterministic run-to-run on CUDA while the fused path is deterministic, so
the divergence stays inside the graph baseline's own envelope. Corrects the
stale "byte-identical" claim and the "pending a per-backend win (e.g. CUDA)"
note in the fused_qk_norm_enabled doc comment.

Add docs/benchmark_results/fused-qk-norm-decode-gb10.md with the full method,
on/off table, and determinism analysis. No code behavior change; the flag stays
default-OFF.
be-free-snowboy pushed a commit to freestylejs/snowbrain-mlxcel that referenced this pull request Oct 27, 2026
…lup#326) (lablup#372)

A default `cargo build --release` on Linux omits the `cuda` feature and produces a CPU-only binary that still runs but executes MLX on the host CPU at single-digit tok/s, with only `Runtime device: CPU` as a hint. This bit a GB10 benchmarking session for lablup#326.

At startup, when the user wanted the GPU but a CPU-only binary fell back to CPU on a host that has an NVIDIA GPU (detected via `/dev/nvidiactl` or `/proc/driver/nvidia/version`, which need no CUDA linkage), print a one-line warning pointing at the `--features cuda` rebuild or the new `cargo cuda` alias. An explicit `MLXCEL_DEVICE=cpu` suppresses it, and a cuda-capable build that fell back to CPU is a genuine no-GPU host, not the footgun. The decision is a pure function with a unit test.

Also adds the `cargo cuda` alias in `.cargo/config.toml` and documents the footgun in the README build section and installation.md. No behavior change on a correctly built GPU binary. Follow-up to lablup#326 and lablup#357.
be-free-snowboy pushed a commit to freestylejs/snowbrain-mlxcel that referenced this pull request Oct 27, 2026
…lablup#444)

CUDA (GB10/SM 12.1) was the last open backend question after the M1 Ultra regression (lablup#326, lablup#341). The GB10 benchmark (lablup#357) found the fused path is also slower there (qwen3-0.6b 0.96x, qwen3-8b ~1.0x, qwen3-30b-a3b 0.92x fused/graph), so there is no per-backend win on any measured backend (M1 Ultra, M5 Max, GB10/CUDA). The default stays off on all backends; no code changes.

Two stale claims in the MLXCEL_FUSED_QK_NORM table row in docs/environment-variables.md are corrected:

1. The byte-identical overclaim is replaced with the canonical precision from the layers.rs doc comment: the fused path matches within RMS < 5e-3, but greedy temp-0 is not byte-identical over long generation. The determinism note is added: on CUDA the graph path is non-deterministic run-to-run from GPU FP-reduction order, while the fused path is deterministic, so its divergence from the graph stays inside the graph baseline's own envelope.

2. The CUDA-pending rationale is replaced with the settled verdict: GB10/CUDA was measured and is also slower, so the flag stays opt-in on every measured backend.

CHANGELOG.md gets a Docs entry under [Unreleased] recording the decision finalization.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:benchmark Benchmark harness and performance measurement (bench_*.sh, /update-benchmarks) area:core mlxcel-core: MLX FFI, primitives, KV cache, layers area:models Model architectures, weights, loading, metadata status:done Completed type:docs Documentation improvements or additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant