diff --git a/tests/unit/test_fmha_v3_stage_c.py b/tests/unit/test_fmha_v3_stage_c.py index 76f78aa2..6c2b74ed 100644 --- a/tests/unit/test_fmha_v3_stage_c.py +++ b/tests/unit/test_fmha_v3_stage_c.py @@ -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)