Repository navigation
Description
Part of #570. Status: BLOCKED for fused-kernel implementation; a bounded latest-pin revalidation can start now. This remains a tracking issue, not active fused-kernel implementation work. The in-tree representation is already shipped and correctness-verified; the throughput win it exists for still requires IREE target support on CUDA or metal-spirv. The 2026-07-22 upstream audit found no advertised data-tiling support for either target in the latest IREE candidate.
What is already in-tree (the representation is ready)
- The packed int8 path (
MLXCEL_XLA_QUANT=packed, feat: int8/int4 packed weight quantization on the OpenXLA path (#516) #568): MLX 4/8-bit weights stay resident packed (ui32payload + f16 scales/biases) and are dequantized inside the StableHLO graph (bit-unpack, thenq*scale + bias). Per-weight-dtype weight ABI landed with it. - Dequant-at-load broadened to bf16 scales/biases (fix(xla): load bf16 affine quant scales in the OpenXLA weight loader #569).
- The path is token-exact with the f32/f16 path on the CUDA target (the in-graph reconstruction is bit-identical to the host dequant), verified on GB10.
- Metal and precision guards so the unsupported knobs fail fast instead of faulting mid-run:
MLXCEL_XLA_QUANT=packedon Metal (bug(xla): packed int8 (MLXCEL_XLA_QUANT=packed) prefill invoke faults on metal-spirv #613) andMLXCEL_XLA_PRECISION=bf16on Metal (feat(xla): fail fast when MLXCEL_XLA_PRECISION=bf16 targets a Metal device #612).
The blocker (measured)
The #573 spike ran real graphs through iree-compile + the runtime and concluded the fusion is upstream IREE work:
- CUDA (GB10): the packed decode is token-exact but about 4.3x slower than f16 (~1.6 vs ~6.7 tok/s, Llama-3.2-1B 4-bit, greedy). IREE's CUDA codegen does not fuse the in-graph unpack+dequant into the matmul: the decode step is ~678 dispatches and the reconstructed f32 weight is materialized to DRAM every step, so the graph pays MORE bandwidth and compute, not less. The
aggressive-fusion/generalize-matmul/early-trunc-fusionflags leave the dispatch count unchanged (678 -> 677). - Metal (M1 Ultra): the packed prefill compiles for
metal-spirvbut the invoke faults at runtime in the metal HAL driver (metal_device.m:Metal command buffer failed (status 5)athal.fence.await, surfaced as IREEINTERNAL). Found in feat: extend the fused low-precision path to the Metal target #575, guarded off in bug(xla): packed int8 (MLXCEL_XLA_QUANT=packed) prefill invoke faults on metal-spirv #613.
So the memory-bandwidth payoff is not realized by authoring the dequant in the portable graph alone; it needs the TARGET to fuse dequant into the matmul (a quantized-matmul op, or an int8 dot_general lowering to the hardware int8 path). ADR 0004 already scopes per-backend fused kernel codegen as upstream IREE's responsibility.
Upstream status refresh (2026-07-22)
The three previously linked IREE issues do not all represent active blockers:
iree-org/iree#18513— OPEN / PARTIAL / related foundation. DispatchCreation data-tiling and grouped quantized-matmul fusion have advanced, including a regression showing dequant and contraction in one dispatch. However, IREE's documentation foriree-3.12.0rc20260721lists data-tiling support only for x86/AArch64/RISC-V CPU, ROCm GPU, and VMVX — not CUDA ormetal-spirv. Keep this as background tracking, but its closure alone would not satisfy this issue.iree-org/iree#8330— DONE / historical reference. The lowering fromlinalg.quantized_matmultolinalg.matmulplus zero-point arithmetic landed iniree-org/iree#8409on 2022-02-27 and remains covered by IREE tests. It does not provide a fused packed-dequant GPU kernel, so it is not an active dependency.iree-org/iree#16937— OPEN / context only.iree-org/iree#16927added a shared-memory-aware cooperative-matrix schedule, but the reporter reproduced the SPIR-V failure afterward and a default Distribute-path follow-up was left unverified. More importantly, that Vulkan compile-time shared-memory failure is not the same failure class as mlxcel's Metal HAL runtime command-buffer fault. Keep it as diagnostic context, not as the Metal unblock tracker.
The direct upstream unblock remains target support that fuses dequant/unpack into the matmul (or lowers a grouped/quantized dot to a native int8 kernel) on CUDA and metal-spirv, so the packed graph does not materialize reconstructed f32 weights to DRAM each step.
The latest stable IREE release is still v3.11.0; the next validation target is the official candidate iree-3.12.0rc20260721 at dc9601f88654749456c7cee4ae87e13de2654e1e. The candidate compiler/runtime must be version-matched on both CUDA and Metal.
We do not open an issue on the IREE repository (project policy: issues live on lablup/mlxcel). Re-check the target support and measured behavior on each MLX/IREE pin bump rather than using upstream issue closure alone.
Next actionable step: latest-pin revalidation
This bounded work can start without treating the fused-kernel implementation as unblocked:
- CUDA / GB10: build the version-matched
iree-3.12.0rc20260721compiler/runtime, rerunscripts/xla/fusion_spike.sh, and record packed/f16 dispatch counts, token exactness, tok/s, and whether generated code contains native int8 instructions (dp4a/ integer MMA) instead of scalar widening. - Metal / M1 Ultra: compile and invoke the minimal packed repro on the matching candidate, capture the faulting encoder/dispatch with Metal command-buffer diagnostics, and determine whether the failure is a bad kernel or a HAL command-buffer limit.
- Record both results here. If CUDA still has no fused/native-int8 path and Metal still faults, keep this issue blocked and update only the last-checked pin/date.
Unblock criteria (what mlxcel does when upstream lands)
- Re-enable the packed path behind the existing
MLXCEL_XLA_QUANT=packedgate; relax the Metal guard (bug(xla): packed int8 (MLXCEL_XLA_QUANT=packed) prefill invoke faults on metal-spirv #613) oncemetal-spirvexecutes the fused kernel. - On GB10, int8 packed
tok/s > f16 tok/s(reverses the feat: int8/int4 packed weight quantization on the OpenXLA path (#516) #568 regression), token-exact or within-gate per the test: precision accuracy gate and per-device default precision for the OpenXLA backend (#449) #515 harness, with the decode dispatch count materially reduced from ~678. - Fold in the packed path accepting bf16 scales/biases (today it requires f16; fix(xla): load bf16 affine quant scales in the OpenXLA weight loader #569 broadened only the dequant-at-load path), verified on a bf16-scale MLX checkpoint through the normal load path.
Payoff caveat
Even once fused, the bandwidth win only matters on an int-native / NPU target. On the compute-bound Metal decode it is un-demonstrable regardless (the #575 f16 result shows the Metal decode tracks compute, not bandwidth; ADR 0004). So this unblocks the CUDA/NPU path first; Metal gets correctness, not throughput.
References
#570 (epic), #573 (spike: in-tree vs upstream split), #568 / #569 (packed representation + bf16 dequant-at-load), #612 / #613 (Metal fail-fast guards), #575 / #611 (Metal transfer validation), ADR docs/adr/0004-compute-backend-session-seam-and-stablehlo-family.md.
Refresh log
- 2026-07-22 — Audited the linked IREE issues and latest official release state.
- Reclassified
iree-org/iree#18513as partial/background because CUDA andmetal-spirvare still outside the documented data-tiling target set. - Reclassified completed
iree-org/iree#8330as historical context, not an active dependency. - Reclassified
iree-org/iree#16937as diagnostic context, not a direct tracker for the Metal runtime fault. - Added a concrete
iree-3.12.0rc20260721CUDA/Metal revalidation checklist; the fused-kernel implementation remains blocked.
- Reclassified
Activity
docs: fusion spike findings for the packed int8 path (#573) (#578)
inureyes commentedon Jul 2, 2026
Spike outcome: the fusion is upstream IREE work
The #573 spike (merged in #578; findings in
src/lib/mlxcel-xla/README.md, reproducible viascripts/xla/fusion_spike.sh) measured that IREE's CUDA codegen does not fuse the packed dequant into the matmul, and that no in-tree lever changes it:iree-compileflag sweep: 677-678 decodeflow.dispatch(no fusion).linalg.quantized_matmul/ ukernels / data-tiling encodings: gated tohip/rocm/llvm-cpu, not thecudatarget.dot_general: lowers to a single CUDA kernel but upcastsi8 -> i32(17sext, zerodp4a/mma.*.s8), so int8 would not beat f16.So this issue takes its documented fallback: track the upstream IREE work, with the minimal in-tree representation kept prepared.
MLXCEL_XLA_QUANT=packed, feat: int8/int4 packed weight quantization on the OpenXLA path (#516) #568) is the correctness-verified foundation; f16-resident weights (feat: f16-resident weights on the OpenXLA path (fusion-free bandwidth win) #572) is the realized bandwidth win on the IREE targets today (token-exact, ~7.6 vs ~5.2 f32 tok/s on GB10).Keeping this open as the upstream tracker for the fused quantized-matmul.
docs(xla): validate #575 low-precision on Metal + oracle dumper (#611)
inureyes commentedon Jul 2, 2026
Metal data point, from the #575 validation (#611): the packed path (
MLXCEL_XLA_QUANT=packed) compiles formetal-spirvbut the prefill invoke faults at runtime with IREE status 13 (IREE_STATUS_INTERNAL) on an M1 Ultra. It has only ever executed on the GB10 CUDA runtime. This is separate from the dequant-to-matmul fusion gate this issue tracks; noting it so the eventual fused-matmul work also covers the Metal runtime path (and because its bandwidth win is un-demonstrable on the compute-bound Metal decode anyway).fix(xla): fail fast on MLXCEL_XLA_QUANT=packed for Metal targets (#617)
[-]feat: fused quantized-matmul realizing the int8 bandwidth win[/-][+]track(upstream-iree): fused dequant->matmul for the packed int8 bandwidth win[/+]inureyes commentedon Jul 2, 2026
Reorganized this as an upstream-IREE tracker (was a to-implement issue). The in-tree packed representation is already shipped and token-exact on CUDA (#568/#569), with Metal/bf16 fail-fast guards (#612/#613); the remaining work is IREE fusing dequant into the matmul on the GPU targets, which #573 established is upstream. Relabeled status:ready to status:blocked and priority to low. Primary upstream item to watch: iree-org/iree#18513 (data-tiling fusion for grouped quantized matmul). Per project policy no issue is filed on the IREE repo; we re-check the linked upstream items on each MLX/IREE pin bump. Full unblock criteria in the body.
inureyes commentedon Jul 2, 2026
Can we patch IREE ourselves (like the in-tree MLX Metal kernels)?
The surface splits in two, because
setup-{macos,cuda}.shbuilds only half of IREE from source:iree_runtime_unified,IREE_HAL_DRIVER_METAL=ON), so the metal HAL driver is our build. The Metal command-buffer fault (bug(xla): packed int8 (MLXCEL_XLA_QUANT=packed) prefill invoke faults on metal-spirv #613) is patchable here, the same shape assrc/lib/mlx-cpp/turbo/*. Concrete first step:runtime/src/iree/hal/drivers/metal/direct_command_buffer.mcreates the buffer withMTLCommandBufferErrorOptionNone; switching toMTLCommandBufferErrorOptionEncoderExecutionStatuswould name the faulting encoder/dispatch and tell us whether it is an in-tree-fixable HAL limit (e.g. oversized dispatch, split the command buffer) or a bad kernel from the compiler. Payoff is correctness only: the packed bandwidth win is un-demonstrable on the compute-bound Metal decode regardless.iree_base_compiler,IREE_BUILD_COMPILER=OFF). Patching the fusion codegen (the 4.3x lever) means either source-building and forking the data-tiling / fusion passes, which is reimplementingiree-org/iree#18513(heavy, general compiler work, belongs upstream), OR the MLX-kernel analogue: a custom-dispatch fused dequant->matmul kernel that links a hand-written kernel through the stock compiler (samples/custom_dispatch/...). That custom-dispatch route ships for CUDA / HIP / Vulkan / CPU but not Metal.Assessment. The only self-patch with a real, demonstrable payoff is a custom-dispatch fused kernel on CUDA / GB10 (reverses the 4.3x, and CUDA has no MLX so IREE is the backend there). It needs a GB10 host to build and validate, plus emitter integration to emit the custom-dispatch call, and re-pin / rebase maintenance. The Metal HAL fault is cheaply patchable but low value. Forking the compiler is not worth it against upstream #18513. Parked here until a GB10 host is available or the payoff is warranted.
inureyes commentedon Oct 14, 2026
ROCm (
hip/gfx1151) Update from #851 QualificationOn IREE
3.12.0rc20260721(dc9601f88654749456c7cee4ae87e13de2654e1e) targeting AMD Radeon 8060S Graphics (gfx1151, ROCm 7.2.2):hiplowering (--iree-hal-target-device=hip --iree-rocm-target=gfx1151): compiles cleanly (1,209flow.dispatchops across the 16-layerLlama-3.2-1B-Instruct-4bitdecode graph) and passes the 64-token greedy trajectory gate (64/64 TOKEN-EXACT PASS, max step layer-15 logitmax_abs = 6.953e-2), cutting host-to-device weight upload bytes by ~3.5x (0.93 GiBvs3.21 GiBfor host-dequantizedf16). However,iree-compilestill lowers eachdequant -> matmulpair into 2 separate dispatches (1 elementwisei8 -> f16dequant dispatch + 1 materializedf16GEMM dispatch), resulting in4.33 tok/sdecode vs14.22 tok/sfor host-dequantizedf16.--iree-global-opt-data-tiling(padanddata-tilingencoding layout resolvers): fails onhipduringiree-ROCMSelectLoweringStrategyPasswitherror: 'tensor.expand_shape' op expected collapsed rank (2) to equal the number of reassociation maps (3)followed byerror: failed to materializeConstant of type 'tensor<16x128xf32>'.Full reproduction commands and compiler dump excerpts are recorded in
docs/benchmark_results/xla_iree_rocm_qualification.mdandscripts/xla/fusion_spike.sh(generalized forMLXCEL_XLA_DEVICE=hip).test(xla): qualify the OpenXLA/IREE engine on ROCm/HIP (#2307)
docs: fusion spike findings for the packed int8 path (lablup#573) (la…
docs(xla): validate lablup#575 low-precision on Metal + oracle dumper (…
fix(xla): fail fast on MLXCEL_XLA_QUANT=packed for Metal targets (lab…