Repository navigation
GPU Test Runner - #9112
GPU Test Runner#9112ericspod wants to merge 37 commits into
Conversation
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueTip 🎯 Customize your risk assessments
✅ Automatic approvals, with your rules
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
|
Hi @ericspod , I'm interested in helping with the GPU test runner. I noticed the PR is still in progress. Is there a specific area where an independent investigation or contribution would be useful? |
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
|
Thanks @vikasreddy11 do you have access to a GPU? I could use some help testing the GPU resampling accuracy with the compiled extensions. I'm seeing affine tests failing like this DetailsThis occurs in |
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
|
Thanks @ericspod, I tested on a GPU outside Docker (RTX 3050 Laptop, WSL2, Python 3.12.15, PyTorch 2.14.1+cu132, I can reproduce it, and it depends on the compiled extension:
Not yet checked: |
|
Update: I also made a minimal standalone reproduction mirroring It is not GPU-specific: running the same script with With I suspect the compiled branch of import numpy as np, torch
from monai.data import MetaTensor
from monai.transforms import Affine
from monai.transforms.lazy.functional import apply_pending
from tests.lazy_transforms_utils import get_apply_param
img = MetaTensor(torch.arange(4, dtype=torch.float32).reshape(1, 2, 2))
rot = torch.tensor([[0., -1., 0.], [1., 0., 0.], [0., 0., 1.]])
init = dict(affine=rot, padding_mode="zeros", align_corners=True)
call = dict(img=img, spatial_size=(4, 4))
eager = Affine(**init)(**call)
eager = eager[0] if isinstance(eager, tuple) else eager
t = Affine(**init); t.lazy = True
out = t(**call)
out = out[0] if isinstance(out, tuple) else out
out = apply_pending(out, overrides=get_apply_param(init, call))[0]
print(np.round(np.asarray(eager), 4)); print(np.round(np.asarray(out), 4))Run with I'd like to dig into this. If I find a fix, would you like me to open a PR, or is someone already working on this? |
|
Hi @vikasreddy11 thanks for looking into the issue. If you could please find a fix and propose a PR if you do, no one else is working on it currently. These fails are the major issues we're encountering with the GPU tests but I'm working on others currently. The root cause hasn't been found since the PR tests compile the code but then don't use it since |
|
The issue with the import torch
t = torch.rand(1, 10, 1).cuda()
tt = torch.rand(1, 1, 10).cuda()
torch.bmm(t, tt)This raises "RuntimeError: Failed to find C compiler." on line 364 of t = torch.rand(1, 10, 1).cuda()
tt = torch.rand(1, 1, 10).cuda()
def matmul_native(a, b): #(B,N,1) (B,1,M)
return a.repeat(1, 1, b.shape[2]) * b.repeat(1, a.shape[1], 1)
matmul_native(t,tt) |
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
for more information, see https://pre-commit.ci
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
|
With
The pending affine and the matrix passed to Forcing Question: for |
|
Thanks again @vikasreddy11 I would say the native branch is the reference and not the compiled. I don't think the compiled code is used often as I suspect most users don't build from the repo. It should be fixed however for those that do if not just for these tests. Please propose your PR to fix the compiled code and the tests you mention, if they are degenerate they can be updated to fix this I hope. |
|
Opened #9248 with the fix for the compiled lazy |
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Related to #9112. ### Description Fixes lazy resampling with the compiled extension (`BUILD_MONAI=1`) when `align_corners=True`, following @ericspod's confirmation that the native `grid_sample` path is the reference. In `spatial_resample`, the compiled branch builds `Affine(affine=xform, normalized=True, align_corners=True)` from a matrix that is already in voxel space. `AffineGrid` and the compiled `Resample` then apply the `align_corners=True` scalings (`d_out/(d_out-1)` and `(d_in-1)/d_in`) on top of it, distorting the grid passed to `grid_pull`. For non-integer `mode`, the matrix is now pre-compensated so those scalings cancel. Integer `mode` is unchanged. Verification (`BUILD_MONAI=1` unless noted): - `test_affine` + `test_affined`: 132 failed -> 0 failed. - Wider set (spacing, resize, zoom, rotate, rand_* transforms): 10 failed -> 0 failed. Default (non-compiled) run: 0 failed, unchanged. - Eager `Spacing` vs a plain `F.grid_sample(align_corners=True)` reference on three shapes: compiled was 0.2 to 0.5 off before, ~2e-7 after (native ~3e-8). - Reproduces on CPU too, so not GPU-specific. Test changes: - Added `test_lazy_rotate_align_corners_compiled` (skipped unless the extension is compiled). It fails without the fix and passes with it. - `_TEMPLATE_5_COMPILED` in `test_spacing.py` changed from 0.75 to 1.0. All sampled input coordinates for that case lie inside the image and the input is all ones, so 1.0 is the geometrically correct value. The native template (0.9553) looks like a unit-size-axis artifact and is untouched. Note: `BUILD_MONAI=1` must be set at runtime, not only at build time, for these tests to exercise the compiled path. Tested locally on RTX 3050 / WSL2 / PyTorch 2.14.1+cu132 (outside CI's range); not run on PyTorch 2.8 to 2.11 or through the full `./runtests.sh`. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [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. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: Vikas Reddy <vikasreddy1090@gmail.com> Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
|
We currently have a core dump on the tests for the CRF block. I can't reproduce this in a local MONAI slim as all tests pass, and have encountered the following testing with ROCm: Something is still an issue with the compiled code that needs to be addressed. @vikasreddy11 if you're up for investigating this further we'd have to somehow reproduce the core dump, the above tests are a harder one to nail down. Thanks! |
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
|
Happy to investigate further. I don't have ROCm hardware, but I tried reproducing on CUDA (RTX 3050, WSL2, PyTorch 2.14.1+cu132). I ran tests/networks/blocks/test_crf_cuda.py with BUILD_MONAI=1: 4 tests ran and passed, and there was no core dump. So I can't reproduce either the ROCm mismatch-ratio failures or the crash on CUDA, though that doesn't rule them out on ROCm. Could you share the GPU model and runtime details of the CI runner (CUDA/ROCm version, PyTorch version) and which test triggers the core dump? I'll use that to narrow it down. |
Hi @vikasreddy11 I'm trying to narrow it down now too within the runner as I can't reproduce outside either. Have a look at the changes to permutohedral.cpp where I'm trying to get debug information out. Information about the environment is in the logs of the check, so when full-dep-gpu fails you can have a look at what it says. |
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
|
@vikasreddy11 I think I may have figured out the issue, we weren't actually compiling CUDA when I thought we were. I'm getting the following build warnings however, could you figure out the tweaks to setup.py to address these? Warnings |
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
|
Thanks for the update. I can try to reproduce the packaging warnings locally without a CUDA build and look at the setup.py discovery config. I'll report back with what I find. |
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Fixes # .
Description
This adds a testing runner for the KCL GPU runner available to MONAI. The goal is to develop a GPU testing process, either as a per-PR test or nightly GPU tests.
Types of changes
./runtests.sh -f -u --net --coverage../runtests.sh --quick --unittests --disttests.make htmlcommand in thedocs/folder.