gemm: software-pipelined k-loop + INT8 dtype support - #177
Closed
bong-water-water-bong wants to merge 3 commits into
Closed
gemm: software-pipelined k-loop + INT8 dtype support#177bong-water-water-bong wants to merge 3 commits into
bong-water-water-bong wants to merge 3 commits into
Conversation
added 2 commits
August 31, 2026 17:11
- aie_kernels/aie2p/mm.cc: software-pipeline the k-loop in
matmul_vectorized_2x2_mmul — prologue loads k-step 0, the loop body
consumes the previous step's A/B tiles while prefetching the next, and
an epilogue MACs the final step. Hides load->vmac latency (verified
bit-exact vs numpy int32 on NPU Strix Halo; ~7.8 TOPS at 2048^3 i8->i32).
- iron/operators/gemm/op.py: per-dtype tile-multiple validation matching
the kernel static_asserts; _kernel_dtype_flag selects the {combo}_ONLY
define (bf16_f32_ONLY under prio_accuracy since design.py resolves
matmul_bf16_f32); reject integer outputs narrower than the 32-bit
accumulator (i8->i8/i8->i16/i16->i16 truncate).
- iron/operators/gemm/design.py: merge duplicate npu1 entry; add i8/i16
MAC dims for npu1/npu2.
- bench_int8.py / int8_bench.py / run_int8_gemm.py: NPU INT8 GEMM
benchmarks (bit-exactness + TOPS, 2048^3 and shape sweeps).
Known limits (upstream design, not this kernel): first dispatch after an
xclbin reload in a multi-shape process can race the zero kernel (retry
exact); N=8192 with 8 columns exceeds the aie.dma_bd stride range
(per-column C slice 2^21 > 2^20) — use partition_N for very wide outputs.
- aie_kernels/aie2p/mm.cc: software-pipeline the k-loop in
matmul_vectorized_2x2_mmul — prologue loads k-step 0, the loop body
consumes the previous step's A/B tiles while prefetching the next, and
an epilogue MACs the final step. Hides load->vmac latency on AIE2P;
the pipelining hint is clamped to the real compile-time trip count
(colA-1, [1,4]) so small K tiles are not mis-scheduled. Verified
bit-exact vs numpy int32 on NPU Strix Halo (~8.4 TOPS at 2048^3 i8->i32).
- iron/operators/gemm/op.py: per-dtype tile-multiple validation matching
the kernel static_asserts; _kernel_dtype_flag selects the {combo}_ONLY
define (bf16_f32_ONLY under prio_accuracy, matching design.py's
matmul_bf16_f32 resolution); integer outputs narrower than the 32-bit
accumulator are rejected (i8->i8/i8->i16/i16->i16 truncate).
- iron/operators/gemm/design.py: merge duplicate npu1 entry; add i8/i16
MAC dims for npu1/npu2.
bong-water-water-bong
requested review from
andrej,
hunhoffe and
jgmelber
as code owners
August 31, 2026 21:04
NPU2 (Strix Halo): a dispatch can rarely (~5% per process) return a wrong result after several distinct xclbins compile in one process — the zero/accumulate write races the first submit on a fresh context and self-heals on the next dispatch. Document the warm-up + verify + retry guidance in the GEMM docstring.
Author
|
Closing — superseded. The INT8 + software-pipelined-k-loop work landed on devel in refined form ( |
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
Software-pipeline the k-loop in
matmul_vectorized_2x2_mmuland add validated INT8/INT16 dtype support to the GEMM operator.Kernel (aie_kernels/aie2p/mm.cc)
Operator (op.py, design.py)
_kernel_dtype_flagselects the correct{combo}_ONLYdefine;bf16_f32_ONLYunderprio_accuracy.Validation (NPU Strix Halo, XDNA2)