-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Fix SM120/SM121 (consumer Blackwell) codegen: no tensor memory pipeline #9852
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
Closed
mihai-chiorean
wants to merge
2
commits into
triton-lang:main
from
mihai-chiorean:fix/sm121-consumer-blackwell-support
+21
−4
Closed
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -96,9 +96,26 @@ def file_hash(path): | |
| return hashlib.sha256(f.read()).hexdigest() | ||
|
|
||
|
|
||
| def _has_tensor_memory(capability: int) -> bool: | ||
| """Return True for architectures with tensor memory (tcgen05). | ||
|
|
||
| Only datacenter Blackwell (SM100/SM103, arch family 10) has tensor memory. | ||
| Consumer Blackwell (SM120/SM121, arch family 12) does NOT have tensor memory | ||
| and must not use the tensor memory pipeline or the "a" arch suffix. | ||
| """ | ||
| arch_family = capability // 10 | ||
| return arch_family == 10 | ||
|
|
||
|
|
||
| def sm_arch_from_capability(capability: int): | ||
| # TODO: Handle non-"a" sms | ||
| suffix = "a" if capability >= 90 else "" | ||
| # SM120/SM121 (consumer Blackwell) lack tensor memory features | ||
| # that the "a" suffix enables. Only give "a" to SM >= 90 that | ||
| # actually have the corresponding accelerator features. | ||
| arch_family = capability // 10 | ||
| if capability >= 90 and arch_family != 12: | ||
| suffix = "a" | ||
| else: | ||
| suffix = "" | ||
| return f"sm_{capability}{suffix}" | ||
|
|
||
|
|
||
|
|
@@ -285,7 +302,7 @@ def make_ttgir(mod, metadata, opt, capability): | |
| passes.ttgpuir.add_assign_latencies(pm, opt.num_stages) | ||
| passes.ttgpuir.add_schedule_loops(pm) | ||
| passes.ttgpuir.add_pipeline(pm, opt.num_stages, dump_enabled) | ||
| elif capability // 10 >= 10: | ||
| elif _has_tensor_memory(capability): | ||
|
Collaborator
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. I don't think this is right, going through that path for sm_120 shoul be fine |
||
| passes.ttgpuir.add_fuse_nested_loops(pm) | ||
| passes.common.add_canonicalizer(pm) | ||
| passes.ttir.add_triton_licm(pm) | ||
|
|
@@ -467,7 +484,7 @@ def make_ptx(self, src, metadata, opt, capability): | |
| # post-process | ||
| ptx_version = f'{ptx_version//10}.{ptx_version%10}' | ||
| ret = re.sub(r'\.version \d+\.\d+', f'.version {ptx_version}', ret, flags=re.MULTILINE) | ||
| ret = re.sub(r'\.target sm_\d+', f'.target sm_{capability}', ret, flags=re.MULTILINE) | ||
| ret = re.sub(r'\.target sm_\d+a?', f'.target sm_{capability}', ret, flags=re.MULTILINE) | ||
| if not knobs.compilation.dump_ir_extract_di_local_variables: | ||
| # Remove the debug flag that prevents ptxas from optimizing the code | ||
| # Note: if this flag is removed, the source var name and type info will be lost when ptx was compiled into cubin | ||
|
|
||
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.
we revert the patch because this was incorrect so not sure why you are adding it back