Skip to content

[BugFix][Arith] Reject cyclic floormod normalization in bijective maps - #67

Open
SiriusNEO wants to merge 1 commit into
tilelang_mainfrom
codex/fix-cyclic-floormod-inverse
Open

SiriusNEO wants to merge 1 commit into
tilelang_mainfrom
codex/fix-cyclic-floormod-inverse

Conversation

@SiriusNEO

Copy link
Copy Markdown
Collaborator

Summary

  • Prevent DetectIterMap(..., Bijective) from silently normalizing a shifted modulo expression to an unshifted one when the offset has a non-zero modulo phase.
  • Reject the unsupported cyclic rotation instead of returning an IterMap that InverseAffineIterMap would invert incorrectly.
  • Preserve existing behavior for offsets divisible by the modulus and for padding-aware non-bijective simplification.

Related to tile-ai/tilelang#2948 and tile-ai/tilelang#3090.

Root cause

VisitExpr_(AddNode) stores the offset in IterSumExpr::base. SplitFloorModConst computes that phase as pair.second, but the bijective path has no padded IterMark carrying it and returns only pair.first. The resulting normalized map is therefore semantically different:

(x + 1) % 128  ->  x

InverseAffineIterMap then sees an unshifted split and produces x = output.

Validation

Before the fix, the regression test failed because the cyclic shift produced one accepted bijective index.

After the fix:

  • cmake --build build -j 32
  • PYTHONPATH=$PWD/python TVM_LIBRARY_PATH=$PWD/build python3 -m pytest -q -p no:tvm.testing.plugin tests/python/arith/test_arith_iter_affine_map.py — 40 passed
  • python3 -m ruff check tests/python/arith/test_arith_iter_affine_map.py
  • python3 -m ruff format --check tests/python/arith/test_arith_iter_affine_map.py
  • clang-format --dry-run --Werror src/arith/iter_affine_map.cc
  • git diff --check

The repository-wide ASF-header pre-commit hook reports 11 pre-existing missing headers outside this change; all relevant formatting and lint hooks pass.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant