Skip to content

tvm: decompose reduction initializers after scheduling - #143

Open
guillon wants to merge 4 commits into
xtc-tools:mainfrom
guillon:dev/cguillon/tvm-decompose-reductions
Open

guillon wants to merge 4 commits into
xtc-tools:mainfrom
guillon:dev/cguillon/tvm-decompose-reductions

Conversation

@guillon

@guillon guillon commented Sep 16, 2026

Copy link
Copy Markdown
Member

Motivation

TVM 0.26 keeps reduction initialization inside the update loop, which can prevent LLVM from automatically vectorizing otherwise vectorizable loops and cause significant performance regressions.

Description

Add a final TVM schedule transform that separates reduction initialization from update loops.

Use TVM's decompose_reduction primitive for regular reductions and a structural fallback for reductions hidden below XTC loop-partition scopes. Preserve spatial loop annotations, support cache-write buffers, and leave already externalized reductions unchanged because they no longer contain an initialization statement.

Emit the transform directly in generated TVM schedule fragments and update the corresponding FileCheck expectations.

Commits

  • tvm: decompose reduction initializers

Discussion

This PR is stacked on #142, which itself depends on #133.

TODO:

Testing

  • uv run pytest tests/pytest/tvm -q — 11 passed
  • uv run lit -j 8 tests/filecheck/backends tests/filecheck/schedules tests/filecheck/search — 113 passed, 3 expected failures, 24 unsupported
  • Ruff, Pyright, and Mypy checks on the changed TVM transform code
  • Numerical validation of partitioned reductions with a cache-write buffer
  • make check-format currently reports unrelated pre-existing formatting issues in MlirOps.py and TVMOps.py

@guillon guillon self-assigned this Sep 16, 2026
@guillon

guillon commented Sep 16, 2026

Copy link
Copy Markdown
Member Author

For information @liamsemeria, update such that with TVM 0.26 we hoist 0-initialization correctly.

@guillon guillon added the enhancement New feature or request label Sep 16, 2026
@codecov

codecov Bot commented Sep 16, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant