Repository navigation
[Feature] Support cluster launch, query, synchronization and barrier operations #1874
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e22e876
support cluster launch for tvm_ffi and cython backend
Rachmanino 2f0e642
lint
Rachmanino e5c1ec7
add test
Rachmanino 7c3a425
lint
Rachmanino 13e3d20
update tvm
Rachmanino acfaf3f
Add cluster synchronization operations and related functions
Rachmanino f5c4848
add test for intrinsics
Rachmanino c8612dc
lint
Rachmanino 8aa3a2b
remove legacy code
Rachmanino edd8f50
Add cluster barrier support and related functionality
Rachmanino e94be2c
lint
Rachmanino 1bcc3a3
fix typo
Rachmanino de0b7ff
add storage sync for cluster
Rachmanino 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
add test
- Loading branch information
commit e5c1ec70d99cbf2a29b7e232da3d486c4f14e47e
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
testing/python/language/test_tilelang_language_cluster_launch.py
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 |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import tilelang | ||
| import tilelang.language as T | ||
| import torch | ||
| import tilelang.testing | ||
|
|
||
|
|
||
| def matmul(M, N, K, block_M, block_N, block_K, dtype=T.float16, accum_dtype=T.float32): | ||
| @T.prim_func | ||
| def gemm( | ||
| A: T.Tensor((M, K), dtype), | ||
| B: T.Tensor((K, N), dtype), | ||
| C: T.Tensor((M, N), dtype), | ||
| ): | ||
| with T.Kernel(T.ceildiv(N, block_N), T.ceildiv(M, block_M), threads=128, cluster_dims=(2, 1, 1)) as (bx, by): | ||
| A_shared = T.alloc_shared((block_M, block_K), dtype) | ||
| B_shared = T.alloc_shared((block_K, block_N), dtype) | ||
| C_local = T.alloc_fragment((block_M, block_N), accum_dtype) | ||
|
|
||
| T.clear(C_local) | ||
| for k in T.Pipelined(T.ceildiv(K, block_K), num_stages=3): | ||
| T.copy(A[by * block_M, k * block_K], A_shared) | ||
| T.copy(B[k * block_K, bx * block_N], B_shared) | ||
| T.gemm(A_shared, B_shared, C_local) | ||
|
|
||
| T.copy(C_local, C[by * block_M, bx * block_N]) | ||
|
|
||
| return gemm | ||
|
|
||
|
|
||
| def run_cython_cluster_launch(): | ||
| kernel = matmul(1024, 1024, 1024, 128, 128, 32) | ||
| mod = tilelang.compile(kernel, execution_backend="cython") | ||
| assert 'clusterDim = {2, 1, 1}' in mod.get_host_source() | ||
|
|
||
|
|
||
| def run_tvm_ffi_cluster_launch(): | ||
| kernel = matmul(1024, 1024, 1024, 128, 128, 32) | ||
| mod = tilelang.compile(kernel, execution_backend="tvm_ffi") | ||
| check_str = r""" | ||
| (((TVMFFIAny*)stack_ffi_any)[3].type_index) = 1; | ||
| (((TVMFFIAny*)stack_ffi_any)[3].zero_padding) = 0; | ||
| (((TVMFFIAny*)stack_ffi_any)[3].v_int64) = ((int64_t)2); | ||
| (((TVMFFIAny*)stack_ffi_any)[4].type_index) = 1; | ||
| (((TVMFFIAny*)stack_ffi_any)[4].zero_padding) = 0; | ||
| (((TVMFFIAny*)stack_ffi_any)[4].v_int64) = ((int64_t)1); | ||
| (((TVMFFIAny*)stack_ffi_any)[5].type_index) = 1; | ||
| (((TVMFFIAny*)stack_ffi_any)[5].zero_padding) = 0; | ||
| (((TVMFFIAny*)stack_ffi_any)[5].v_int64) = ((int64_t)1); | ||
| """ | ||
| assert check_str in mod.get_host_source() | ||
|
|
||
|
|
||
| @tilelang.testing.requires_cuda | ||
| @tilelang.testing.requires_cuda_compute_version_ge(9, 0) | ||
| def test_cluster_launch(): | ||
| run_cython_cluster_launch() | ||
| run_tvm_ffi_cluster_launch() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| test_cluster_launch() | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make host-source assertions less formatting-fragile.
The current checks are tightly coupled to exact whitespace/layout, especially the multiline TVM FFI snippet, so harmless codegen formatting changes can fail the test.
Proposed refactor
🤖 Prompt for AI Agents