Skip to content

update(xla): add a paired A/B harness for two IREE builds - #3050

Merged
inureyes merged 1 commit into
mainfrom
update/xla-ab-decode-pair-script
Nov 14, 2026
Merged

inureyes merged 1 commit into
mainfrom
update/xla-ab-decode-pair-script

Conversation

@inureyes

Copy link
Copy Markdown
Member

Summary

Adds scripts/xla/ab_decode_pair.sh, the paired A/B harness the decode measurements of #3028, #3042 and #3043 were taken with, so the comparison can be reproduced on another host with one command instead of hand-written shell. docs/benchmarks.md gains the invocation under "Suggested benchmark commands".

A single before/after run of mlxcel generate --profile moves 5 to 10 percent between runs on a thermally loaded host, so an apparent win can be drift. The script builds or takes both arms, runs them interleaved, reports both medians and how many paired rounds the new arm won, and then requires the greedy text to match. Equality is not reimplemented: the text half is delegated to the existing scripts/ab_output_equality.sh.

Three cases are refused rather than measured, because each of them has produced a wrong number before:

  • Identical arms. A cargo build that no-ops leaves both arms the same bytes and every round "passes". Refused unless --allow-identical.
  • A zero prefill window. That means the decode rate covers the whole run, the accounting bug fixed in fix(cli): report XLA prefill and decode separately (#3041) #3042, so the two arms would be compared on different quantities. Refused unless --allow-whole-run-accounting.
  • Cold compilation. The first run of a fresh context compiles the graphs and creates the vmfb cache, so each arm is warmed up before measuring.

Usage

# The baseline is a git ref (built in a temporary worktree); the new arm
# defaults to the working tree.
scripts/xla/ab_decode_pair.sh --model models/llama-3.2-1b-instruct-4bit \
    --device hip --old origin/main --tokens 128 --rounds 6

--old and --new also take a path to an already-built binary (anything containing a slash). --device accepts hip, cuda, metal and local-task. On CUDA the script wraps every run in gpu-lock run --tag xla-ab --; on HIP it uses scripts/rocm_gpu_guard.sh --hold --; both can be overridden with --lock. When MLXCEL_XLA_IREE_COMPILE is unset, the script applies the scripts/iree/setup-*.sh --env matching --device, so a fresh shell needs no manual setup.

MLXCEL_XLA_QUANT=native is HIP-only, and the help text says so, because a CUDA run with the flag silently uses the f16 path and its figures are not comparable with HIP native-4bit figures.

Validation

  • HIP host (gfx1151, AMD RYZEN AI MAX+ 395, llama-3.2-1b-instruct-4bit): end-to-end run with MLXCEL_XLA_IREE_COMPILE unset exited 0. It applied the ROCm setup env, printed the per-round table, both medians and the round-win count, then the delegated gate reported text EQUAL. The rates from that run are not reportable: the baseline binary predates the fix(cli): report XLA prefill and decode separately (#3041) #3042 accounting fix, so both arms fell to whole-run accounting and the run needed --allow-whole-run-accounting. The point of that run was the harness paths, not the number.
  • Refusals exercised with exit 1 before any measurement: missing --model, a model directory that does not exist, two arms holding identical bytes, and a zero prefill window.
  • bash -n clean; --help prints the header block.

The CUDA path is left to be exercised on a GB10 host. The lock prefix and the setup script for it were verified by reading gpu-lock run --tag <tag> -- <command> and scripts/iree/setup-cuda.sh --env; the first version of the script omitted the -- that both require, and that was caught by this HIP run.

A single before/after run of `mlxcel generate --profile` moves 5 to 10 percent between runs on a thermally loaded host, so an apparent win can be drift. The new harness builds or takes both arms, runs them interleaved, reports both medians and how many paired rounds the new arm won, and requires the greedy text to match. It is the harness the decode changes of #3028, #3042 and #3043 were measured with.

Three cases are refused rather than measured because each has produced a wrong number before: two arms built from the same bytes, a zero prefill window (whole-run accounting, #3042), and differing text. Text equality is delegated to scripts/ab_output_equality.sh.

The per-device toolchain env is applied from scripts/iree/setup-*.sh when it is not already exported, and GPU use is serialized through gpu-lock on CUDA and scripts/rocm_gpu_guard.sh on HIP.
@inureyes inureyes added status:review Under review type:chore Maintenance tasks (build, CI, etc.) labels Nov 14, 2026
@inureyes
inureyes merged commit ee8ef0c into main Nov 14, 2026
31 checks passed
@inureyes
inureyes deleted the update/xla-ab-decode-pair-script branch November 14, 2026 12:39
@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

status:review Under review type:chore Maintenance tasks (build, CI, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant