Skip to content

docs: fusion spike findings for the packed int8 path (#573) - #578

Merged
inureyes merged 1 commit into
mainfrom
spike/573-fusion-investigation
Jul 1, 2026
Merged

inureyes merged 1 commit into
mainfrom
spike/573-fusion-investigation

Conversation

@inureyes

@inureyes inureyes commented Jul 1, 2026

Copy link
Copy Markdown
Member

Summary

Part of #570. The #573 spike measures whether IREE's CUDA codegen can fuse the packed int4/int8 dequant into the matmul, so the reconstructed weight is not materialized to DRAM every decode step. Deliverable: a reproducible measurement harness (scripts/xla/fusion_spike.sh) and a findings section in the mlxcel-xla README.

Method

The fusion signal is the static decode dispatch count: iree-compile --compile-to=flow on the real packed decode graph, counting flow.dispatch. tok/s is end-to-end through the mlxcel binary. scripts/xla/fusion_spike.sh reproduces the baseline, an 11-config flag sweep, and three one-matmul microtests (dequant then matmul, bare f16, bare int8).

Findings (GB10, IREE 3.11.0rc @ e4a3b04, Llama-3.2-1B 4-bit)

decode path flow.dispatch tok/s
packed, in-graph dequant (#568) 678 ~1.5
f16-resident (#572) 454 ~7.6
  • No iree-compile flag fuses it. The 11-config sweep (aggressive-fusion, generalize-matmul, early-trunc, horizontal-contractions, fuse-multi-use, elementwise-multi-reduction, encoding-fusion, data-tiling x2, all-combined) stays at 677-678. Data-tiling is a no-op on CUDA (encoding layout resolvers are hip/rocm-only).
  • The dequant is a separate dispatch. The dequant-then-matmul microtest is 2 dispatches (elementwise producer + matmul) under every flag: IREE does not fuse an elementwise producer into a matmul operand load on CUDA.
  • linalg.quantized_matmul / ukernels are CUDA-unavailable. Data-tiling encodings and ukernels, the facilities that carry a fused quantized matmul, are gated to hip/rocm/llvm-cpu, not cuda.
  • int8 dot_general lowers, but upcasts. A bare i8 x i8 -> i32 matmul compiles to one CUDA kernel (like f16), but the codegen upcasts i8 -> i32 (17 sext, zero dp4a / mma.*.s8): no int8 tensor cores, so int8 would not beat f16 here.

Split and recommendation for #574

  • In-tree today: f16-resident weights (feat: f16-resident weights on the OpenXLA path (fusion-free bandwidth win) #572, landed) is the realized bandwidth lever (token-exact, ~7.6 tok/s). The packed int8 path is a correctness foundation but is dominated on CUDA (678 dispatches, ~1.5 tok/s) until fusion exists.
  • Upstream IREE: a fused dequant-to-matmul (or a hardware int8 tensor-core matmul) for the CUDA target, an IREE CUDA quantized-matmul codegen path / encoding resolver / ukernel that does not exist in 3.11.0.
  • track(upstream-iree): fused dequant->matmul for the packed int8 bandwidth win #574 therefore takes the "ship the minimal in-tree representation + track upstream" branch the issue allows: keep the packed path behind MLXCEL_XLA_QUANT=packed, and fold in the bf16 scales/biases limitation (extend the packed emitter + loader to accept bf16 scales, matching fix(xla): load bf16 affine quant scales in the OpenXLA weight loader #569's dequant-at-load broadening: the emitter declares the .scales / .biases args, currently f16, as bf16 when the checkpoint stores them bf16, and the loader uploads the raw bf16 bytes with a bf16 dtype code). It does not attempt an int8-beats-f16 fusion win in-tree (not achievable per the measurements above).

Closes #573
Part of #570

Measure whether IREE's CUDA codegen fuses the packed int4/int8 dequant into
the matmul, so the reconstructed weight is not materialized to DRAM every
decode step. Adds scripts/xla/fusion_spike.sh (reproducible: static decode
dispatch count via `iree-compile --compile-to=flow`, an 11-config flag sweep,
and dequant / f16 / int8 matmul microtests) and records the result in the
mlxcel-xla README.

Finding (GB10, IREE 3.11.0rc @ e4a3b04): no in-tree lever fuses it. The flag
sweep stays at 677-678 dispatches; the dequant is always a separate elementwise
dispatch (the one-matmul microtest is 2 dispatches under every flag); data-tiling
encodings and ukernels (the facilities that carry a fused quantized matmul) are
gated to hip / rocm / llvm-cpu, not cuda; and a bare int8 dot_general lowers but
upcasts i8 -> i32 with no int8 tensor cores. The fused kernel is upstream IREE
work; the realized in-tree bandwidth win is f16-resident weights (#572). #574
ships the minimal in-tree packed representation (bf16 scales) and tracks upstream.

Part of #570
@inureyes inureyes added type:performance Performance improvements priority:medium Medium priority area:inference Generation, sampling, decoding (incl. speculative, DRY) status:review Under review labels Jul 1, 2026
@inureyes
inureyes merged commit f064d34 into main Jul 1, 2026
4 checks passed
@inureyes
inureyes deleted the spike/573-fusion-investigation branch July 1, 2026 09:26
@inureyes inureyes added status:done Completed and removed status:review Under review labels Jul 1, 2026
@inureyes inureyes self-assigned this Aug 31, 2026
be-free-snowboy pushed a commit to freestylejs/snowbrain-mlxcel that referenced this pull request Oct 27, 2026
…blup#578)

Measure whether IREE's CUDA codegen fuses the packed int4/int8 dequant into
the matmul, so the reconstructed weight is not materialized to DRAM every
decode step. Adds scripts/xla/fusion_spike.sh (reproducible: static decode
dispatch count via `iree-compile --compile-to=flow`, an 11-config flag sweep,
and dequant / f16 / int8 matmul microtests) and records the result in the
mlxcel-xla README.

Finding (GB10, IREE 3.11.0rc @ e4a3b04): no in-tree lever fuses it. The flag
sweep stays at 677-678 dispatches; the dequant is always a separate elementwise
dispatch (the one-matmul microtest is 2 dispatches under every flag); data-tiling
encodings and ukernels (the facilities that carry a fused quantized matmul) are
gated to hip / rocm / llvm-cpu, not cuda; and a bare int8 dot_general lowers but
upcasts i8 -> i32 with no int8 tensor cores. The fused kernel is upstream IREE
work; the realized in-tree bandwidth win is f16-resident weights (lablup#572). lablup#574
ships the minimal in-tree packed representation (bf16 scales) and tracks upstream.

Part of lablup#570
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:medium Medium priority status:done Completed type:performance Performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spike: quantized-matmul / dequant-to-matmul fusion investigation on IREE (CUDA first)

1 participant