Skip to content

docs(xla): validate #575 low-precision transfer to Metal + oracle dumper - #611

Merged
inureyes merged 1 commit into
mainfrom
docs/575-metal-low-precision-transfer
Jul 2, 2026
Merged

inureyes merged 1 commit into
mainfrom
docs/575-metal-low-precision-transfer

Conversation

@inureyes

@inureyes inureyes commented Jul 2, 2026

Copy link
Copy Markdown
Member

Summary

Closes #575 (part of epic #570). Brings the realized low-precision path to the Metal HAL driver on an M1 Ultra and validates it through the normal mlxcel generate load/serve path, then documents the two levers that do not cross to Metal.

The fused path #575 originally set out to transfer (#574, fused quantized-matmul) does not exist in-tree: #573 concluded it is upstream IREE work. So this closes #575 on the realizable scope (the f16-resident lever confirmed on Metal) and leaves #574 open as the upstream tracker, per the epic acceptance ("landed OR clearly characterized as upstream IREE work").

Measured on Metal (Llama-3.2-1B 4-bit, greedy, normal generate path)

precision tok/s (median-3) vs f32 token-exact vs f32
f32 1.51 1.0x reference
f16-resident (#572, metal default) 3.45 2.28x PASS (64 steps)
bf16 n/a n/a fails to compile on metal-spirv
packed int8 (#568) n/a n/a prefill invoke faults (IREE INTERNAL)
  • f16 is 2.28x over f32 and token-exact for 64 greedy steps versus the f32 path (xla_oracle_check against an XLA-f32 oracle, TOKEN-EXACT PASS at 40 and 64 steps). Both precisions are deterministic across runs. This confirms ADR 0004's transferability thesis on a second IREE target with no per-backend kernel work.
  • bf16 does not lower on metal-spirv: the Metal GPU target has no bf16 compute, so the emitter's f32-to-bf16 bitcast fails to legalize. f16 is the portable low-precision entry on Metal.
  • packed int8 compiles for Metal but the prefill invoke returns IREE status 13 (INTERNAL); it has only ever run on the GB10 CUDA runtime. Its bandwidth win is un-demonstrable on the compute-bound Metal decode regardless (the f16 result shows the decode tracks compute, not bandwidth).

Changes

  • docs/adr/0004-...md: new "Low precision on the Metal target (2026-07-02)" subsection with the results above.
  • examples/xla_traj_dump.rs (+ Cargo.toml registration): dumps the engine's greedy trajectory at the ambient MLXCEL_XLA_PRECISION as an oracle JSON, so the token-exact gate can compare one precision against another without the HF fp32 Python oracle a macOS/Metal host lacks. This is how the f16-vs-f32 check above was run.
  • src/lib/mlxcel-xla/README.md: Metal precision limits in Scope/limits, plus the oracle-free gate recipe.

Validation

  • cargo fmt --all -- --check: clean.
  • Real-checkpoint runs on Metal (MLXCEL_BACKEND=xla MLXCEL_XLA_DEVICE=metal), not a synthetic harness: token-exact passes and tok/s medians above.
  • Docs plus a gated xla-iree example only; no request-path code changed. (A pre-existing mlxcel-core/build.rs clippy nit, unrelated to this PR, is left untouched.)

Follow-ups (not in this PR)

Transfer the realized low-precision levers to the Metal HAL driver on an M1 Ultra (Llama-3.2-1B 4-bit, normal generate path). f16-resident weights (#572) run 2.28x faster than f32 (3.45 vs 1.51 tok/s median-of-3, both deterministic) and stay token-exact for 64 greedy steps versus the f32 path per the #515 harness, confirming ADR 0004's transferability thesis on a second IREE target with no per-backend kernel work.

Add the xla_traj_dump example so the token-exact gate can use the XLA f32 path itself as the reference oracle, without the HF fp32 Python oracle that a macOS/Metal host lacks.

Record the two Metal-specific divergences from the CUDA result: bf16 does not lower on metal-spirv (the target has no bf16 compute, so the f32-to-bf16 bitcast fails to legalize), and the packed int8 path compiles but faults at prefill invoke (IREE INTERNAL); its bandwidth win is un-demonstrable on the compute-bound Metal decode regardless, and the fused quantized-matmul remains upstream IREE work (#574).

Docs only plus a gated example; no request-path code changed.
@inureyes inureyes added area:inference Generation, sampling, decoding (incl. speculative, DRY) priority:low Low priority type:performance Performance improvements labels Jul 2, 2026
@inureyes
inureyes merged commit 92e2b0a into main Jul 2, 2026
4 checks passed
@inureyes
inureyes deleted the docs/575-metal-low-precision-transfer branch July 2, 2026 04:52
@inureyes inureyes self-assigned this Aug 31, 2026
@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
…lablup#611)

Transfer the realized low-precision levers to the Metal HAL driver on an M1 Ultra (Llama-3.2-1B 4-bit, normal generate path). f16-resident weights (lablup#572) run 2.28x faster than f32 (3.45 vs 1.51 tok/s median-of-3, both deterministic) and stay token-exact for 64 greedy steps versus the f32 path per the lablup#515 harness, confirming ADR 0004's transferability thesis on a second IREE target with no per-backend kernel work.

Add the xla_traj_dump example so the token-exact gate can use the XLA f32 path itself as the reference oracle, without the HF fp32 Python oracle that a macOS/Metal host lacks.

Record the two Metal-specific divergences from the CUDA result: bf16 does not lower on metal-spirv (the target has no bf16 compute, so the f32-to-bf16 bitcast fails to legalize), and the packed int8 path compiles but faults at prefill invoke (IREE INTERNAL); its bandwidth win is un-demonstrable on the compute-bound Metal decode regardless, and the fused quantized-matmul remains upstream IREE work (lablup#574).

Docs only plus a gated example; no request-path code changed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:inference Generation, sampling, decoding (incl. speculative, DRY) priority:low Low priority status:done Completed type:performance Performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: extend the fused low-precision path to the Metal target

1 participant