Repository navigation
[Codegen][CPU] Add x86 AVX-512 VNNI 16x16x2 i8 MMA intrinsic. - #24534
Conversation
a8e703f to
e880789
Compare
c531378 to
3a9e9b4
Compare
|
do we actually have an e2e test that runs this code path? |
Yes — the in-tree e2e_matmul_cpu_dt_i8_i32_llvm-cpu_local-task_avx512vnni and e2e_matmul_cpu_experimental_dt_i8_i32_llvm-cpu_local-task_avx512vnni tests cover it. Pre-PR, the cost model picks a smaller i8 intrinsic for the data-tiled VNNI matmul; this PR's kAllX86[] entry plus the lowering at lowerX86Avx512Vnni16x16x2I8 make MMA_X86_AVX512VNNI_16x16x2_I32_I8_CASTI16 the preferred choice (largest register footprint at avx512), so post-PR those tests go through the new lowering numerically. I confirmed via --mlir-print-ir-after-all on a representative shape on this branch that the cost model does select this intrinsic for a data-tiled i8 matmul. |
GPU's configuration pipeline folds the `pack`/`expand_shape`/`transpose` relayout chain from encoding materialization into a single `iree_linalg_ext.map_store` before tiling; CPU did not. For a non-row- major encoding swizzle the intervening `tensor.expand_shape` (not a `TilingInterface` op) blocks producer fusion and strands an untiled, whole-tensor `pack` intermediate. Mirror GPU on CPU: - Add `RelayoutCombinationScope::DispatchReshape`: like `Dispatch` but restricted to chains whose backward slice contains an expand/collapse_shape. Pure pack/unpack/transpose chains tile fine and are left alone. - Run `CombineResultLayoutTransformation` with that scope in the CPU configuration pipeline, after MaterializeDeviceEncoding. - Skip `map_load`/`map_store` as `getRootOperation` candidates, so a dispatch with a real compute op plus a `map_store` roots on the compute op. Inert for existing (row-major) CPU encodings. Progress towards #24515. Co-Authored-By: Claude Opus 4.7 <[email protected]> Signed-off-by: Benoit Jacob <[email protected]>
3a9e9b4 to
5a6b922
Compare
`MMA_X86_AVX512VNNI_16x16x2_I32_I8_CASTI16` processes a full 16x16x2 i8 matmul tile, mirroring the mmt4d ukernel's hot loop. Unlike the 1x16x2 / 16x1x2 CASTI16 variants -- one row per intrinsic, with a per-row i8->i16 widen + broadcast -- it consumes whole 16x2 i8 panels: one `vpmovsxbw` widen per panel, 4 in-lane + 4 128-bit-block shuffles to fan the panels across a 4x4 grid, then 16 `vpdpwssd`. The 16x16 accumulator uses a block-interleaved `TileSwizzle` so each `vpdpwssd` accumulator is a contiguous register. i8 inner_tiled matmul, 4096x4096 on Zen 4: 72.5ms -> 52.9ms. Progress towards #24515. Co-Authored-By: Claude Opus 4.7 <[email protected]> Signed-off-by: Benoit Jacob <[email protected]>
e880789 to
9816c54
Compare
MMA_X86_AVX512VNNI_16x16x2_I32_I8_CASTI16processes a full 16x16x2 i8 matmul tile, mirroring the mmt4d ukernel's hot loop. Unlike the 1x16x2 / 16x1x2 CASTI16 variants -- one row per intrinsic, with a per-row i8->i16 widen + broadcast -- it consumes whole 16x2 i8 panels: onevpmovsxbwwiden per panel, 4 in-lane + 4 128-bit-block shuffles to fan the panels across a 4x4 grid, then 16vpdpwssd. The 16x16 accumulator uses a block-interleavedTileSwizzleso eachvpdpwssdaccumulator is a contiguous register.i8 inner_tiled matmul, 4096x4096 on Zen 4: 72.5ms -> 52.9ms.
Progress towards #24515.