-
Notifications
You must be signed in to change notification settings - Fork 7k
[air] Upgrade and unify device types with dataset.TorchDeviceType #56745
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Daniel Sperber <[email protected]>
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.
Code Review
This pull request improves the type hints for PyTorch device parameters in ray.air._internal.torch_utils. By replacing Optional[Union[str, "torch.device"]] with the unified Optional[TorchDeviceType], the type hints now correctly include int as a valid device identifier, aligning with PyTorch's API. The use of TYPE_CHECKING for the import is appropriate to prevent runtime circular dependencies. The changes are consistent and well-executed. This is a good step towards unifying device type definitions across the codebase.
Signed-off-by: Daniel Sperber <[email protected]>
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
|
(~ ̄(OO) ̄)ブ stale |
## Why are these changes needed? Follow up of RLlib PR: #55291 Torch `device` allows input types of `str | int | torch.device`, this PR unifies the type in a type variable and allows for the `int` type as well. Upstream air PR: #56745 ## Checks - [x] I've signed off every commit(by using the -s flag, i.e., `git commit -s`) in this PR. - [x] I've run `scripts/format.sh` to lint the changes in this PR. - [x] I've included any doc changes needed for https://docs.ray.io/en/master/. - [ x I've added any new APIs to the API Reference. For example, if I added a method in Tune, I've added it in `doc/source/tune/api/` under the corresponding `.rst` file. - [x] I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/ - Testing Strategy - [x] This PR is not tested :( --------- Signed-off-by: Daniel Sperber <[email protected]> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…ct#56743) ## Why are these changes needed? Follow up of RLlib PR: ray-project#55291 Torch `device` allows input types of `str | int | torch.device`, this PR unifies the type in a type variable and allows for the `int` type as well. Upstream air PR: ray-project#56745 ## Checks - [x] I've signed off every commit(by using the -s flag, i.e., `git commit -s`) in this PR. - [x] I've run `scripts/format.sh` to lint the changes in this PR. - [x] I've included any doc changes needed for https://docs.ray.io/en/master/. - [ x I've added any new APIs to the API Reference. For example, if I added a method in Tune, I've added it in `doc/source/tune/api/` under the corresponding `.rst` file. - [x] I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/ - Testing Strategy - [x] This PR is not tested :( --------- Signed-off-by: Daniel Sperber <[email protected]> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…ct#56743) ## Why are these changes needed? Follow up of RLlib PR: ray-project#55291 Torch `device` allows input types of `str | int | torch.device`, this PR unifies the type in a type variable and allows for the `int` type as well. Upstream air PR: ray-project#56745 ## Checks - [x] I've signed off every commit(by using the -s flag, i.e., `git commit -s`) in this PR. - [x] I've run `scripts/format.sh` to lint the changes in this PR. - [x] I've included any doc changes needed for https://docs.ray.io/en/master/. - [ x I've added any new APIs to the API Reference. For example, if I added a method in Tune, I've added it in `doc/source/tune/api/` under the corresponding `.rst` file. - [x] I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/ - Testing Strategy - [x] This PR is not tested :( --------- Signed-off-by: Daniel Sperber <[email protected]> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: YK <[email protected]>
…ct#56743) ## Why are these changes needed? Follow up of RLlib PR: ray-project#55291 Torch `device` allows input types of `str | int | torch.device`, this PR unifies the type in a type variable and allows for the `int` type as well. Upstream air PR: ray-project#56745 ## Checks - [x] I've signed off every commit(by using the -s flag, i.e., `git commit -s`) in this PR. - [x] I've run `scripts/format.sh` to lint the changes in this PR. - [x] I've included any doc changes needed for https://docs.ray.io/en/master/. - [ x I've added any new APIs to the API Reference. For example, if I added a method in Tune, I've added it in `doc/source/tune/api/` under the corresponding `.rst` file. - [x] I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/ - Testing Strategy - [x] This PR is not tested :( --------- Signed-off-by: Daniel Sperber <[email protected]> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Why are these changes needed?
Follow up of RLlib PR: #55291
Torch
deviceallows input types ofstr | int | torch.device, this PR unifies the type in a type variable and allows for theinttype as well.Necessary sister PR: #56743 introducing the used type-hint in
dataChecks
git commit -s) in this PR.scripts/format.shto lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/under thecorresponding
.rstfile.