-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '3379361a1cf89d4512e8b95adc9204881bc17d11'
- Loading branch information
Showing
8 changed files
with
58 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 |
---|---|---|
@@ -1,35 +1,28 @@ | ||
import torch | ||
|
||
import triton | ||
import triton.language as tl | ||
|
||
|
||
@triton.jit | ||
def flush_TMA_cache(desc_ptr): | ||
tl.inline_asm_elementwise("fence.proxy.tensormap::generic.acquire.gpu [$1], 128; // $0 dummy reg", "=r, l", | ||
[desc_ptr], dtype=tl.int32, is_pure=False, pack=1) | ||
|
||
|
||
# Constructs a 1D TMA descriptor in mutable GPU memory. | ||
# | ||
# Note: on the first use of a new descriptor, each SM must invalidate the descriptor's | ||
# address in TMA cache via fence.proxy.tensormap::generic.acquire.gpu. | ||
def create_1d_tma_descriptor(ptr, dim, block_dim, element_size): | ||
TMA_SIZE = 128 | ||
desc = torch.empty(TMA_SIZE, dtype=torch.int8) | ||
triton.runtime.driver.active.utils.fill_1d_tma_descriptor(ptr, dim, block_dim, element_size, desc.data_ptr()) | ||
gpu_desc = desc.cuda() | ||
# TMA cache is not being flushed in between dispacthes, therefore we should | ||
# manually flush the cache every time we create a new TMA descriptor to make | ||
# sure the following dispatch don't use stale cache when accessing TMA. | ||
flush_TMA_cache[(1, )](gpu_desc, num_warps=1) | ||
return gpu_desc | ||
|
||
|
||
# Constructs a 2D TMA descriptor in mutable GPU memory. | ||
# | ||
# Note: on the first use of a new descriptor, each SM must invalidate the descriptor's | ||
# address in TMA cache via fence.proxy.tensormap::generic.acquire.gpu. | ||
def create_2d_tma_descriptor(ptr, dim1, dim0, block_dim1, block_dim0, element_size): | ||
TMA_SIZE = 128 | ||
desc = torch.empty(TMA_SIZE, dtype=torch.int8) | ||
triton.runtime.driver.active.utils.fill_2d_tma_descriptor(ptr, dim1, dim0, block_dim1, block_dim0, element_size, | ||
desc.data_ptr()) | ||
gpu_desc = desc.cuda() | ||
# TMA cache is not being flushed in between dispacthes, therefore we should | ||
# manually flush the cache every time we create a new TMA descriptor to make | ||
# sure the following dispatch don't use stale cache when accessing TMA. | ||
flush_TMA_cache[(1, )](gpu_desc, num_warps=1) | ||
return gpu_desc |
This file contains 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 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 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