Skip to content

[Codegen][CPU] Add x86 AVX-512 VNNI vpdpbusd MMA intrinsic. - #24494

Merged
bjacob merged 2 commits into
mainfrom
users/bjacob/cpu-inner-tiled-vpdpbusd
May 19, 2026
Merged

bjacob merged 2 commits into
mainfrom
users/bjacob/cpu-inner-tiled-vpdpbusd

Conversation

@bjacob

@bjacob bjacob commented May 14, 2026

Copy link
Copy Markdown
Collaborator

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.

@bjacob bjacob mentioned this pull request May 14, 2026
25 of 28 tasks
@bjacob
bjacob force-pushed the users/bjacob/e2e-matmul-distinct-lhs-rhs-types branch from 87920d9 to 04c4b79 Compare May 15, 2026 14:04
@bjacob
bjacob force-pushed the users/bjacob/cpu-inner-tiled-vpdpbusd branch from d877a4b to 41d1eb5 Compare May 15, 2026 14:04
@bjacob
bjacob force-pushed the users/bjacob/e2e-matmul-distinct-lhs-rhs-types branch from 04c4b79 to 4c6b5a9 Compare May 15, 2026 15:54
@bjacob
bjacob force-pushed the users/bjacob/cpu-inner-tiled-vpdpbusd branch from 41d1eb5 to 75c3ec0 Compare May 15, 2026 15:54
@bjacob
bjacob force-pushed the users/bjacob/e2e-matmul-distinct-lhs-rhs-types branch from 4c6b5a9 to d17ea2f Compare May 15, 2026 16:02
@bjacob
bjacob force-pushed the users/bjacob/cpu-inner-tiled-vpdpbusd branch from 75c3ec0 to e850560 Compare May 15, 2026 16:02
@bjacob
bjacob force-pushed the users/bjacob/e2e-matmul-distinct-lhs-rhs-types branch from d17ea2f to ba02c9a Compare May 15, 2026 17:06
@bjacob
bjacob force-pushed the users/bjacob/cpu-inner-tiled-vpdpbusd branch from e850560 to ac57449 Compare May 15, 2026 17:06
bjacob and others added 2 commits May 15, 2026 15:41
…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]>
@bjacob
bjacob force-pushed the users/bjacob/e2e-matmul-distinct-lhs-rhs-types branch from ba02c9a to 0f31820 Compare May 15, 2026 19:41
@bjacob
bjacob force-pushed the users/bjacob/cpu-inner-tiled-vpdpbusd branch from ac57449 to 5773d5c Compare May 15, 2026 19:41
@bjacob
bjacob marked this pull request as ready for review May 15, 2026 20:02
@bjacob
bjacob requested review from Max191, hanhanW and jtuyls as code owners May 15, 2026 20:02
@bjacob
bjacob changed the base branch from users/bjacob/e2e-matmul-distinct-lhs-rhs-types to main May 19, 2026 15:38
@bjacob
bjacob requested a review from benvanik as a code owner May 19, 2026 15:38
@bjacob
bjacob merged commit e8ac558 into main May 19, 2026
61 of 64 checks passed
@bjacob
bjacob deleted the users/bjacob/cpu-inner-tiled-vpdpbusd branch May 19, 2026 15:39
RattataKing pushed a commit to RattataKing/iree that referenced this pull request May 27, 2026
…#24494)

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 iree-org#24323.

---------

Signed-off-by: Benoit Jacob <[email protected]>
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants