[BugFix][Carver] Parse lettered SM arch strings in check_sm_version - #2891
Conversation
check_sm_version gated on str.isdigit(), so any arch carrying the trailing
feature-set letter that nvcc and CUTLASS use for Hopper and newer, sm_90a,
sm_100a, sm_103a, fell through to the -1 sentinel instead of parsing to 90,
100 or 103.
Those lettered strings are the real value of target.attrs["arch"], not a
hypothetical one: contrib/nvcc.py already does .rstrip("af") on the same
attribute, contrib/nvrtc.py documents "90a" as valid, and
carver/roller/policy/tensorcore.py compares compute_capability against
"sm_90a" directly. So one path handled the suffix and this one did not.
The -1 then silently corrupted capability dispatch. sm_version feeds
is_volta_arch, is_ampere_arch, is_ada_arch, is_hopper_arch and
has_mma_support, and matmul_analysis compares the same value against 70,
80 and 90. With -1 a real Hopper target failed every one of those checks,
so it was treated as pre-sm_70 and quietly lost its arch-specific
pipeline, block-reduce and MMA dispatch. No error was raised.
Parse the leading digits instead of requiring an all-digit string, keeping
-1 only for genuinely non-CUDA input such as a HIP gfx942 target. The bare
numeric form that was already accepted stays accepted.
matmul_analysis carried a second copy of the identical body, so fixing one
place would have left the other wrong. It now imports the shared helper.
Fixes tile-ai#2852
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe shared CUDA SM parser now accepts letter-suffixed architectures and returns their numeric versions. ChangesCUDA SM parsing
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
👋 Hi! Thank you for contributing to the TileLang project. Please remember to run We appreciate you taking this step! Our team will review your contribution, and we look forward to your awesome work! 🚀 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tilelang/carver/arch/cuda.py`:
- Around line 21-23: Update the CUDA arch parsing logic in the function that
strips the sm prefix and matches _SM_VERSION_PATTERN so it removes only a single
leading "sm_" from arch instead of replacing every occurrence. Keep the existing
int(match.group(1)) success path unchanged, and ensure malformed values like
repeated-prefix inputs still fail the pattern match and return -1.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: cbc05763-8598-46a0-aa11-78dad8fd939f
📒 Files selected for processing (3)
testing/python/carver/test_tilelang_carver_sm_version.pytilelang/carver/arch/cuda.pytilelang/carver/matmul_analysis.py
str.replace removed every occurrence, so a malformed value like sm_sm_90 parsed as 90 instead of returning the -1 sentinel. Matching the optional prefix inside the pattern keeps one source of truth for the grammar and leaves no way for a second prefix to be stripped away.
|
The ROCm job went red here, and I do not think it is this change. It is failing on 4 of the 5 other open PRs right now as well (#2905, #2898, #2895, #2892), so it looks repo-wide rather than branch specific. On the change itself, the only behavior differences are the intended ones. Comparing old and new across arch strings:
HIP targets parse identically, and the The CUDA and Metal jobs are still queued, and those are the ones that actually exercise it. |
|
The ROCm CI failure is not related to this PR, let me handle it |
|
Update now that the queue cleared. CUDA-auto passed in 14m48s and Metal passed in 24m21s, along with Quick Lint. Those are the jobs that actually exercise ROCm was re-run and failed again, so it is not flaky. I want to be more careful than I was earlier though. I said it was failing on 4 of 5 other open PRs, and the current picture is 5 of 7 failing with 2 passing, so widespread but not universal:
The failures straddle the two passes in time, so I cannot pin it to a single breakage point, and the self-hosted job logs are not readable from outside so I cannot see the actual error. What I can still stand behind is that this diff has no path to a ROCm test. HIP arch strings parse identically before and after, and the |
|
I was wrong that the ROCm logs are unreadable, they are available through ROCm is Both pass on the CUDA job of the same run, on this same commit:
So they are runner dependent, not commit dependent. I did check the one thing that could plausibly have been mine. That test builds a target with |
check_sm_versiongated onstr.isdigit(), so any arch string carrying the trailing feature-set letter that nvcc and CUTLASS use for Hopper and newer,sm_90a,sm_100a,sm_103a, fell through to the-1sentinel instead of parsing to 90, 100 or 103.Those lettered strings are the real value of
target.attrs["arch"], not a hypothetical one.tilelang/contrib/nvcc.pyalready does.rstrip("af")on that same attribute,tilelang/contrib/nvrtc.pydocuments"90a"as a valid arch,tilelang/contrib/cutedsl/cpasync.pyvalidates against["sm_90", "sm_90a", "sm_100a"], andtilelang/carver/roller/policy/tensorcore.pycomparescompute_capabilityagainst"sm_90a"directly. One path handled the suffix and this one did not.The
-1then silently corrupted capability dispatch.CUDA.sm_versionis set fromcheck_sm_versionand feedsis_volta_arch,is_ampere_arch,is_ada_arch,is_hopper_archandhas_mma_support, andmatmul_analysiscompares the same value against 70, 80 and 90. With-1a real Hoppersm_90atarget failed every one of those checks, so it was treated as pre-sm_70 and quietly lost its arch-specific pipeline, block-reduce and MMA dispatch. No error was raised, which is why no test caught it.Fix
Parse the leading digits instead of requiring an all-digit string, so
sm_90amaps to 90 andsm_100amaps to 100.-1is kept only for genuinely non-CUDA input such as a HIPgfx942target, and the bare numeric form that the old code already accepted stays accepted.tilelang/carver/matmul_analysis.pycarried a second copy of the identical function body insideget_tensorized_func_and_tags, so fixing one place would have left the other wrong. It now imports the shared helper fromtilelang.carver.arch.cuda. That module was already an import dependency ofmatmul_analysis, so no new import edge is added.Testing
New CPU regression test at
testing/python/carver/test_tilelang_carver_sm_version.py. No GPU is needed, the defect and the fix are pure string parsing.Verified fail-before and pass-after against the base ref rather than a stash:
With the fix applied, the same file reports 5 passed, and
testing/python/carver/test_tilelang_carver_hint.pystill passes alongside it.The test covers four things: the numeric arches that already worked, the lettered arches that did not, the non-CUDA strings that must stay at
-1, and the downstream consequence, that asm_90aarch now satisfiesis_hopper_archandhas_mma_supportand none of the older-arch predicates. The last test pins the deduplication so a future re-copy of the parser fails.Formatting checked with the pinned
ruff==0.14.14fromrequirements-lint.txt:ruff format --checkreports already formatted andruff checkpasses on all three files.Fixes #2852
Summary
check_sm_versionto parse numeric and lettered CUDA architectures, includingsm_90a,sm_100a, andsm_103a.sm_prefix to reject malformed inputs such assm_sm_90.-1for non-CUDA and unparseable inputs.matmul_analysis.py.