Skip to content

Tracking: [RVV] inner_tiled performance vs mmt4d ukernels #24932

Open

Description

@TMahlatini

WIP (& AI generated summary)

Tracking inner_tiled MMA codegen vs the existing mmt4d ukernel path on RISC-V V. Hardware is a SpaceMiT X60 (VLEN=256). First-iteration codegen is not required to be on-par; this issue is the dashboard. Per-dtype absolute ms, CPU/wall, and follow-ups live in child issues.

Towards #24311. Split from #24926 review. F32 codegen: #24933.

Setup

  • Board: SpaceMiT X60, 8 cores @ 1600 MHz, VLEN=256 (v / zve64d / zvfh)

  • Tool: iree-benchmark-module, --benchmark_repetitions=10

  • Metric: BM_matmul/process_time/real_time_mean Time (wall ms). Ratio = inner_tiled / ukernel. Also record CPU/wall as a threading sanity check (~1 at 1 thread, rising toward 4 and 8).

  • Thread sweep, matched compile + runtime:

    threads compile run
    1 --iree-llvmcpu-disable-distribution=true --device=local-sync
    4 --iree-llvmcpu-number-of-threads=4 --device=local-task --task_topology_group_count=4
    8 --iree-llvmcpu-number-of-threads=8 --device=local-task --task_topology_group_count=8
  • Shared compile flags (same triple/abi/features on both paths):

    • inner_tiled: --iree-opt-data-tiling --iree-llvmcpu-enable-ukernels=none --iree-llvmcpu-enable-inner-tiled=true
    • ukernel: --iree-opt-data-tiling --iree-llvmcpu-enable-ukernels=all --iree-llvmcpu-enable-inner-tiled=false
  • Features: +m,+a,+f,+d,+c,+v,+zvl256b plus the dtype extras

  • Shapes: 64×64×64, 256×256×256, 81×41×19, 540×516×332

Children

Standing

Cells are 1 / 4 / 8 thread ratios (ukernel wall / inner_tiled wall). >1 means inner_tiled is faster. the f32 row is a re-run after the per-K accumulator insert/extract left the inner loop.

dtype small 64³ medium 256³ rect 81×41×19 large 540×516×332 notes
f32 1.66 / 1.06 / 1.12× 1.21 / 1.04 / 0.96× 1.88 / 1.24 / 1.05× 1.26 / 0.77 / 0.64× f32 vfmacc.vf (intrinsics_m = 6). 1-thread wins (large 26.4 vs 33.2 ms). 4/8-thread large still behind: 11.2 / 9.39 ms vs ukernel 8.57 / 6.00. Distribution tiles stay 1
f16 native 1.49 / 0.88 / 0.87× 1.75 / 0.36 / 0.34× 1.46 / 1.05 / 0.93× 1.78 / 0.36 / 0.40× +zvfh, f16 vfmacc (intrinsics_m = 14). 1-thread wins. 4-thread large wall 19.6 ms vs 13.6 ms at 1 thread. Ukernel often widens to f32
f16 VFWMACC 1.43 / 0.91 / 0.95× 1.15 / 0.37 / 0.41× 1.74 / 1.14 / 1.05× 1.42 / 0.36 / 0.41× +zvfh, vfwmacc into f32 (intrinsics_m = 7). Closer ukernel match. 1-thread wins. 4-thread large wall 23.1 ms vs 19.8 ms at 1 thread
f16 CASTF32 0.83 / 1.13 / 1.02× 0.76 / 0.66 / 0.62× 0.93 / 1.02 / 1.13× 0.74 / 0.76 / 0.89× +zvfhmin only, extf then f32 vfmacc (intrinsics_m = 6). Not the +zvfh f32-acc path. Medium/large behind. Large scales 222 → 32.8 ms
f16 WIDENF32 0.81 / 1.20 / 1.04× 0.75 / 0.75 / 0.70× 0.79 / 1.05 / 1.05× 0.73 / 0.85 / 0.99× +zvfhmin only, f16 acc via f32 vfmacc (intrinsics_m = 6). Large 8-thread ~parity (0.99×). Medium stays behind
bf16
i8

Activity

  1. egebeysel commented on Sep 17, 2026

    @egebeysel
    Contributor

    Thanks for the initial PR on F32 and the performance numbers!

    Could you maybe briefly take a look at why we're leaving so much performance on the table and try and reason about it? I don't think the unrolling factor of 6 (inner_tiled) vs 7 (mmt4d) is the reason for it. It might be related to the memory layout transformation ops pack -> expand (-> transpose) or (transpose ->) collapse -> unpack not being vectorized and being scalarized as well.

    I see that we're utilizing vector.scalable.insert/extract and some broadcast instructions while lowering the inner_tiled op to the intrinsics. There might be something related to that causing the inefficiencies. Could you take a look at the generated assembly for a matmul example and try and reason about it maybe?

  2. TMahlatini commented on Sep 18, 2026

    @TMahlatini
    ContributorAuthor

    I will dig into it and share an update soon

  3. TMahlatini commented on Sep 28, 2026

    @TMahlatini
    ContributorAuthor

    @egebeysel I noted my findings from the disassembly here: #24933 (comment)

  4. egebeysel commented on Oct 7, 2026

    @egebeysel
    Contributor

    Hmm, it's a bit odd to have 1.26 / 0.77 / 0.64× for the large case. Maybe we should take a look at this, because this might actually come from some tile size selection heuristic for the distribution tiles that is very ineffective for the inner_tiled case in comparison to the mmt4d ones. I wouldn't expect scaling problems otherwise 🤔

  5. TMahlatini commented on Oct 7, 2026

    @TMahlatini
    ContributorAuthor

    Yeah your read is right.setRootConfig for iree_codegen.inner_tiled sets every parallel distribution tile to 1. getMmt4dLoweringConfig still picks M1/N1 divisors under the 256 KiB budget, and both paths then go through the same workgroup split. That tile is the 4/8-thread large drop.

    I'll file a separate issue to port that cost model onto inner_tiled.

  6. shuangjuliu commented on Nov 3, 2026

    @shuangjuliu

    @egebeysel
    I have created a PR to port that cost model onto inner_tiled.

    Related PR: #25130

  7. added 2 commits that reference this issue on Nov 9, 2026
  8. added a commit that references this issue on Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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