-
Notifications
You must be signed in to change notification settings - Fork 1.5k
8587 test erros on pytorch release 2508 on series 50 #8770
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
base: dev
Are you sure you want to change the base?
Changes from 19 commits
ba56a6d
5216b7a
eacd783
c64825f
66b6c17
19cab57
09c2cd9
7cd0607
3fd7546
4f6df07
36e2623
356956a
17b9910
8de64af
7c2ddb6
cfe5524
1dec216
ec8bf1f
4b5bf1e
23f0290
057ff4d
2b5b367
80124e6
1b5ac46
0a90770
b5b1eff
4a54359
f07dcb1
2feca34
0b887a3
e57f64e
e2b99da
256b671
f3e612c
43dd636
f284c48
c00aaf8
0cd053a
d30be44
08a1cce
f6473f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -342,8 +342,7 @@ def set_regular_matcher( | |||||
| """ | ||||||
| if fg_iou_thresh < bg_iou_thresh: | ||||||
| raise ValueError( | ||||||
| "Require fg_iou_thresh >= bg_iou_thresh. " | ||||||
| f"Got fg_iou_thresh={fg_iou_thresh}, bg_iou_thresh={bg_iou_thresh}." | ||||||
| f"Require fg_iou_thresh >= bg_iou_thresh. Got fg_iou_thresh={fg_iou_thresh}, bg_iou_thresh={bg_iou_thresh}." | ||||||
|
Member
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.
Suggested change
|
||||||
| ) | ||||||
| self.proposal_matcher = Matcher( | ||||||
| fg_iou_thresh, bg_iou_thresh, allow_low_quality_matches=allow_low_quality_matches | ||||||
|
|
@@ -519,7 +518,7 @@ def forward( | |||||
| else: | ||||||
| if self.inferer is None: | ||||||
| raise ValueError( | ||||||
| "`self.inferer` is not defined." "Please refer to function self.set_sliding_window_inferer(*)." | ||||||
| "`self.inferer` is not defined. Please refer to function self.set_sliding_window_inferer(*)." | ||||||
| ) | ||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||
| head_outputs = predict_with_inferer( | ||||||
| images, self.network, keys=[self.cls_key, self.box_reg_key], inferer=self.inferer | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,6 +54,35 @@ | |
| __all__ = ["spatial_resample", "orientation", "flip", "resize", "rotate", "zoom", "rotate90", "affine_func"] | ||
|
|
||
|
|
||
| def _compiled_unsupported(device: torch.device) -> bool: | ||
| """ | ||
| Return True if ``monai._C`` (the compiled C extension providing ``grid_pull``) is not | ||
| compiled with support for the given CUDA device's compute capability. | ||
|
|
||
| Args: | ||
| device: The torch device to check for compiled extension support. | ||
|
|
||
| Returns: | ||
| True if the device is CUDA with compute capability major >= 12 (Blackwell+), | ||
| False otherwise. Always returns False for CPU devices. | ||
|
|
||
| Note: | ||
| ``monai._C`` is built at install time against a fixed set of CUDA architectures. | ||
| NVIDIA Blackwell GPUs (sm_120, compute capability 12.x) and newer were not included in | ||
| the default ``TORCH_CUDA_ARCH_LIST`` when the MONAI slim image was originally built, | ||
|
Member
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 remember if I asked you, but have you tried building the slim image with the new capabilities added to TORCH_CUDA_ARCH_LIST? There must be a way of adding these as well for the main MONAI image. |
||
| so executing ``grid_pull`` on those devices produces incorrect results. Falling back to | ||
| the PyTorch-native ``affine_grid`` + ``grid_sample`` path (``USE_COMPILED=False``) gives | ||
| correct output on all architectures. | ||
|
|
||
| The threshold (``major >= 12``) matches the first architecture family (Blackwell, sm_120) | ||
| that shipped after the highest sm supported in the current default build list (sm_90, | ||
| Hopper). Adjust this constant when ``monai._C`` is rebuilt with sm_120+ support. | ||
| """ | ||
| if device.type != "cuda": | ||
| return False | ||
| return torch.cuda.get_device_properties(device).major >= 12 | ||
|
|
||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| def _maybe_new_metatensor(img, dtype=None, device=None): | ||
| """create a metatensor with fresh metadata if track_meta is True otherwise convert img into a torch tensor""" | ||
| return convert_to_tensor( | ||
|
|
@@ -158,7 +187,8 @@ def spatial_resample( | |
| xform_shape = [-1] + in_sp_size | ||
| img = img.reshape(xform_shape) | ||
| img = img.to(dtype_pt) | ||
| if isinstance(mode, int) or USE_COMPILED: | ||
| _use_compiled = USE_COMPILED and not _compiled_unsupported(img.device) | ||
| if isinstance(mode, int) or _use_compiled: | ||
| dst_xform = create_translate(spatial_rank, [float(d - 1) / 2 for d in spatial_size]) | ||
| xform = xform @ convert_to_dst_type(dst_xform, xform)[0] | ||
| affine_xform = monai.transforms.Affine( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| # Copyright (c) MONAI Consortium | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Test GPU support detection and fallback paths for spatial transforms.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import unittest | ||
|
|
||
| import torch | ||
|
|
||
| from monai.transforms.spatial.functional import _compiled_unsupported | ||
|
|
||
|
|
||
| class TestCompiledUnsupported(unittest.TestCase): | ||
| """Test _compiled_unsupported device detection.""" | ||
|
|
||
| def test_cpu_device_always_supported(self): | ||
| """CPU devices should never be marked unsupported.""" | ||
| device = torch.device("cpu") | ||
| self.assertFalse(_compiled_unsupported(device)) | ||
|
|
||
| def test_non_cuda_device_always_supported(self): | ||
| """Non-CUDA devices should always be supported.""" | ||
| device = torch.device("cpu") | ||
| self.assertFalse(_compiled_unsupported(device)) | ||
|
|
||
| @unittest.skipIf(not torch.cuda.is_available(), reason="CUDA not available") | ||
| def test_cuda_device_detection(self): | ||
| """Verify CUDA compute capability detection.""" | ||
| device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") | ||
| if device.type == "cuda": | ||
| cc_major = torch.cuda.get_device_properties(device).major | ||
| unsupported = _compiled_unsupported(device) | ||
| # Device is unsupported if cc_major >= 12 | ||
| if cc_major >= 12: | ||
| self.assertTrue(unsupported) | ||
| else: | ||
| self.assertFalse(unsupported) | ||
|
|
||
| def test_compiled_unsupported_return_type(self): | ||
| """Verify return type is bool.""" | ||
| device = torch.device("cpu") | ||
| result = _compiled_unsupported(device) | ||
| self.assertIsInstance(result, bool) | ||
|
|
||
|
|
||
| class TestResampleFallback(unittest.TestCase): | ||
| """Test Resample fallback behavior on unsupported devices.""" | ||
|
|
||
| @unittest.skipIf(not torch.cuda.is_available(), reason="CUDA not available") | ||
| def test_resample_compilation_flag_respected(self): | ||
| """Verify Resample respects _compiled_unsupported check.""" | ||
| # This would require internal inspection or output verification | ||
| # Could test with mock device properties or actual Blackwell GPU | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| def test_compiled_unsupported_logic(self): | ||
| """Test that unsupported devices are correctly detected.""" | ||
| # CPU should be supported | ||
| cpu_device = torch.device("cpu") | ||
| self.assertFalse(_compiled_unsupported(cpu_device)) | ||
|
|
||
| # Verify logic: return True if CUDA and cc_major >= 12 | ||
| cuda_device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") | ||
| if cuda_device.type == "cuda": | ||
| cc_major = torch.cuda.get_device_properties(cuda_device).major | ||
| expected = cc_major >= 12 | ||
| actual = _compiled_unsupported(cuda_device) | ||
| self.assertEqual(actual, expected) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() | ||
| if __name__ == "__main__": | ||
| unittest.main() | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
Uh oh!
There was an error while loading. Please reload this page.