[Bugfix] Disable cpp_itfs sampling on ROCm 10 - #4754
Open
fsx950223 wants to merge 1 commit into
Open
Conversation
Fail import before the incompatible sampling.cuh JIT path so callers can fall back cleanly. Signed-off-by: fsx950223 <fsx950223@outlook.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR prevents the cpp_itfs sampling JIT path from being entered on ROCm 10+ (where the toolchain is incompatible), by failing fast with an ImportError and conditionally skipping the sampling test suite for that expected incompatibility.
Changes:
- Add an import-time ROCm 10+ gate for
csrc.cpp_itfs.samplingthat raisesImportErrorbefore JIT compilation is attempted. - Update
op_tests/test_sampling.pyto treat that specificImportErroras an expected condition and skip the module’s tests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| op_tests/test_sampling.py | Wraps sampling import to skip the test module when the ROCm 10+ disablement ImportError is raised. |
| csrc/cpp_itfs/sampling/init.py | Adds an import-time ROCm version check to disable cpp_itfs sampling on ROCm 10+. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+10
to
+16
| try: | ||
| from aiter.ops import sampling | ||
| except ImportError as exc: | ||
| if "cpp_itfs sampling is disabled on ROCm 10" not in str(exc): | ||
| raise | ||
| sampling = None | ||
| pytestmark = pytest.mark.skip(reason=str(exc)) |
Comment on lines
+6
to
+25
| import os | ||
| import re | ||
|
|
||
| import torch | ||
|
|
||
|
|
||
| def _get_rocm_major_version() -> int | None: | ||
| version = os.environ.get("AITER_ROCM_VERSION") or getattr( | ||
| torch.version, "hip", None | ||
| ) | ||
| match = re.match(r"\s*(\d+)", version or "") | ||
| return int(match.group(1)) if match else None | ||
|
|
||
|
|
||
| _rocm_major_version = _get_rocm_major_version() | ||
| if _rocm_major_version is not None and _rocm_major_version >= 10: | ||
| raise ImportError( | ||
| "AITER cpp_itfs sampling is disabled on ROCm 10 and later because " | ||
| "csrc/cpp_itfs/sampling/sampling.cuh is not compatible with this toolchain." | ||
| ) |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
cpp_itfssampling package on ROCm 10 and later before the incompatiblesampling.cuhJIT path is reachedImportErrorso callers can use their existing fallback pathTest plan
AITER_ROCM_VERSION=10.0(352 sampling tests skipped cleanly)Made with Cursor