Skip to content
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

[Ray Core] Adds in Google Cloud TPUs as a native Resource (#38669) #39352

Merged

Conversation

architkulkarni
Copy link
Contributor

Cherry-pick of #38669 to the release branch.

The description of that PR is copy-pasted below.


Why are these changes needed?

The issue below has more details, but at a high level this change addresses the feature request of adding in TPUs as a native resource within Ray.

To a user, these changes intend to shift from:

@ray.remote(resources={"TPU": 1})
def my_function():
    ...

to

@ray.remote(num_tpus=4)
def my_function():
    ...

Since we're adding TPUs as a native resource, this gives users the added ability to access individual TPU chips in a TPU host, e.g. the following would be valid:

@ray.remote(num_tpus=1) # or 2
def my_function():
    import jax
    print(jax.device_count()) -> 1 (or 2)

This is enabled by setting environment variables as described in jax-ml/jax#14977.

Short overview of changes:

  • Add in autodetect num TPU chips + TPU version (+ tests for each)
  • Adds in num_tpus in ray_params and does input sanitization similar to how GPUs function (e.g. num_tpus instead of TPU in resources)
  • Adds in several constants
  • Since there are a lot of changes related to neuron cores (from Auto-detection of accelerator_type for aws_accelerators trn1_inf #37998) I tried to consolidate the neuron core specific logic with TPU logic where applicable, for instance changing _validate_neuron_core_accelerator -> _validate_accelerator in ray_option_utils.py
  • And added in a lot of tests!

Related issue number

#38085

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/.
    • 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
    • Unit tests
    • Release tests
    • This PR is not tested :(

…t#38669)

The issue below has more details, but at a high level this change addresses the feature request of adding in TPUs as a native resource within Ray.

---------

Signed-off-by: allenwang28 <[email protected]>
Signed-off-by: Archit Kulkarni <[email protected]>
Co-authored-by: Archit Kulkarni <[email protected]>
Signed-off-by: Archit Kulkarni <[email protected]>
Copy link
Collaborator

@zhe-thoughts zhe-thoughts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a must-have feature in 2.7. But let's be careful about possible issues on the release branch

@GeneDer GeneDer merged commit a94f97d into ray-project:releases/2.7.0 Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-blocker P0 Issue that blocks the release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants