Skip to content

[LLVMCPU] Lowering strategy selection is non-deterministic for a decomposed softmax #25258

Open

Description

@Manewing

What happened?

Compiling the same input repeatedly with the same iree-compile gives two different results. The vector_common_parallel tile size that iree-llvmcpu-select-lowering-strategy picks for the first loop of the softmax dispatch alternates between runs.

Steps to reproduce your issue

softmax.mlir:

func.func @softmax(%x: tensor<1x10xf32>) -> tensor<1x10xf32> {
  %empty = tensor.empty() : tensor<1x10xf32>
  %r = linalg.softmax dimension(1)
      ins(%x : tensor<1x10xf32>) outs(%empty : tensor<1x10xf32>) -> tensor<1x10xf32>
  return %r : tensor<1x10xf32>
}
for i in $(seq 1 12); do
  iree-compile softmax.mlir \
    --iree-hal-target-device=local \
    --iree-hal-local-target-device-backends=llvm-cpu \
    --iree-llvmcpu-target-triple=x86_64-unknown-linux-gnu \
    --iree-llvmcpu-target-cpu=haswell \
    --compile-to=executable-configurations -o - | shasum
done | sort | uniq -c

Output (two different results, about half of the runs each):

   6 327d42b2...
   6 fbf2fdad...

The two outputs differ only in the lowering configs of the softmax dispatch. One run:

%5 = linalg.fill {lowering_config = #iree_cpu.lowering_config<vector_common_parallel = [8]>} ...
%6 = linalg.generic ... {lowering_config = #iree_cpu.lowering_config<vector_common_parallel = [8, 0], vector_reduction = [0, 8]>}
%7 = linalg.fill {lowering_config = #iree_cpu.lowering_config<vector_common_parallel = [8]>} ...

Another run:

%5 = linalg.fill {lowering_config = #iree_cpu.lowering_config<vector_common_parallel = [1]>} ...
%6 = linalg.generic ... {lowering_config = #iree_cpu.lowering_config<vector_common_parallel = [1, 0], vector_reduction = [0, 8]>}
%7 = linalg.fill {lowering_config = #iree_cpu.lowering_config<vector_common_parallel = [1]>} ...

The same happens with --iree-llvmcpu-target-cpu=host on an Apple M4 ([4] vs [1]) and with --iree-llvmcpu-target-triple=aarch64-unknown-linux-gnu --iree-llvmcpu-target-cpu=cortex-a76. With --compile-to=executable-sources the output is the same on every run.

tests/e2e/stablehlo_models/mnist_fake_weights.mlir shows it too, in its softmax dispatch; its .vmfb differs between runs.

What component(s) does this issue relate to?

Compiler

Version information

main at 957e6b5, built from source on macOS (arm64), release build.

Additional context

No response

Activity

  1. yashb98 commented on Nov 17, 2026

    @yashb98

    Hi @Manewing, is anyone already working on this? Local checks on an ARM64 host with the November 17 nightly (8953bcf) reproduce the changing vector_common_parallel sizes for both Haswell and Cortex-A76 targets. The executable-sources output stayed identical in 16 runs per target. Final VMFB files were also stable in 16 runs per input and target for softmax and MNIST. I'd like to investigate the ordering of equal-priority candidates in fillTileSizesWithNonRootOps, while preserving the existing PackOp priority.
    Would that be a useful direction to take?

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