-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 all commits
ba56a6d
5216b7a
eacd783
c64825f
66b6c17
19cab57
09c2cd9
7cd0607
3fd7546
4f6df07
36e2623
356956a
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}." | ||
| ) | ||
| 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(*)." | ||
| ) | ||
|
Comment on lines
519
to
522
Contributor
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. Missing space after period in error message.
Proposed fix 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(*)."
)🧰 Tools🪛 Ruff (0.15.4)[warning] 520-522: Avoid specifying long messages outside the exception class (TRY003) 🤖 Prompt for AI Agents |
||
| 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,27 @@ | |
| __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. | ||
|
|
||
| ``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, | ||
| 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 | ||
|
|
||
|
Comment on lines
+57
to
+76
Contributor
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. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Find all USE_COMPILED usages that might need the _compiled_unsupported guard
rg -n "USE_COMPILED" --type=py -C2 | grep -v "_compiled_unsupported"Repository: Project-MONAI/MONAI Length of output: 22885 🏁 Script executed: cat -n monai/networks/blocks/warp.py | head -200Repository: Project-MONAI/MONAI Length of output: 9110 🏁 Script executed: sed -n '57,250p' monai/transforms/spatial/functional.py | head -100Repository: Project-MONAI/MONAI Length of output: 6288 🏁 Script executed: sed -n '170,200p' monai/transforms/spatial/functional.pyRepository: Project-MONAI/MONAI Length of output: 1558 🏁 Script executed: sed -n '140,152p' monai/networks/blocks/warp.pyRepository: Project-MONAI/MONAI Length of output: 693 Add device compatibility check before The _use_compiled = USE_COMPILED and not _compiled_unsupported(image.device)
if not _use_compiled: # pytorch native grid_sample
...
else: # grid_pull
return grid_pull(...)This prevents incorrect results on Blackwell GPUs (compute capability 12.x+) where 🤖 Prompt for AI Agents |
||
|
|
||
| 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 +179,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( | ||
|
|
||
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.
Missing space after period in error message.
The concatenation dropped the space between sentences:
"not supported yet.Try modify"should be"not supported yet. Try modify".Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents