Repository navigation
docs(xla): validate #575 low-precision transfer to Metal + oracle dumper - #611
Merged
Merged
Conversation
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.
This was referenced Jul 2, 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.
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
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 generateload/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)
metal-spirvINTERNAL)xla_oracle_checkagainst an XLA-f32 oracle,TOKEN-EXACT PASSat 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.metal-spirv: the Metal GPU target has no bf16 compute, so the emitter'sf32-to-bf16bitcast fails to legalize. f16 is the portable low-precision entry on Metal.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.tomlregistration): dumps the engine's greedy trajectory at the ambientMLXCEL_XLA_PRECISIONas 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.MLXCEL_BACKEND=xla MLXCEL_XLA_DEVICE=metal), not a synthetic harness: token-exact passes and tok/s medians above.xla-ireeexample only; no request-path code changed. (A pre-existingmlxcel-core/build.rsclippy nit, unrelated to this PR, is left untouched.)Follow-ups (not in this PR)
MLXCEL_XLA_PRECISION=bf16up front with a clear message pointing at f16, instead of surfacing the rawiree-compilelegalization error.INTERNALfault onmetal-spirv(separate from the track(upstream-iree): fused dequant->matmul for the packed int8 bandwidth win #574 fusion gate).