Skip to content

[CPU][RISC-V] SpaceMiT IME vmadot no longer selected for an M=1 QDQ matmul #25338

In progress

Description

@mkovacevic99

What happened?

Compiling the reproducer below with +xsmtvdot,+zvl1024b and --iree-opt-data-tiling now produces 0 vmadot in the generated assembly. A build from 10 Nov produces 4.

Steps to reproduce your issue

  1. Save the IR below as qdq_matmul_m1.linalg.mlir
  2. Command:
iree-compile qdq_matmul_m1.linalg.mlir -o m.vmfb \
  --iree-hal-target-device=local --iree-hal-local-target-device-backends=llvm-cpu \
  --iree-llvmcpu-target-triple=riscv64-unknown-linux-gnu --iree-llvmcpu-target-abi=lp64d \
  --iree-llvmcpu-target-cpu=generic-rv64 \
  --iree-llvmcpu-target-cpu-features=+m,+a,+f,+d,+c,+v,+zvl1024b,+xsmtvdot \
  --iree-opt-data-tiling --iree-hal-dump-executable-files-to=dump
  1. grep -c vmadot dump/*.s (prints 0; expected 4)
// qdq_matmul_m1.mlir after the ONNX/torch input conversion (iree-compile --compile-to=input,
// nightly 3.15.0rc20261123), tidied to a plain func: for IREE builds without the torch frontend.
// One decode-shaped QDQ int8 matmul: x [1,1,512] f32 -> Q/DQ -> batch_matmul with DQ(w [512,512] s8) -> Q/DQ.
#id3 = affine_map<(d0, d1, d2) -> (d0, d1, d2)>
#s3 = affine_map<(d0, d1, d2) -> ()>
#id2 = affine_map<(d0, d1) -> (d0, d1)>
#s2 = affine_map<(d0, d1) -> ()>
func.func @main(%x: tensor<1x1x512xf32>, %w: tensor<512x512xi8>) -> tensor<1x1x512xf32> {
  %zero = arith.constant 0.000000e+00 : f32
  %xs = arith.constant 2.000000e-02 : f32
  %ws = arith.constant 1.000000e-03 : f32
  %ys = arith.constant 5.000000e-02 : f32
  %e8 = tensor.empty() : tensor<1x1x512xi8>
  %ef = tensor.empty() : tensor<1x1x512xf32>
  %xq = iree_linalg_ext.quantize_affine <indexing_maps = [#id3, #s3, #id3], quant_min = -128, quant_max = 127> ins(%x, %xs : tensor<1x1x512xf32>, f32) outs(%e8 : tensor<1x1x512xi8>) -> tensor<1x1x512xi8>
  %xdq = iree_linalg_ext.dequantize_affine <indexing_maps = [#id3, #s3, #id3], quant_min = -128, quant_max = 127> ins(%xq, %xs : tensor<1x1x512xi8>, f32) outs(%ef : tensor<1x1x512xf32>) -> tensor<1x1x512xf32>
  %ew = tensor.empty() : tensor<512x512xf32>
  %wdq = iree_linalg_ext.dequantize_affine <indexing_maps = [#id2, #s2, #id2], quant_min = -128, quant_max = 127> ins(%w, %ws : tensor<512x512xi8>, f32) outs(%ew : tensor<512x512xf32>) -> tensor<512x512xf32>
  %eb = tensor.empty() : tensor<1x512x512xf32>
  %wb = linalg.generic {indexing_maps = [affine_map<(d0, d1, d2) -> (d1, d2)>, #id3], iterator_types = ["parallel", "parallel", "parallel"]} ins(%wdq : tensor<512x512xf32>) outs(%eb : tensor<1x512x512xf32>) {
  ^bb0(%in: f32, %out: f32):
    linalg.yield %in : f32
  } -> tensor<1x512x512xf32>
  %acc = linalg.fill ins(%zero : f32) outs(%ef : tensor<1x1x512xf32>) -> tensor<1x1x512xf32>
  %mm = linalg.batch_matmul ins(%xdq, %wb : tensor<1x1x512xf32>, tensor<1x512x512xf32>) outs(%acc : tensor<1x1x512xf32>) -> tensor<1x1x512xf32>
  %yq = iree_linalg_ext.quantize_affine <indexing_maps = [#id3, #s3, #id3], quant_min = -128, quant_max = 127> ins(%mm, %ys : tensor<1x1x512xf32>, f32) outs(%e8 : tensor<1x1x512xi8>) -> tensor<1x1x512xi8>
  %y = iree_linalg_ext.dequantize_affine <indexing_maps = [#id3, #s3, #id3], quant_min = -128, quant_max = 127> ins(%yq, %ys : tensor<1x1x512xi8>, f32) outs(%ef : tensor<1x1x512xf32>) -> tensor<1x1x512xf32>
  return %y : tensor<1x1x512xf32>
}

What component(s) does this issue relate to?

Compiler

Version information

Works: 957e6b5 (4 vmadot)
Broken: 3a74322 (0 vmadot), #25099

Additional context

This worked before #25099 (addresses #25034). Narrow-M IME tiles (M0=8/4) were added in #24769 for narrow-M workloads, and this M=1 case no longer gets them. I'm happy to work on a fix; guidance on the preferred direction is welcome.

After data tiling, the working build has an 8-row block (batch_mmt4d, M0 = 8), and the broken one has a 1-row block (mmt4d, M0 = 1).

The changes in the mentioned commit added a pass that removes size-1 loops right after the quantize-to-integer rewrite. Just before it, there are 4 loops (1x1x512 and 1x512x512). Just after it, it has 2 (512 and 512x512). I tried locally to delete only that pass call and it brings the 4 vmadot back.

@Manewing since you are the author of this commit that I'm mentioning, could you maybe take a look at this issue and give some guidance. Thanks!

I used Claude in the process of understanding the issue and narrowing down to what caused the issue, but I review everything myself and ran all the commands.

Activity

  1. added
    bug 🐞
    on Nov 26, 2026
  2. github-actions commented on Nov 26, 2026

    @github-actions

    Hello @mkovacevic99 👋

    Thank you for submitting an issue to IREE! It looks like it's your first one.

    The volume of issues is huge, and triage times may vary. If you need quicker assistance on the issue, consider posting it on IREE Discord and providing short context there.
    Feel free to identify the most frequent contributors to the corresponding part of the codebase via Git history/CODEOWNERS and (gently!) tag them below.


    Action required: acknowledge IREE project policies

    IREE is a Linux Foundation project. All participants are expected to follow the LF Projects Code of Conduct.

    Please note that all contributions to IREE, including GitHub issues, must follow our IREE AI Tool Use Policy. This means:

    • Issue reporters must fully understand the primary issue and the impact of the problem.
      For bug reports, specifics of the use-case, workflow and/or crash scenario usually suffice.
      For improvement suggestions, this usually implies deeper understanding of suboptimal code, IR design choices, assumed performance tradeoffs, etc.
    • Contributors must write the summary of the issue themselves, so that the exact impact and scenario is clear to other participants.
    • Issue authors are expected to review and understand all LLM/AI-assisted segments of the report, if any. E.g.: CLI commands and IR reproducers, model/framework details, lowering pipeline details, assumptions about problematic behaviors of IREE components.
    • Substantial use of LLM/generative AI tools must be disclaimed in the header or footer of the issue description.

    Before the issue can be triaged, we kindly ask you to reply to this message and confirm that you understand and accept the proposed policy. As required, please adjust your initial issue description.


    If you have any questions, feel free to leave a comment here, or ask away on IREE Discord.

    Thank you,
    The IREE Community

  3. mkovacevic99 commented on Nov 26, 2026

    @mkovacevic99
    ContributorAuthor

    Hello @mkovacevic99 👋

    Thank you for submitting an issue to IREE! It looks like it's your first one.

    The volume of issues is huge, and triage times may vary. If you need quicker assistance on the issue, consider posting it on IREE Discord and providing short context there. Feel free to identify the most frequent contributors to the corresponding part of the codebase via Git history/CODEOWNERS and (gently!) tag them below.

    Action required: acknowledge IREE project policies

    IREE is a Linux Foundation project. All participants are expected to follow the LF Projects Code of Conduct.

    Please note that all contributions to IREE, including GitHub issues, must follow our IREE AI Tool Use Policy. This means:

    • Issue reporters must fully understand the primary issue and the impact of the problem.
      For bug reports, specifics of the use-case, workflow and/or crash scenario usually suffice.
      For improvement suggestions, this usually implies deeper understanding of suboptimal code, IR design choices, assumed performance tradeoffs, etc.
    • Contributors must write the summary of the issue themselves, so that the exact impact and scenario is clear to other participants.
    • Issue authors are expected to review and understand all LLM/AI-assisted segments of the report, if any. E.g.: CLI commands and IR reproducers, model/framework details, lowering pipeline details, assumptions about problematic behaviors of IREE components.
    • Substantial use of LLM/generative AI tools must be disclaimed in the header or footer of the issue description.

    Before the issue can be triaged, we kindly ask you to reply to this message and confirm that you understand and accept the proposed policy. As required, please adjust your initial issue description.

    If you have any questions, feel free to leave a comment here, or ask away on IREE Discord.

    Thank you, The IREE Community

    I understand and accept the policy

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

    bug 🐞

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions