forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 75
[rocm7.0_internal_testing] fix enabling sparse tests fp16/bf16 for rocm7.0/7.1 #2239
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
jithunnair-amd
merged 1 commit into
rocm7.0_internal_testing
from
dnikolaev/fix_sparse_tests_rocm6.5
Jun 30, 2025
Merged
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
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
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 |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ | |
| import random | ||
| import unittest | ||
| from torch.testing import make_tensor | ||
| from torch.testing._internal.common_utils import TestCase, run_tests, skipIfRocm, do_test_dtypes, \ | ||
| from torch.testing._internal.common_utils import TestCase, run_tests, do_test_dtypes, \ | ||
| load_tests, TEST_NUMPY, TEST_SCIPY, IS_WINDOWS, gradcheck, coalescedonoff, \ | ||
| DeterministicGuard, first_sample, TEST_WITH_CROSSREF, TEST_WITH_ROCM, skipIfTorchDynamo, \ | ||
| parametrize, subtest, is_coalesced_indices, suppress_warnings, instantiate_parametrized_tests, \ | ||
|
|
@@ -68,6 +68,12 @@ def _op_supports_any_sparse(op): | |
| ) or (not IS_WINDOWS and not TEST_WITH_ROCM) | ||
|
|
||
| HIPSPARSE_SPMM_COMPLEX128_SUPPORTED = torch.version.hip and version.parse(torch.version.hip.split("-")[0]) >= version.parse("6.0") | ||
| HIPSPARSE_FP16_SUPPORTED = torch.version.hip and version.parse(torch.version.hip.split("-")[0]) >= version.parse("7.0") | ||
| HIPSPARSE_BF16_SUPPORTED = torch.version.hip and version.parse(torch.version.hip.split("-")[0]) >= version.parse("7.1") | ||
|
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. this is not yet tested, but hipsparse will support this in 7.1 |
||
|
|
||
| SPARSE_COMPLEX128_SUPPORTED = CUSPARSE_SPMM_COMPLEX128_SUPPORTED or HIPSPARSE_SPMM_COMPLEX128_SUPPORTED | ||
| SPARSE_FLOAT16_SUPPORTED = (SM53OrLater and torch.version.cuda) or (HIPSPARSE_FP16_SUPPORTED) | ||
| SPARSE_BFLOAT16_SUPPORTED = (SM80OrLater and torch.version.cuda) or (HIPSPARSE_BF16_SUPPORTED) | ||
|
|
||
| def all_sparse_layouts(test_name='layout', include_strided=False): | ||
| return parametrize(test_name, [ | ||
|
|
@@ -3608,13 +3614,12 @@ def test_log_softmax_zero_nnz(self, device, dtype): | |
| self._check_zero_nnz_softmax_op(torch.sparse.log_softmax, 10, device, dtype) | ||
|
|
||
| # TODO: Check after why ROCm's cusparseXcsrgemm2Nnz function doesn't return the same nnz value as CUDA | ||
| @skipIfRocm | ||
| @coalescedonoff | ||
| @dtypes(*floating_and_complex_types()) | ||
| @dtypesIfCUDA(*floating_types_and(*[torch.half] if SM53OrLater else [], | ||
| *[torch.bfloat16] if SM80OrLater else [], | ||
| @dtypesIfCUDA(*floating_types_and(*[torch.half] if SPARSE_FLOAT16_SUPPORTED else [], | ||
| *[torch.bfloat16] if SPARSE_BFLOAT16_SUPPORTED else [], | ||
| torch.complex64, | ||
| *[torch.complex128] if CUSPARSE_SPMM_COMPLEX128_SUPPORTED else [])) | ||
| *[torch.complex128] if SPARSE_COMPLEX128_SUPPORTED else [])) | ||
| @unittest.skipIf(TEST_WITH_CROSSREF, "not working with fake tensor") | ||
| @precisionOverride({torch.bfloat16: 1e-2, torch.float16: 1e-2, torch.complex64: 1e-2, torch.float32: 1e-2}) | ||
| def test_sparse_matmul(self, device, dtype, coalesced): | ||
|
|
||
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
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.
Uh oh!
There was an error while loading. Please reload this page.