You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browse filesBrowse the repository at this point in the historyBrowse files
authored
8587 test erros on pytorch release 2508 on series 50 (#8770)
Fixes#8587.
### Description
On NVIDIA Blackwell GPUs (compute capability 12.x, sm_120), running
MONAI with `USE_COMPILED=True` produces **silently incorrect spatial
transform results**. The root cause is that the MONAI compiled C
extension (`monai._C`) is built at install time against a fixed set of
CUDA architectures (`TORCH_CUDA_ARCH_LIST`). Blackwell (sm_120) is not
included in the default build list (which tops out at sm_90, Hopper), so
`grid_pull` executes against a mismatched PTX or JIT path and silently
returns wrong values — there is no runtime error.
This affects two independent code paths:
**1. `spatial_resample` / `Resample`**
(`monai/transforms/spatial/functional.py`)
When `USE_COMPILED=True`, `spatial_resample` unconditionally calls
`grid_pull`. On Blackwell GPUs this produces incorrect resampling output
without raising any exception.
**2. `Warp`** (`monai/networks/blocks/warp.py`)
`Warp.__init__` stores interpolation and padding modes as **integers**
when `USE_COMPILED=True` (as required by `grid_pull`). The
PyTorch-native fallback path (`F.grid_sample`) requires **string**
modes. Without a Blackwell-aware fallback, there was no path to trigger
this mismatch — but once the device check forces the fallback, the
integer modes cause a type error at runtime.
#### Additional change to `runner.py` (⚠️not directly related to the
issue)
Add per-test timeout via --timeout flag
Tests that hang indefinitely (e.g. GPU ops stuck on Blackwell) block the
entire suite. Add a --timeout SECONDS option to tests/runner.py that
uses SIGALRM to interrupt any individual test that exceeds the limit;
the test is recorded as an error and the runner continues with the next
test.
- Default is 0 (disabled); SIGALRM support is checked at runtime so the
flag is silently ignored on Windows.
- runtests.sh gains a matching --timeout [secs] flag (default 180s when
the flag is given without a value) that is forwarded to runner.py for
unit tests.
```bash
#Usage:
./runtests.sh -u --timeout # 3-minute per-test limit
./runtests.sh -u --timeout 60 # 1-minute per-test limit
python tests/runner.py --timeout 180
```
**Fix**
A private helper `_compiled_unsupported(device: torch.device) -> bool`
is added to `monai/transforms/spatial/functional.py`. It returns `True`
for CUDA devices with compute capability major ≥ 12, and `False` for all
other devices (CPU, older GPUs).
- In `spatial_resample`, the compiled path is now gated on `USE_COMPILED
and not _compiled_unsupported(img.device)`, falling back to the
PyTorch-native `affine_grid + grid_sample` path on unsupported devices.
- In `Warp`, the same gate is applied in `forward()`. Additionally,
`__init__` now always stores **both** the compiled integer modes (for
`grid_pull`) and the native string modes (for `F.grid_sample`), ensuring
the fallback path has correctly-typed arguments regardless of how
`USE_COMPILED` was set at initialisation time.
Behaviour on all previously supported GPU architectures (sm_75 through
sm_90) is unchanged.
### Types of changes
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [x] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.
---------
Signed-off-by: R. Garcia-Dias <rafaelagd@gmail.com>
Signed-off-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
0 commit comments