-
Notifications
You must be signed in to change notification settings - Fork 308
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
[BugFix] Fix invalid CUDA ID error when loading Bounded variables across devices #2421
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/2421
Note: Links to docs will display an error until the docs builds have been completed. ❌ 3 New Failures, 1 Cancelled Job, 2 Pending, 6 Unrelated FailuresAs of commit 9b22619 with merge base df4fa78 (): NEW FAILURES - The following jobs have failed:
CANCELLED JOB - The following job was cancelled. Please retry:
FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
BROKEN TRUNK - The following jobs failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Hi @cbhua! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
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.
LGTM thanks!
Feel free to mark is as ready for review for me to merge it |
Thanks for your review! @vmoens, I saw some unpassed pytest checks, so I made this PR draft. It seems those are from GitHub action settings or dependency packages, so should be fine. I will make it ready to merge! |
Errors in CI are not related to this PR, happy to merge it |
Description
This pull request resolves an invalid CUDA ID error that occurs when transferring a Bounded variable between servers with different numbers of GPUs.
In the current implementation, when changing the device of a
Bounded
variable, there is:rl/torchrl/data/tensor_specs.py
Lines 2273 to 2274 in df4fa78
This operation first attempts to move
self.space._low
to itsself.space.device
before transferring to the target device (dest
):rl/torchrl/data/tensor_specs.py
Lines 376 to 382 in df4fa78
This process leads to errors when a variable previously on
cuda:7
(in an 8 GPU server) is loaded on a server with only one GPU, as it incorrectly attempts to accesscuda:7
.Motivation and Context
The issue was identified when a model was trained and saved on a multi-GPU cluster and subsequently loaded on a local server equipped with fewer GPUs. The model’s saved state includes device information specific to the original multi-GPU environment. When attempting to assign the model to a device available on the current server, the discrepancy in device IDs between the environments leads to this bug.
This PR fixes #2420 .
Types of changes
To resolve this bug, I have adjusted the approach to device assignment. Instead of calling the saved device information from the previous cluster, we directly update the device information to match the current server’s available hardware.
In the meantime, I think there is repeat function code here:
rl/torchrl/data/tensor_specs.py
Lines 390 to 408 in df4fa78
Checklist