Upgrade to nanobind 3 - #74
Conversation
Code Review by Qodo
1.
|
|
Code review by qodo was updated up to the latest commit 09b60d3 |
|
Thanks for the contribution. Did you happen to take a look at what the nanobind 3 upgrade would require? I believe it's supposed to not make many breaking changess |
|
I looked, and the upgrade itself looks small. nanobind 3 isn't really the problem. On a CPU-only runner, On my fork, building against
A run that printed the pending error showed the warning text: https://github.com/Kayvan-Zahiri/mach/actions/runs/34557575757 I haven't run the GPU tests or the wheel build against nanobind 3, since my fork has no GPU runner. Would you rather I turn this PR into the nanobind 3 upgrade, or keep the cap for now and open the upgrade separately? |
|
Thanks @Kayvan-Zahiri ! Yeah, since it's pretty well-scoped, let's just turn this into a nanobind 3 upgrade. I'll separately look into avoiding these issues in the future by making a uv.lock file for the build tools, which don't require all of the package dependencies |
Require nanobind>=3.0.1,<4 in build-system.requires, the build dependency group, uv.lock, the cibuildwheel before-build step, the Makefile compile target and the CMakeLists setup comment. The before-build specifiers are now quoted so the shell no longer reads >= as a redirect. On a CPU-only runner cudaDriverGetVersion succeeds and reports 0, so checkCudaDriverCompatibility warned that driver 0.0 is too old. Under the pytest "error" warning filter PyErr_WarnEx returned -1, the exception stayed pending through module init, and nanobind 3.0.1 aborted in enum_create. Skip the version comparison when the driver version is 0, and throw nb::python_error when any of the three import-time warnings fails.
20e2e6c to
e82f865
Compare
|
Done, this is now the nanobind 3 upgrade, with the two kernel.cu changes from my last comment. On my fork the new commit passes Test-CPU (47 tests), Check, and Build wheels with the import test on 3.11 to 3.14. Test-GPU and the docs build haven't run on this PR. Pushes don't trigger them (their pull_request types are opened, reopened, ready_for_review), their only runs here are from the first commit and await approval, and a manual dispatch can only target a branch or tag in this repo. Closing and reopening the PR should start them, though I haven't tried that. A uv.lock for the build tools sounds good. |
| if (cudaDriverGetVersion(&driverVersion) != cudaSuccess) { | ||
| PyErr_WarnEx(PyExc_RuntimeWarning, "Could not get CUDA driver version", 1); | ||
| if (PyErr_WarnEx(PyExc_RuntimeWarning, "Could not get CUDA driver version", 1) < 0) { | ||
| throw nb::python_error(); | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| // The runtime reports 0 when no driver is installed | ||
| if (driverVersion == 0) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Suggest warning on missing driver - so it's clear at import time that beamforming won't work (although users can still use geometry, etc, and functionality that we run through Test-CPU job
So you could consolidate these 2 checks into:
if (cudaDriverGetVersion(&driverVersion) != cudaSuccess || driverVersion == 0) {
// cudaDriverGetVersion reports 0 when no driver is installed
if (PyErr_WarnEx(
PyExc_RuntimeWarning,
"[mach] No NVIDIA driver was found. CUDA beamforming is unavailable. ",
1) < 0) {
throw nb::python_error();
}
return;
}
There was a problem hiding this comment.
assuming you take this suggestion to also warn when the driver is missing (CPU-only node), you'll need to update the pytest filterwarnings as well:
filterwarnings = [
"error",
"ignore:\\[mach\\] No NVIDIA driver was found.*:RuntimeWarning",
"ignore:.*This will add latency due to CPU<->GPU memory transfers.*:UserWarning",
# vbeam warnings
...
]
There was a problem hiding this comment.
edit: probably an easier to read filterwarnings match would be:
"ignore:.*No NVIDIA driver was found.*:RuntimeWarning",
|
Thanks for the update & fix! I think it would still be helpful to have a warning if a driver was absent, as almost all users of this library are interested in the CUDA kernel, even though there is some functionality that does not require a GPU (tested by test_cpu.yml), only remaining suggestion would be to still warn on missing driver and update |
cudaDriverGetVersion reports 0 when no driver is installed. Warn at import in that case, and when the version query fails, so it is clear that CUDA beamforming is unavailable. pytest's filterwarnings ignores this warning, so the CPU-only test job still runs with warnings as errors.
|
Done. It now warns On my fork, Test-CPU passes with 47 tests, and a CI-only step that imports mach on the CPU runner prints the warning: https://github.com/Kayvan-Zahiri/mach/actions/runs/34655201037. Check and Build wheels pass too. The GPU tests haven't run. |
Introduction
Upgrades to nanobind 3 in place of the earlier cap below 3.
Changes
nanobind>=3.0.1,<4inbuild-system.requires, the build group, the Makefile and the CMakeLists setup comment.uv.lockchanges only nanobind.before-buildspecifiers, since the shell read an unquoted>=as a redirect.kernel.cu: on a CPU-only runner,cudaDriverGetVersionsucceeds and reports 0, so the import check warned that driver 0.0 is too old. The pytest"error"filter madePyErr_WarnExreturn -1, nothing checked it, and nanobind 3 aborted on the pending exception inenum_create("InterpolationType"). Now a failed version query or a version of 0 warns that no NVIDIA driver was found, and the import-timePyErr_WarnExcalls thrownb::python_erroron failure.pyproject.toml:filterwarningsignores the no-driver warning, so the CPU-only tests still run with warnings as errors.Behavior
Importing mach without a driver now warns
[mach] No NVIDIA driver was found. CUDA beamforming is unavailable.Locally,uv lock --locked(uv 0.7.3) and pre-commit pass._cuda_impl.pyiis not regenerated, since that needs a CUDA build.Fork CI on this branch, with only CI-only steps added on top (push triggers and two import checks): Test-CPU passed (47 tests, nanobind 3.0.1), and its import step printed the warning. With
-W error::RuntimeWarning, the import failed with a Python error, not an abort. Check and Build wheels passed.The GPU tests and the docs build have not run against nanobind 3.