Skip to content

[Codegen][CPU] inner_tiled does not scale past 1 thread: distribution tile is always 1. #25028

Open

Description

@TMahlatini

Child of #24932

Problem

setRootConfig for iree_codegen.inner_tiled sets every parallel distribution tile to 1 (KernelDispatch.cpp#L3083-L3095). Each workgroup computes a single tile over the full K: 6x32 for f32 and 14x32 for f16 RVV at VLEN 256. A large matmul becomes thousands of very small workgroups.

Ratio is ukernel wall / inner_tiled wall from #24932.

  • f32 large, 1T/4T/8T: 1.26 / 0.77 / 0.64. inner_tiled wall 26.4 / 11.2 / 9.39 ms, ukernel 33.2 / 8.57 / 6.00 ms. inner_tiled wins single-threaded and loses once distributed.
  • f16 native large: inner_tiled 4T wall is slower than 1T (19.6 vs 13.6 ms) while CPU/wall is about 3.91. Threads are busy but the total work grows.
  • CASTF32 and WIDENF32 already scale.

1T compiles use --iree-llvmcpu-disable-distribution, so they run the same inner loop without workgroup split. inner_tiled winning at 1T and losing at 4T/8T points at the distribtuion tile, not the kernel.

Likely cause, not yet measured: per-workgroup overhead and lost RHS/LHS reuse across cores when each workgroup is one inner tile. Comparing workgroup counts and cache misses between 1T and 4T would confirm it.

Where to look

  • the tile is set in setRootConfig for InnerTiledOp (#L3060-L3121). Its comment already names the mmt4d cost model as the template follow-up.
  • The mmt4d path picks larger tiles in getMmt4dLoweringConfig (#L1820-L1966), bounded by `iree-llvmcpu-matmul-tile-bytes (256 KiB)
  • Both ops use the Mmt4dTilingExpert pipeline, so the workgroup split itself is shared.

Open questions

  • How should the mmt4d byte model map onto inner_tiled, where one iteration is already a whole inner tile?
  • What should happen with dynamic outer dims and batch dims?
  • Should the search be shared with mmt4d or kept seperate?

Expected outcome

4T and 8T inner_tiled walls scale past 1T on the f32 and f16 large shapes, without regressing 1T, CASTF32 or WIDENF32.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions