-
Notifications
You must be signed in to change notification settings - Fork 333
Fix various issues under int64_t static and dynamic shape.
#1218
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 all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
64d39ad
Fix various issues under int64_t static and dynamic shape.
Elevator14B 52b0a60
Merge branch 'main' into fix-int64
Elevator14B 527add7
Merge remote-tracking branch 'origin/main' into fix-int64
Elevator14B 412a98c
Resolve reviewed issues.
Elevator14B 3d09215
Merge remote-tracking branch 'origin/main' into fix-int64
Elevator14B dbebd7e
Merge remote-tracking branch 'origin/main' into fix-int64
Elevator14B 4ee7b24
Merge remote-tracking branch 'origin/main' into fix-int64
Elevator14B 7f6efe6
Add unit test.
Elevator14B e273ba3
fix
LeiWang1999 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import tilelang | ||
| import tilelang.language as T | ||
|
|
||
|
|
||
| @tilelang.jit | ||
| def fill_symbolic(value: float, dtype="bfloat16"): | ||
| n = T.symbolic("n", "int64") | ||
| block_n = 512 | ||
|
|
||
| @T.prim_func | ||
| def main(x: T.Tensor[n, dtype]): | ||
| # Initialize Kernel Context | ||
| with T.Kernel(T.ceildiv(n, block_n), threads=128) as bx: | ||
| # Doesn't yet work with int64-shaped global tensor | ||
| # T.fill(x[bx * block_n : (bx + 1) * block_n], value) | ||
| for i in T.Parallel(block_n): | ||
| x[bx * block_n + i] = value | ||
|
|
||
| return main | ||
|
|
||
|
|
||
| def run_fill_symbolic(n: int): | ||
| import torch | ||
|
|
||
| x = torch.zeros(n, dtype=torch.bfloat16, device="cuda") | ||
| fill_symbolic(1.0)(x) | ||
| assert x.min() == 1.0 and x.max() == 1.0 | ||
|
|
||
|
|
||
| def test_fill_symbolic(): | ||
| # Requires 8GB VRAM | ||
| run_fill_symbolic(2**32) | ||
|
|
||
|
|
||
| @tilelang.jit | ||
| def fill_static(n: int, value: float, dtype="bfloat16"): | ||
| block_n = 512 | ||
|
|
||
| @T.prim_func | ||
| def main(x: T.Tensor[n, dtype]): | ||
| # Initialize Kernel Context | ||
| with T.Kernel(T.ceildiv(n, block_n), threads=128) as bx: | ||
| # Doesn't yet work with int64-shaped global tensor | ||
| # T.fill(x[bx * block_n : (bx + 1) * block_n], value) | ||
| for i in T.Parallel(block_n): | ||
| x[bx * block_n + i] = value | ||
|
|
||
| return main | ||
|
|
||
|
|
||
| def run_fill_static(n: int): | ||
| import torch | ||
|
|
||
| x = torch.zeros(n, dtype=torch.bfloat16, device="cuda") | ||
| fill_static(n, 1.0)(x) | ||
| assert x.min() == 1.0 and x.max() == 1.0 | ||
|
|
||
|
|
||
| def test_fill_static(): | ||
| # Requires 8GB VRAM | ||
| run_fill_static(2**32) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| test_fill_symbolic() | ||
| test_fill_static() | ||
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
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.
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.
Prevent OOM and missing-CUDA crashes in the int64 fill tests
run_fill_symbolic/run_fill_staticunconditionally create atorch.zerosbuffer on CUDA and the test invokes them withn = 2**32. On hosts without a CUDA-capable GPU this raises immediately becausetorch.cuda.is_available()is false, and even when a GPU exists the allocation needs ~8.6 GiB for bfloat16 data, which will throwtorch.cuda.OutOfMemoryErroron the default CI machines long before the kernel is exercised.(debuglab.net)Please gate these helpers on CUDA availability and skip when the requested tensor cannot fit into the active device before trying to allocate it. One option is:
This keeps the int64 coverage when the hardware can handle it and lets the suite pass everywhere else.
🤖 Prompt for AI Agents