Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/transform/warp_specialized_rewriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,23 @@ class WSCodeEmitter : public StmtMutator {
: parity_;
block_stmt.push_back(makeParityWait(acquire_barrier_id, parity));
}
ICHECK(!map.release[i].empty());
// It is possible that a producer does not participate in any
// producer-consumer dependency that requires synchronization.
// In that case, there will be no associated release pattern.
// We should still emit the (optionally guarded) statement without
// inserting any mbarrier for it instead of failing.
if (map.release[i].empty()) {
LOG(WARNING) << "Producer doesn't have corresponding consumer: "
<< seq_transformed[i];
block_stmt.push_back(seq_transformed[i]);
new_body.push_back(
MakeGroupBlock(block_stmt.size() == 1
? block_stmt[0]
// NOLINTNEXTLINE(performance-move-const-arg)
: SeqStmt(std::move(block_stmt)),
annotations));
continue;
}
for (size_t j = 0; j < map.release[i].size(); j++) {
int pattern_idx = map.release[i][j];
PrimExpr release_barrier_id =
Expand Down
32 changes: 32 additions & 0 deletions testing/python/issue/test_tilelang_issue_1263.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import tilelang.testing
import tilelang.language as T


def test_issue_1263_pipeline_no_consumer():
@tilelang.jit()
def test_kernel(M, N):
dtype = "bfloat16"

@T.prim_func
def fwd_main(
KV: T.Tensor((M, N), dtype),
ids: T.Tensor((4,), "int32"),
ids2: T.Tensor((4,), "int32"),
):
with T.Kernel(4, threads=1):
A = T.alloc_shared([N], dtype)
B = T.alloc_shared([N], dtype)

for i in T.Pipelined(4, num_stages=1):
id = ids[i]
id2 = ids2[id]
T.copy(KV[id2, :], A)
T.clear(B)

return fwd_main

test_kernel(1024, 128)


if __name__ == "__main__":
tilelang.testing.main()
Loading