Summary
A unit-dependent tile() bound that multiplies a mesh coordinate by a constant floor-division, e.g. cta.x * (M // BX), makes parsing recurse until RecursionError. The same bound written with the quotient precomputed (cta.x * CHUNK_M, CHUNK_M = M // BX) or as a literal (cta.x * 128) parses fine. All three are the same program.
Reproduction
Start from the repository's own fixture tests/fixtures/placed/persistent_gemm_tiled.py (added in #175) and change only line 38:
# original: parses
for mi in tile(cta.x * CHUNK_M, (cta.x + 1) * CHUNK_M, BM):
# changed: RecursionError
for mi in tile(cta.x * (M // BX), (cta.x + 1) * (M // BX), BM):
# also parses
for mi in tile(cta.x * 128, (cta.x + 1) * 128, BM):
from tilefoundry.cli.source import load_namespace
load_namespace("persistent_gemm_tiled_inline.py") # RecursionError: maximum recursion depth exceeded
M and BX are module-level Python ints (512 and 4), so M // BX is the constant 128.
Traceback (tail, deduplicated)
src/tilefoundry/parser/ast_pattern.py, line 1402, in construct
src/tilefoundry/parser/pattern_nodes.py, line 4076, in construct
src/tilefoundry/ir/isl_interop.py, line 238, in normalize_dim
src/tilefoundry/ir/isl_interop.py, line 172, in dim_to_isl_expr
src/tilefoundry/ir/visitor.py, line 202, in visit
src/tilefoundry/ir/visitor.py, line 271, in dispatch_visit
src/tilefoundry/ir/isl_interop.py, line 127, in visit_Call
src/tilefoundry/ir/isl_interop.py, line 332, in dim_range
src/tilefoundry/ir/isl_interop.py, line 302, in visit_Call
RecursionError: maximum recursion depth exceeded
The cycle is dim_to_isl_expr → visit_Call (isl_interop.py:127) → dim_range (:332) → _DimRangeVisitor.visit_Call (:302, which calls dim_to_isl_expr on the same value) → …, apparently without folding the constant DimFloorDiv first.
Expected
The constant quotient folds (or is bounded) and the loop parses exactly like the CHUNK_M form. If some form is genuinely unsupported, a parse error naming the bound rather than an unbounded recursion.
Workaround
Precompute the quotient at module level (CHUNK_M = M // BX) and use the name in the bound.
Version
TileFoundry main at 53c739d (after #176).
Summary
A unit-dependent
tile()bound that multiplies a mesh coordinate by a constant floor-division, e.g.cta.x * (M // BX), makes parsing recurse untilRecursionError. The same bound written with the quotient precomputed (cta.x * CHUNK_M,CHUNK_M = M // BX) or as a literal (cta.x * 128) parses fine. All three are the same program.Reproduction
Start from the repository's own fixture
tests/fixtures/placed/persistent_gemm_tiled.py(added in #175) and change only line 38:MandBXare module-level Python ints (512 and 4), soM // BXis the constant 128.Traceback (tail, deduplicated)
The cycle is
dim_to_isl_expr→visit_Call(isl_interop.py:127) →dim_range(:332) →_DimRangeVisitor.visit_Call(:302, which callsdim_to_isl_expron the same value) → …, apparently without folding the constantDimFloorDivfirst.Expected
The constant quotient folds (or is bounded) and the loop parses exactly like the
CHUNK_Mform. If some form is genuinely unsupported, a parse error naming the bound rather than an unbounded recursion.Workaround
Precompute the quotient at module level (
CHUNK_M = M // BX) and use the name in the bound.Version
TileFoundry
mainat 53c739d (after #176).