-
Notifications
You must be signed in to change notification settings - Fork 552
[BugFix] Consider non-local store in external call and SIMT producer for warp specialize #2166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Rachmanino
wants to merge
3
commits into
tile-ai:main
Choose a base branch
from
Rachmanino:fix/call-extern-parallel-and-simt-barrier
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+140
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,6 +114,34 @@ def main( | |
| return main | ||
|
|
||
|
|
||
| def explicit_cp_async_wait_position(iters=4, block=16, cp_elems=8, dtype="float16", threads=128): | ||
| """A mixed TMA + explicit cp.async pipeline with cp.async consumed first.""" | ||
|
|
||
| @T.prim_func | ||
| def main( | ||
| A: T.Buffer((iters, block), dtype), | ||
| B: T.Buffer((iters, cp_elems), dtype), | ||
| B_out: T.Buffer((iters,), dtype), | ||
| A_out: T.Buffer((iters, block), dtype), | ||
| ): | ||
| with T.Kernel(1, threads=threads) as _: | ||
| A_shared = T.alloc_shared((block,), dtype) | ||
| B_shared = T.alloc_shared((cp_elems,), dtype) | ||
|
|
||
| for ko in T.Pipelined(iters, num_stages=2): | ||
| T.ptx_cp_async( | ||
| T.access_ptr(B_shared[0], "w", cp_elems), | ||
| T.access_ptr(B[ko, 0], "r", cp_elems), | ||
| cp_elems, | ||
| ) | ||
| T.copy(A[ko, 0], A_shared) | ||
| B_out[ko] = B_shared[0] | ||
| for i in T.Parallel(block): | ||
| A_out[ko, i] = A_shared[i] | ||
|
|
||
| return main | ||
|
|
||
|
|
||
| def grouped_gemm_padded_pipelined( | ||
| batch_sizes, | ||
| K, | ||
|
|
@@ -431,6 +459,27 @@ def test_tiled_ws_sinks_preloop_tma_waits_into_consumer(): | |
| assert k_load < v_load < branch < first_wait | ||
|
|
||
|
|
||
| def test_tiled_ws_explicit_cp_async_wait_precedes_first_consumer_read(): | ||
| """Explicit cp.async destinations must pull the consumer wait earlier.""" | ||
|
|
||
| func = explicit_cp_async_wait_position().with_attr("global_symbol", "main") | ||
| mod = tvm.IRModule.from_expr(func) | ||
| mod = tvm.tir.transform.BindTarget(tvm.target.Target("cuda -arch=sm_90"))(mod) | ||
| mod = tilelang.transform.ProducerConsumerWarpSpecialized()(mod) | ||
| script = mod["main"].script() | ||
|
|
||
| assert "tl_tiled_ws_applied" in script | ||
| assert "T.ptx_cp_async" in script | ||
| assert "T.tma_copy" in script | ||
|
|
||
| consumer_branch = _find_after(script, "else:") | ||
| wait = _find_after(script, "T.mbarrier_wait_parity", consumer_branch) | ||
| cp_async_read = _find_after(script, "B_out[ko] = B_shared[0]", consumer_branch) | ||
| tma_read = _find_after(script, "A_out[ko, i] = A_shared", consumer_branch) | ||
|
|
||
| assert wait < cp_async_read < tma_read | ||
|
|
||
|
Comment on lines
+462
to
+481
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add required CUDA test decorators. The test is missing decorators that are present on all other CUDA tests in this file. Without them, the test will attempt to run on non-CUDA systems and fail. 🔧 Proposed fix+@tilelang.testing.requires_cuda
+@tilelang.testing.requires_cuda_compute_version(9, 0)
def test_tiled_ws_explicit_cp_async_wait_precedes_first_consumer_read():
"""Explicit cp.async destinations must pull the consumer wait earlier."""🤖 Prompt for AI Agents |
||
|
|
||
| @tilelang.testing.requires_cuda | ||
| @tilelang.testing.requires_cuda_compute_version(9, 0) | ||
| def test_tiled_ws_keeps_shared_prelude_local_vars_for_grouped_gemm(): | ||
|
|
@@ -468,5 +517,6 @@ def test_tiled_ws_does_not_clone_local_var_into_producer_branch(): | |
| test_tiled_ws_swizzled_layout_allows_ws() | ||
| test_tiled_ws_incompatible_layout_blocks_ws() | ||
| test_tiled_ws_sinks_preloop_tma_waits_into_consumer() | ||
| test_tiled_ws_explicit_cp_async_wait_precedes_first_consumer_read() | ||
| test_tiled_ws_keeps_shared_prelude_local_vars_for_grouped_gemm() | ||
| test_tiled_ws_does_not_clone_local_var_into_producer_branch() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.