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

[Doc][Train] Add accelerator_type to Ray Train user guide #44882

Merged
merged 11 commits into from
Apr 24, 2024

Conversation

hongpeng-guo
Copy link
Contributor

@hongpeng-guo hongpeng-guo commented Apr 20, 2024

Why are these changes needed?

Our ScalingConfig() function supports a new argument accelerator_type. This PR provides a user guide with example code to showcase the usage. The generated section of the user guide is appended below:

Screenshot 2024-04-22 at 7 35 27 PM

Related issue number

"Closes #44763

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 :(

Signed-off-by: Hongpeng Guo <hpguo@anyscale.com>
@justinvyu
Copy link
Contributor

Tip if you haven't seen this already: we build the docs as part of the premerge CI, so you can take a look at your rendered docs: https://anyscale-ray--44882.com.readthedocs.build/en/44882/index.html

Screenshot 2024-04-22 at 11 04 34 AM

@hongpeng-guo
Copy link
Contributor Author

Tip if you haven't seen this already: we build the docs as part of the premerge CI, so you can take a look at your rendered docs: https://anyscale-ray--44882.com.readthedocs.build/en/44882/index.html

Screenshot 2024-04-22 at 11 04 34 AM

Nice tips! ty

Copy link
Contributor

@justinvyu justinvyu left a comment

Choose a reason for hiding this comment

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

Nice! Made some edit suggestions.

Comment on lines 109 to 111
Sometimes you might want to specify the accelerator type for a worker. For example,
you can specify `accelerator_type="A100"` in the `ScalingConfig` if you want to
assign the worker an NVIDIA A100 GPU.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Sometimes you might want to specify the accelerator type for a worker. For example,
you can specify `accelerator_type="A100"` in the `ScalingConfig` if you want to
assign the worker an NVIDIA A100 GPU.
Ray Train allows you to specify the accelerator type for each worker.
This is useful if your model training has some GPU memory constraints that requires a specific type of GPU.
In a heterogeneous Ray cluster, this means that your training workers will be forced to run on the specified GPU type, rather than on any arbitrary GPU node.
For example, you can specify `accelerator_type="A100"` in the :class:`~ray.train.ScalingConfig` if you want to
assign each worker a NVIDIA A100 GPU.

Comment on lines 119 to 138
import torch
from ray.train import ScalingConfig
from ray.train.torch import TorchTrainer, get_device


def train_func():
assert torch.cuda.is_available()

device = get_device()
assert device == torch.device("cuda:0")

trainer = TorchTrainer(
train_func,
scaling_config=ScalingConfig(
num_workers=1,
use_gpu=True,
accelerator_type="A100"
)
)
trainer.fit()
Copy link
Contributor

Choose a reason for hiding this comment

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

We can cut this down to just show the ScalingConfig.

Comment on lines 121 to 132
from ray.train import ScalingConfig
from ray.train.torch import TorchTrainer


trainer = TorchTrainer(
train_func,
scaling_config=ScalingConfig(
num_workers=1,
use_gpu=True,
accelerator_type="A100"
)
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, for this one, I'm thinking of just showing:

ScalingConfig(...)

Comment on lines 116 to 117
Ensure that your cluster has instances with the specified accelerator type
or is able to autoscale to fulfill the request.
Copy link
Contributor

Choose a reason for hiding this comment

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

We can make this a tip:

.. tip::
    Ensure that your cluster has instances with the specified accelerator type 
or is able to autoscale to fulfill the request.
    Otherwise, your job will hang forever due to unsatisfiable pending resource requests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh nice tip structure. Will try.

Signed-off-by: Hongpeng Guo <hpguo@anyscale.com>
Signed-off-by: Hongpeng Guo <hpguo@anyscale.com>
Comment on lines 123 to 127
ScalingConfig(
num_workers=1,
use_gpu=True,
accelerator_type="A100"
)
Copy link
Member

Choose a reason for hiding this comment

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

Fix the indent here?

Setting the GPU type
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ray Train allows you to specify the accelerator type for each worker.
This is useful if your model training has some GPU memory constraints that requires a specific type of GPU.
Copy link
Member

Choose a reason for hiding this comment

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

Users may want to use different accelerator types not only for GPU memory constraints, but also for e.g. compute power, cost efficiency, availability, etc.

Let's just say This is useful if you want to use a specific accelerator type for model training.

Signed-off-by: Hongpeng Guo <hpguo@anyscale.com>
Signed-off-by: Hongpeng Guo <hpguo@anyscale.com>
Signed-off-by: Hongpeng Guo <hpguo@anyscale.com>
Copy link
Member

@woshiyyya woshiyyya left a comment

Choose a reason for hiding this comment

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

Nice work!

Copy link
Contributor

@justinvyu justinvyu left a comment

Choose a reason for hiding this comment

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

Nice!

@justinvyu justinvyu changed the title [Doc][Train] Add accelerator_type to Ray Train user guides [Doc][Train] Add accelerator_type to Ray Train user guide Apr 24, 2024
@justinvyu justinvyu merged commit 0da794c into ray-project:master Apr 24, 2024
5 checks passed
@hongpeng-guo hongpeng-guo deleted the doc-accelerator-type branch April 25, 2024 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[doc][train] Document ScalingConfig(accelerator_type) in user guide
4 participants