Skip to content

test(bench): benchmark cuda-oxide RMSNorm on GB10 and record the result - #3477

Merged
inureyes merged 13 commits into
mainfrom
feature/issue-2834-cuda-oxide-benchmark
Nov 28, 2026
Merged

inureyes merged 13 commits into
mainfrom
feature/issue-2834-cuda-oxide-benchmark

Conversation

@inureyes

@inureyes inureyes commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Summary

Benchmarks the cuda-oxide fused residual-add + RMSNorm kernel (#2832 artifact, #2833 adapter) against the existing fused CUDA kernel on GB10 under a protocol frozen before measurement, and records the result. Recommendation: stop, do not expand cuda-oxide kernels on this evidence. Maintainer decision: stop is adopted for the default, and the #2833 adapter stays in the tree as an opt-in route (not removed), for a possible later rewrite of the kernels on cuda-oxide. No default changes and nothing joins the default build.

  • Correctness passes on llama-3.2-1b-instruct-bf16: logit traces byte-identical to the existing kernel in three shapes, greedy output identical in 6 cells over 7 rounds, all 168 runs on the intended route, 130 of 130 at the op boundary.
  • End to end there is no regression and no gain: paired deltas of -0.31 % to +1.65 % against null floors of 0.3 to 2.1 %. One cell (TTFT, B=4, 2048-token prompt) cannot resolve 2 %.
  • The kernels take the same time through MLX (within 3 % on four of five shapes, 0.38 µs apart on the fifth). The port has the existing kernel's structure, as bit identity required, so only code generation could differ.
  • First use is slower with warm caches (11.8 ms against 5.25 ms) and faster only on a machine's first run (88 ms against about 0.7 s per width).
  • The route adds a compiler toolchain and an artifact contract and removes nothing.

Order, for the audit: protocol 93182387, harness 0a5968fa, first raw results 37ac8922; four additions to the protocol were each committed before they ran (bc1e47ff, 70fa4f9a). A fifth adjustment, added in review, records that M1 ran both prompt lengths in one process per path, batch and arm rather than one process per cell; that choice was committed in the harness (0a5968fa) before any stage ran and applies to every arm equally.

What changed

  • docs/mlxcelverse/cuda-oxide-benchmark-evidence.md: protocol, results, what could not be measured, gate evaluation, recorded result. The feasibility review, the result index, the environment-variable page and the changelog point to it.
  • docs/benchmark_results/cuda-oxide-fused-norm-gb10-2026-11-27/: raw rows, run.sh with every command, provenance, per-stage host state.
  • Harness: a driver-API standalone launcher (spike/cuda-oxide-fused-norm/standalone), the mlxcel-core example oxide_fused_norm_bench, the root example oxide_fused_norm_checkpoint_bench, scripts/oxide_fused_norm_rounds.py, scripts/nsys_kernel_table.py, and mlxcel_core::fused_norm_route::fused_norm_route_snapshot() (None without the adapter), which logit_trace prints in an opted-in build.

Changes during review

  • Recorded the maintainer decision (keep the route opt-in, do not remove it) in the evidence report, the feasibility review and the changelog.

  • scripts/oxide_fused_norm_rounds.py summarize no longer reports "no regression" for a cell with missing or non-finite pairs (NaN compared false against every threshold), and no longer crashes when an arm has no rows for a cell; both now read "unresolved". Covered by tests/test_oxide_fused_norm_rounds.py. Re-summarizing the committed M1 rows reproduces the committed summary, so no reported verdict changed.

  • The G1 matrix result is now committed as m2c-adapter-matrix.csv (rerun at 5939da7f under gpu-lock through a new m2c stage in run.sh, reduced from the test binary's capture by scripts/oxide_fused_norm_m2c_summarize.py; the results tree keeps no raw logs).

  • Report corrections against the raw data: graph-path kernel column as the median of three captures, the 11.2 ms first-use cost described as validation plus device query plus install (not broken down), the 4.1 µs event floor explained as the back-to-back launch rate, decode traffic 24/96 KiB, and narrower wording where a claim went past what was measured. No gate, threshold, baseline, conclusion or recommendation changed.

  • run.sh and the standalone launcher hardened: staged writes for provenance and cold-start CSVs, refusal of a work directory inside the checkout, strict numeric argument parsing, and the digest check documented as consistency with the in-tree manifests rather than authenticity.

Not measured

Hardware counters (ncu is refused for this user), a CPU profile of the host path (perf_event_paranoid is 4), per-kernel time with CUDA graphs on, a second checkpoint, and an idle host: the host is a CI runner and was shared, and the runner's job logs show one stage partly overlapped by a job (it was repeated, both sets are reported).

Test plan

  • run.sh stages m1 to m9 on GB10 under gpu-lock, results committed
  • cuda_oxide suite in the release profile, --test-threads=1: 31 passed, including the 130-case matrix (recorded in m2c-adapter-matrix.csv)
  • tests/test_oxide_fused_norm_rounds.py (summarizer on complete and incomplete input); shellcheck on run.sh and standalone-bench.sh; g++ -Wall -Wextra on the standalone launcher
  • fused_norm_route unit tests: 2 passed
  • rustfmt --check on the new Rust files; check_used_by, check_env_var_docs, check_binary_assets, check_benchmark_raw_logs, check_windows_reserved_paths, check_native_env_writes
  • cargo clippy --release --features cuda -- -D warnings on mlxcel-core --lib --example oxide_fused_norm_bench and on the two root examples, with the opt-in build variable, after the measurements (it cold-builds MLX under its own build-script hash, so it could not run alongside them)

Closes #2834

Issue #2834 requires the checkpoint, prompts, tolerances, timing method, repetitions and acceptance thresholds to be fixed before any result is collected. This commit holds the protocol alone so the order is auditable: arms and their route-counter signatures, the artifact and checkpoint digests, the prompts, the seven measurements (end to end with a null arm, logit traces, standalone and through-MLX kernel time under one profiler, op level, cold start, static resources), the three gates with their baselines and noise-floor rule, and the rule that maps the outcome to one disposition.

Only functional checks of the instruments ran before it, listed in the document; no timing from them is recorded or used. Results follow in later commits.

Refs #2834
The #2834 protocol needs four things the tree did not have. None of them joins the default build or changes what a default-build binary does.

- A standalone launch benchmark that needs only the CUDA driver API (`spike/cuda-oxide-fused-norm/standalone`, `scripts/standalone-bench.sh`): the #2832 harness needs the cuda-oxide compiler, which this host does not have. It checks the committed PTX against the five manifests, loads it with `cuModuleLoadData`, launches with the manifest ABI and launch rule, and times with CUDA events.
- `mlxcel-core` example `oxide_fused_norm_bench`: graph path, existing fused kernel and cuda-oxide node through MLX on the same shapes, in `iso`, `pipe` and `cold` modes, each block checked against the route counters.
- `mlxcel_core::fused_norm_route::fused_norm_route_snapshot()`: the adapter's counters behind a cfg-independent reader (`None` without the adapter), because the cfg is set by the core crate's build script and the root crate cannot test it. `logit_trace` prints the route with it in an opted-in build.
- Root example `oxide_fused_norm_checkpoint_bench` and `scripts/oxide_fused_norm_rounds.py`: the engine probes `mlxcel-bench-engine` runs, plus per-arm environment, route counters and MLX peak memory per pass, token ids, concurrent requests, rotated rounds with a null arm and the frozen gate rule. `scripts/nsys_kernel_table.py` turns an Nsight Systems capture into per-kernel and per-API tables.

Only functional probes have run. rustfmt is clean; clippy was not run because it starts a cold MLX build under its own build-script hash on this host.

Refs #2834
The first attempt at the measurement batch never started: main-branch CI jobs occupied this host's runner back to back for more than the 30 minutes the script waits, and its 10-second poll missed the gaps between jobs. The wait is now configurable (`RUNNER_WAIT`) and polls every 2 seconds, and each stage appends its start and end time, the load average and whether a CI job was running at its end to `host-state.csv`, since a job can start in the middle of a stage. No timing had been taken; the only protocol item run so far is the adapter test suite with the 130-case matrix (M2c), which is not time sensitive.

Refs #2834
docs/benchmarks.md gains a section on the three tools the #2834 comparison added: the route snapshot and the checkpoint bench that records it per pass, the rounds driver for arms that differ by process environment, and the pairing of the through-MLX op bench with the standalone driver-API launcher under one profiler, including why the MLX capture needs CUDA graphs off and what must not be read from it.

Refs #2834
First results of the protocol frozen in 9318238, taken on spark-101 at b45ce7a with the opted-in release build: standalone CUDA-event timings (M3), kernel and CUDA API tables from nsys for the standalone program and for MLX with graphs off (M4), op-level timings through MLX with graphs on (M5), cold start (M6), kernel resource usage (M7), seven interleaved end-to-end rounds with a null arm (M1), and the logit trace comparison (M2), with the environment in provenance.json and the per-stage host state in host-state.csv.

The host was shared: a CI job was running when M4 and M5 ended, which host-state.csv records. Those two stages are repeated in a later commit; this set is kept as taken. The m7 CSV's constant-bank column is empty because of a parser mistake fixed with the repeat.

Refs #2834
…g them

The first result set raised three things the frozen protocol did not cover. No gate, threshold, baseline or repetition count changes; the additions are dated and committed here before any of them runs.

- The standalone module load took under a millisecond because the CUDA driver's own PTX compile cache was warm, so the cold-start state for the cuda-oxide arm measured a cache hit. Cold start and the standalone program are also run with CUDA_CACHE_DISABLE=1.
- A CI job was running when the nsys and op-level stages ended, so both are repeated into separate files and both sets are kept.
- The op-level pipe mode shows a host-side per-op difference that the shared-process API table cannot attribute, so an exploratory per-arm API profile is added.

The run script gains the matching stages, a repeat-set suffix, the corrected constant-bank parser for the resource table, and LF line endings in the CSV writers.

Refs #2834
Results of the three additions recorded in bc1e47f: the repeated nsys and op-level stages (`*-repeat.csv`), cold start and the standalone program with the driver's PTX compile cache disabled (`m6b-*`), the resource table with its constant-bank column filled, and the per-arm CUDA API counts (`m8`).

The per-arm profile shows the same CUDA API calls per op for the existing kernel and the cuda-oxide node, so the per-op difference in pipe mode is host work before the launch. A fourth addition, recorded in the evidence document here before it runs, times that directly: a `build` mode in the op bench that constructs the lazy node without evaluating it.

The CI-job check matched a monitoring shell by command line and recorded one false positive, noted in the document; the scripts now match the process name.

Refs #2834
The evidence document now holds the results under the frozen protocol, the gate evaluation and the recorded result. On GB10 with Llama 3.2 1B Instruct bf16 the cuda-oxide route is correct (logit traces byte-identical to the existing fused kernel in three shapes, greedy output identical in six cells over seven rounds, every run on the intended route) and has no end-to-end effect (paired deltas of -0.31 % to +1.65 % against null floors of 0.3 to 2.1 %, one cell unable to resolve 2 %).

No benefit passes a gate. The two kernels take the same time, within 3 % on four of five shapes, because the operator is launch-bound at decode and memory-bound at prefill. First use is slower with warm caches (11.8 ms against 5.25 ms) and faster only on a machine's first run. The route adds a compiler toolchain and an artifact contract and removes nothing. The recommendation is to stop expanding cuda-oxide kernels; the maintainer makes the call, and no default changes.

Also recorded: the per-op gap between the generic custom-kernel launcher and a dedicated primitive (node-build timings in m9), what could not be measured (hardware counters, a CPU profile, an idle host), and the pointers in the feasibility review, the result index, the environment-variable page and the changelog.

Refs #2834
…e op bench

Two statements in the report went beyond the data. The kernels do not tie because the operator is memory-bound at prefill: at 128 and 512 rows the graph path's two kernels do the same arithmetic in 55 % and 35 % of either fused kernel's time. They tie because the port has the existing kernel's structure and geometry, which bit identity required, so only code generation could differ. The report now says that, and states as a limit that no restructured kernel was measured. The recommendation is unchanged.

The host-state account now follows the runner's job logs instead of the per-stage flag: jobs ran back to back from 02:51:40 to 03:48:54 UTC and once more from 03:53:12 to 03:54:40, so only the end of the first op-level set overlapped a job, and the flag at the end of the first nsys stage was a false positive of the command-line match like the later one.

`oxide_fused_norm_bench.rs` was past 500 lines; its argument parsing and its recorder move to `oxide_fused_norm_bench/{args,record}.rs` with no change in behavior (a routes-only pass was rerun; every committed number predates the split). Narrow clippy with `-D warnings` is clean on the core lib, that example and the two root examples.

Refs #2834
@inureyes inureyes added status:review Under review type:test Test related changes priority:medium Medium priority area:benchmark Benchmark harness and performance measurement (bench_*.sh, /update-benchmarks) platform:linux Linux (CUDA / packaging) specific labels Nov 27, 2026
…izer

A cell missing the fused-null arm, or with fewer oxide pairs than rounds, gave a NaN null floor or median, and every NaN comparison is false, so `summarize` printed `no regression` for any slowdown. Removing the null arm from the committed M1 data and doubling oxide TTFT reproduced it. Cells now need one finite oxide and one finite null pair for every round in the cell before a verdict; otherwise they read `unresolved (incomplete or non-finite pairs)`.

Validated without a GPU: the summary of the committed `m1-end-to-end.csv` is unchanged, and the same file with the null arm removed reports all 12 cell-metrics as unresolved.

Refs #2834
@inureyes

Copy link
Copy Markdown
Member Author

Implementation Review Summary

Intent

Benchmark the cuda-oxide fused residual-add + RMSNorm on GB10 against the existing fused kernel under a frozen protocol, and record one disposition (#2834).

Findings Addressed

  • oxide_fused_norm_rounds.py summarize printed no regression for a cell with a missing null arm or missing oxide pairs (NaN floor compares false). Incomplete or non-finite cells now read unresolved; the committed M1 summary is unchanged (5939da7) (HIGH)

Remaining Items

  • M2(c) 130-case matrix result and "31 passed" are quoted in the report, but no raw log is committed and run.sh has no stage for it (MEDIUM), needs the existing log or a rerun by the maintainer
  • Kernel table, graph-path column: 512 rows rms_norm_small reads 3.81 (rep1 only) against a median of three of 4.03 / 4.10; 2048 rows binary_vv reads 113 against 114.05 / 116.74; derived 8.3 and 143 us become about 8.5 and 144 (MEDIUM), conclusions unchanged
  • The 11.2 ms first-use cost of oxide is attributed to artifact validation, but select_us also covers the device capability query and the C++ install; it was not broken down (MEDIUM)
  • M1 runs both prompt lengths in one process per path, batch and arm, while the frozen M1 text describes six cells each as fresh processes; the deviation is the same for every arm but is not listed under Protocol adjustments (MEDIUM)
  • "the event timer resolves about 2 us" does not explain the 4.1 us floor: the per-launch synchronized samples resolve below 1 us, and the warm figures are multiples of 2.048 us per launch, which points at a back-to-back launch rate (MEDIUM)
  • Smaller wording items (LOW): decode traffic 20 / 82 KiB omits the per-row weight read (the CSV formula gives 24 / 96 KiB); "graph is cheaper per op in pipe mode" is false at 2048 rows (168.8 against 161.3 us); the fused empty-cache control moved from 698 to 757 ms under CUDA_CACHE_DISABLE=1 without comment; run.sh provenance still uses pgrep -f; missing comma after (#2832) in docs/README.md; "applies to every fast::cuda_kernel launcher" and "cost-free end to end" go beyond the data; cold-start subtraction uses the bimodal iso steady median (about 0.9 ms of noise); the logit_trace binary digest is not in provenance.json

Verification

  • All stated requirements implemented
  • No placeholder/mock code remaining
  • Integrated into project code flow
  • Project conventions followed
  • Existing modules reused where applicable
  • No unintended structural changes
  • Tests pass (CI green except the known OpenXLA feature compile; no GPU test was rerun in this review)

Checked: the protocol commit 9318238 was pushed at 11:55 KST, before the first stage started (03:37 UTC); gates, thresholds, baselines and repetition counts are identical between 9318238 and HEAD, and each addition was pushed before its stage ran. Recomputed from the CSVs: the M1 summary, 168 of 168 and 4,365 of 4,365 valid route signatures, identical greedy ids, peak memory, M3, M4 (both sets), M5 pipe, M6, M6b, M8 and M9 tables match the report apart from the items above. The standalone harness checks the PTX digest against all five manifests before loading and uses the schema's 13-argument ABI and the manifest launch rule. Narrow cargo check of the three examples in the opted-in build is clean; default builds gain only a reader that returns None.

@inureyes

Copy link
Copy Markdown
Member Author

Security and Performance Review

No CRITICAL or HIGH findings, so no fixes were committed. The scope was the standalone bench (C++ and wrapper), fused_norm_route.rs, the Rust examples, both Python scripts, and run.sh.

Verified

  • Default builds: fused_norm_route_snapshot() returns None and is called only from examples and logit_trace's end-of-run print. It never reaches the library's forward path. The bridge symbols the examples import carry no cfg gates. cargo check --release -p mlxcel-core --features cuda --example oxide_fused_norm_bench with the adapter build is clean. A g++ -Wall -Wextra build of the standalone bench is clean, and shellcheck passes on both scripts.
  • Standalone bench: the wrapper checks the digest before the program loads the PTX. rows*dim is widened to size_t before the multiply and capped at 2^32-1. Every buffer is n or dim elements, which matches grid rows with one row per block. Every driver call is checked.
  • Process handling: nothing kills a process, every pgrep only observes, and waits are bounded. The Python timeout reaches the bench itself because gpu-lock execs its command. Nothing deletes files.

Remaining (not fixed)

  • MEDIUM: oxide_fused_norm_rounds.py summarize raises ValueError in the peak-memory table (min(peaks)) when an arm has no rows for a cell, before --out is written. Reproduced by dropping one arm from one cell of the committed M1 CSV.
  • LOW: run.sh runs chmod 700 on any pre-existing WORK without checking that it is outside the checkout. $WORK is word-split through --wrap. A failed m6/m6b leaves intermediate CSVs that the next run appends to. stage_env uses pgrep -f, unlike the rest of the script.
  • LOW: M2's run_trace does not unset MLXCEL_CUDA_OXIDE_FUSED_NORM_DIR, which the M1 driver strips. An inherited value would load a different artifact for the traces.
  • LOW: the standalone bench's static_cast<unsigned>(std::stoul(...)) silently truncates and accepts -1, and stoi/stoul exceptions are uncaught. The digest check pins the PTX to the manifests in the same tree, so it checks consistency, not authenticity.

Review and security passes on the cuda-oxide fused-norm benchmark left MEDIUM and LOW items. No measurement was rerun, and no gate, threshold, baseline, conclusion or disposition changed.

Evidence docs: the report now cites a committed log for the 130-case matrix through the adapter (new run.sh stage m2c, a correctness rerun of the 31 cuda_oxide tests, 31 passed, saved as m2c-adapter-matrix-test.log). The graph-path column uses the median of three captures (8.5 and 144 us derived). The 11.2 ms first-use cost is described as the whole select step, not broken down. The M1 one-process-per-arm-and-cell deviation is listed under the protocol adjustments with its commit time. The 4.1 us floor is attributed to a back-to-back launch rate of 2.048 us multiples, not timer resolution. Smaller wording fixes: decode traffic 24/96 KiB, the pipe-mode graph claim narrowed, the 698 to 757 ms control and the cold-start subtraction noise noted, over-broad launcher and cost-free claims narrowed, 0.023 points, the missing comma in docs/README.md. The logit_trace digest is recorded as recomputed after capture.

Scripts: summarize reports a cell with no rows for an arm as unresolved and still writes --out (unit test added; the committed M1 summary reproduces up to line endings). run.sh uses pgrep -x, writes provenance.json atomically, refuses a WORK path with whitespace or inside the checkout, stages m6 and m6b output so a failed run leaves nothing to append to, fails loudly on a missing M2 route line or an empty m7 glob, and unsets MLXCEL_CUDA_OXIDE_FUSED_NORM_DIR for the traces. The standalone bench rejects negative, non-numeric and out-of-range arguments, and keeps the row newline for a long --label. The digest check is documented as consistency with the in-tree manifests, not authenticity.

Validation:
- gpu-lock run -- mlxcel_core lib test binary cuda_oxide --test-threads=1: 31 passed
- python3 -m unittest tests/test_oxide_fused_norm_rounds.py: 2 passed
- shellcheck on both scripts, g++ -Wall -Wextra on the bench: clean
- cargo fmt --all -- --check: clean; no Rust source changed

Refs #2834
@inureyes inureyes added status:done Completed and removed status:review Under review labels Nov 27, 2026
The results tree keeps no raw captures (check_benchmark_raw_logs.py), so the m2c test-binary output committed in review failed the binary-assets job. The capture now stays in the run work directory and scripts/oxide_fused_norm_m2c_summarize.py reduces it to m2c-adapter-matrix.csv: command, commit, binary SHA-256, each test outcome, every field of the 130-case RESULT line and the libtest totals. The CSV was derived from the same capture, so the cited result is unchanged.

Refs #2834
The maintainer adopted the stop recommendation for the default and kept the #2833 adapter in the tree as an opt-in route, off by default at build and run time, for a possible later rewrite of the kernels on cuda-oxide. The evidence report, the feasibility review and the changelog now state the decision instead of leaving it open.
@inureyes
inureyes merged commit da347a2 into main Nov 28, 2026
32 of 33 checks passed
@inureyes
inureyes deleted the feature/issue-2834-cuda-oxide-benchmark branch November 30, 2026 14:01
@inureyes inureyes added this to the 0.9 milestone Nov 30, 2026
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) platform:linux Linux (CUDA / packaging) specific priority:medium Medium priority status:done Completed type:test Test related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Benchmark cuda-oxide RMSNorm and record the adoption decision

1 participant