Repository navigation
Refuse a device operand for a host operator; MoDL lesson on the card - #173
Merged
Merged
Conversation
Applying a CartesianSense built on host tensors to a CUDA tensor, or solving with it, crashed the process. Operator application and the linear solve now raise a ValueError naming both devices. The MoDL lesson keeps the operator, its data and the network on one device, the card when there is one. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MFB6QLvu9frE7HdzPd4yCU
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MFB6QLvu9frE7HdzPd4yCU
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
… refuses a device operand Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MFB6QLvu9frE7HdzPd4yCU
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MFB6QLvu9frE7HdzPd4yCU
Collaborator
Author
|
codecov/patch: at e9e4204 the duplicate device helper is gone, and Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Operator._apply) and running the linear solve (optim._linear._solve) now raiseValueErrorwhen the operand is on a card but the operator's data is on the host. The message names the device and says how to fix it.device=or data on the card) takes host operands, which it moves itself.device is None, e.g.FFT) takes operands anywhere.x0must be ony's device, and a barecudacounts as the current card.docs/examples/06-learning/02-modl-with-admm.py) keeps the SENSE operator, its data and the network on one device: the card when there is one, the host otherwise. Lightning's accelerator follows that device.Why
A
CartesianSensebuilt on host tensors crashes the process (SIGSEGV in_apply/_solve) when it is applied to CUDA tensors or solved withoptim.cg. This was reproduced with bartorch 0.0.22 on an A40, on forward, adjoint, normal and cg. It is what stopped the MoDL lesson from running withaccelerator="gpu". With the lesson as changed here, the whole example runs in 52 s on an A40, against 175 s on the CPU.Validation
./scripts/lint.sh: all checks passed../scripts/run_tests.sh -n 4, clang 18 build, first head): 2567 passed, 183 skipped. The twotest_openmp.py::...share_one_openmp_runtimefailures are unrelated: they fail the same way without this change, because this container's clang build links LLVM's libomp while torch carries libgomp.tests/test_cuda.py tests/test_sense.py tests/test_solve.py tests/test_optim_functional.py tests/test_linop.py: 282 passed, 27 skipped.tests/test_cuda.py tests/test_sense.py: 104 passed, 1 skipped. This includestest_an_operator_on_a_card_takes_and_returns_host_arrays, which the first head failed.scripts/check_device.py: 9/9.Documentation impact
The MoDL lesson runs on a GPU when one is present. A device tensor given to a host-built operator raises
ValueErrorinstead of crashing.🤖 Generated with Claude Code
https://claude.ai/code/session_01MFB6QLvu9frE7HdzPd4yCU