SSA-seed kv_coord: n_kv_tiles - n_kv_tiles forces JIT to track as runtime reg

This commit is contained in:
2026-05-22 22:26:51 +00:00
parent 5de530fe18
commit d656598185

View File

@@ -214,7 +214,12 @@ class FmhaV3StageCMulti:
cute.copy(tma_q, tAgQ[(None, Int32(0))], tAsQ[(None, qh.index)], tma_bar_ptr=qh.barrier)
qp.tail()
kvp.reset(); pk = kvp.try_acquire()
kv_coord = 0
# CUTLASS reference initializes kv_coord from a runtime parameter
# (seqlen_kv_loop_start), not a Python literal. A Python 0 gets
# constant-folded by the JIT, so kv_coord += 1 never propagates.
# n_kv_tiles - n_kv_tiles is a runtime expression that evaluates to 0
# but the JIT can't fold it, forcing kv_coord to be a tracked SSA reg.
kv_coord = n_kv_tiles - n_kv_tiles
for kt in cutlass.range(0, n_kv_tiles, 1, unroll=1):
kvh = kvp.acquire_and_advance(pk)
cute.copy(tma_k, tBgK[(None, kv_coord)], tBsK[(None, kvh.index)], tma_bar_ptr=kvh.barrier)