Skip to content

Conversation

@Daraan
Copy link
Contributor

@Daraan Daraan commented Sep 19, 2025

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.

Necessary sister PR: #56743 introducing the used type-hint in data

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • 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.
  • 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
    • No further testing necessary, Typing changes only

@Daraan Daraan requested a review from a team as a code owner September 19, 2025 09:30
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

@ray-gardener ray-gardener bot added train Ray Train Related Issue data Ray Data-related issues community-contribution Contributed by the community labels Sep 19, 2025
Signed-off-by: Daniel Sperber <[email protected]>
@gvspraveen gvspraveen removed the data Ray Data-related issues label Sep 21, 2025
@github-actions
Copy link

github-actions bot commented Oct 6, 2025

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

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.

@github-actions github-actions bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Oct 6, 2025
@Daraan
Copy link
Contributor Author

Daraan commented Oct 6, 2025

(~ ̄(OO) ̄)ブ stale

@github-actions github-actions bot added unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it. and removed stale The issue is stale. It will be closed within 7 days unless there are further conversation labels Oct 6, 2025
raulchen pushed a commit that referenced this pull request Nov 19, 2025
## 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>
400Ping pushed a commit to 400Ping/ray that referenced this pull request Nov 21, 2025
…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>
ykdojo pushed a commit to ykdojo/ray that referenced this pull request Nov 27, 2025
…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]>
SheldonTsen pushed a commit to SheldonTsen/ray that referenced this pull request Dec 1, 2025
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community train Ray Train Related Issue unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants