Repository navigation
[Codegen][CPU] Drop the power-of-two cap on chooseUnrolling. - #24495
Merged
Merged
Conversation
25 of 28 tasks
bjacob
force-pushed
the
users/bjacob/cpu-inner-tiled-vpdpbusd
branch
from
May 15, 2026 14:04
d877a4b to
41d1eb5
Compare
bjacob
force-pushed
the
users/bjacob/cpu-mma-drop-pow2-unrolling-cap
branch
from
May 15, 2026 14:04
bca2822 to
d933814
Compare
bjacob
force-pushed
the
users/bjacob/cpu-inner-tiled-vpdpbusd
branch
from
May 15, 2026 15:54
41d1eb5 to
75c3ec0
Compare
bjacob
force-pushed
the
users/bjacob/cpu-mma-drop-pow2-unrolling-cap
branch
from
May 15, 2026 15:54
d933814 to
00e5785
Compare
bjacob
force-pushed
the
users/bjacob/cpu-inner-tiled-vpdpbusd
branch
from
May 15, 2026 16:02
75c3ec0 to
e850560
Compare
bjacob
force-pushed
the
users/bjacob/cpu-mma-drop-pow2-unrolling-cap
branch
from
May 15, 2026 16:02
00e5785 to
321ccbe
Compare
bjacob
force-pushed
the
users/bjacob/cpu-inner-tiled-vpdpbusd
branch
from
May 15, 2026 17:06
e850560 to
ac57449
Compare
bjacob
force-pushed
the
users/bjacob/cpu-mma-drop-pow2-unrolling-cap
branch
from
May 15, 2026 17:06
321ccbe to
2c2f57d
Compare
…ework. The framework so far only generated symmetric-type matmuls (LHS and RHS of the same type via `--lhs_rhs_type`). This generalizes it to support `--lhs` and `--rhs` separately so we can test asymmetric-type intrinsics like the upcoming x86 AVX-512 VNNI vpdpbusd (LHS=ui8, RHS=i8 → ACC=i32). - `generate_e2e_matmul_tests.py`: replace `--lhs_rhs_type` with the per-operand `--lhs` / `--rhs` pair (legacy form still accepted; the CLI requires exactly one form). Adds a `ui8` choice. Plumbing for separate `lhs_type`/`rhs_type` is threaded through `generate()` / `generate_function()` / `generate_call()`. - `generate_code.py`: emit a `linalg.generic` (with `arith.extui` / `arith.extsi` widening) when LHS != RHS or an operand is unsigned; buffer-view printing uses the `ui8` HAL element type for unsigned operands. - `iree-e2e-matmul-test.cc`: new `REFERENCE_MATMUL(uint8_t, int8_t, int32_t, int32_t)` reference and matching dispatch arm for `IREE_HAL_ELEMENT_TYPE_UINT_8` LHS / signed-i8 RHS. New test `e2e_matmul_cpu_dt_inner_tiled_ui8_i8_i32` exercises the generated ui8/i8 matmul through the data-tiling + inner-tiled pipeline. No matching hardware MMA intrinsic exists yet (this commit is purely framework), so it only runs on the `generic` CPU variant and falls through to the type-polymorphic generic-scalar MMA. A follow-up PR adds the vpdpbusd MMA and an `avx512vnni` variant. Progress towards #24323. Signed-off-by: Benoit Jacob <[email protected]>
Adds `vpdpbusd` — the AVX-512-VNNI byte dot-product — as a data-tiled MMA intrinsic. It is the first asymmetric MMA: the first byte source is unsigned, the second is signed, so the natural and swapped orientations need different arg-routing at the call site (unlike the LHS/RHS-symmetric FMA / dpbf16ps / vpdpwssd / pmaddw already supported). Two new enum values, `MMA_X86_AVX512VNNI_1x16x4_I32_UI8_I8` and its M↔N-swapped sibling `MMA_X86_AVX512VNNI_16x1x4_I32_I8_UI8`, both lower to `llvm.x86.avx512.vpdpbusd.512`. The swapped lowering flips its (lhs, rhs) call args so the unsigned operand still lands in the first slot. Signedness handling — per IREE convention, vector tile types in IR are signless, with the signed/unsigned distinction carried on the encoding's `element_types`. `getABCElementTypes(intrinsic)` now returns `ui8` where applicable, used by the cost model and validator for matching against an encoding's `element_types`; `getUndistributedTileTypes` strips the signedness when constructing tile types. The validator and cost-model `getIntrinsicInfo` bypass `getUndistributedTileTypes` and read shape + types straight from the intrinsic via `getRowMajorTilesMNKShape` and `getABCElementTypes`, which become public for that reason. The prerequisite "distinct LHS/RHS types" PR added the `e2e_matmul_cpu_dt_inner_tiled_ui8_i8_i32` test on the `generic` variant only; this commit adds the `avx512vnni` variant that actually selects the new intrinsic. Progress towards #24323. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> Signed-off-by: Benoit Jacob <[email protected]>
`chooseUnrolling` previously enumerated `intrinsics_m` / `intrinsics_n` through powers of two. There's no real reason for that — within the register budget, the cost model can pick any factor. Looking ahead: some intrinsics may eventually want the unroll factor on a particular dim to be a multiple of some target-specific number — Arm scalar-by-element FMA forms are an example, where the scalar is a lane of a vector register, so covering whole vector registers is more efficient. But even there it's not a strict preference: narrow matmuls (e.g. matrix-vector) are better off avoiding the padding that imposing that multiple would force. So a simple per-intrinsic "preferred multiple" doesn't capture it. We'll come back to this when we have a concrete need. Lit-test fallout: relaxing pow2 lets the cost model land on better non-pow2 unrolls in some cases the existing tests pin (e.g. `materialize_encoding_x86_64.mlir`'s dynamic-N AVX-512 case now picks `intrinsics_m = 29` instead of 16 — saturating the zmm register file much more tightly, and at higher arithmetic intensity per the existing scoring formula). CHECK lines updated to the new values. Progress towards #24323. Signed-off-by: Benoit Jacob <[email protected]>
bjacob
force-pushed
the
users/bjacob/cpu-inner-tiled-vpdpbusd
branch
from
May 15, 2026 19:41
ac57449 to
5773d5c
Compare
bjacob
force-pushed
the
users/bjacob/cpu-mma-drop-pow2-unrolling-cap
branch
from
May 15, 2026 19:41
2c2f57d to
05a52e4
Compare
bjacob
marked this pull request as ready for review
May 15, 2026 20:02
bjacob
requested review from
MaheshRavishankar,
Max191,
hanhanW,
jtuyls and
qedawkins
as code owners
May 15, 2026 20:02
hanhanW
approved these changes
May 18, 2026
RattataKing
pushed a commit
to RattataKing/iree
that referenced
this pull request
May 27, 2026
…org#24495) `chooseUnrolling` previously enumerated `intrinsics_m` / `intrinsics_n` through powers of two. There's no real reason for that — within the register budget, the cost model can pick any factor. Looking ahead: some intrinsics may eventually want the unroll factor on a particular dim to be a multiple of some target-specific number — Arm scalar-by-element FMA forms are an example, where the scalar is a lane of a vector register, so covering whole vector registers is more efficient. But even there it's not a strict preference: narrow matmuls (e.g. matrix-vector) are better off avoiding the padding that imposing that multiple would force. So a simple per-intrinsic "preferred multiple" doesn't capture it. We'll come back to this when we have a concrete need. Lit-test fallout: relaxing pow2 lets the cost model land on better non-pow2 unrolls in some cases the existing tests pin (e.g. `materialize_encoding_x86_64.mlir`'s dynamic-N AVX-512 case now picks `intrinsics_m = 29` instead of 16 — saturating the zmm register file much more tightly, and at higher arithmetic intensity per the existing scoring formula). CHECK lines updated to the new values. Progress towards iree-org#24323. --------- Signed-off-by: Benoit Jacob <[email protected]> Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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.
chooseUnrollingpreviously enumeratedintrinsics_m/intrinsics_nthrough powers of two. There's no real reason for that — within the register budget, the cost model can pick any factor.Looking ahead: some intrinsics may eventually want the unroll factor on a particular dim to be a multiple of some target-specific number — Arm scalar-by-element FMA forms are an example, where the scalar is a lane of a vector register, so covering whole vector registers is more efficient. But even there it's not a strict preference: narrow matmuls (e.g. matrix-vector) are better off avoiding the padding that imposing that multiple would force. So a simple per-intrinsic "preferred multiple" doesn't capture it. We'll come back to this when we have a concrete need.
Lit-test fallout: relaxing pow2 lets the cost model land on better non-pow2 unrolls in some cases the existing tests pin (e.g.
materialize_encoding_x86_64.mlir's dynamic-N AVX-512 case now picksintrinsics_m = 29instead of 16 — saturating the zmm register file much more tightly, and at higher arithmetic intensity per the existing scoring formula). CHECK lines updated to the new values.Progress towards #24323.