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] [Serve] Add docs for custom resources with Serve #28529

Merged
merged 6 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions doc/source/serve/scaling-and-resource-allocation.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ def func_2(*args):

In this example, each replica of each deployment will be allocated 0.5 GPUs. The same can be done to multiplex over CPUs, using `"num_cpus"`.

### Custom Resources

You can also specify [custom resources](custom-resources) in `ray_actor_options`, for example to ensure that a deployment is scheduled on a specific node.
For example, if you have a deployment that requires 2 units of the `"custom_resource"` resource, you can specify it like this:

```python
@serve.deployment(ray_actor_options={"resources": {"custom_resource": 2}})
def func(*args):
return do_something_with_my_custom_resource()
```

(serve-omp-num-threads)=

## Configuring Parallelism with OMP_NUM_THREADS
Expand Down
4 changes: 3 additions & 1 deletion python/ray/serve/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,9 @@ def deployment(
a '/' unless they're the root (just '/'), which acts as a
catch-all.
ray_actor_options: Options to be passed to the Ray actor
constructor such as resource requirements.
constructor such as resource requirements. Valid options are
`accellerator_type`, `memory`, `num_cpus`, `num_gpus`,
architkulkarni marked this conversation as resolved.
Show resolved Hide resolved
`object_store_memory`, `resources`, and `runtime_env`.
user_config (Optional[Any]): Config to pass to the
reconfigure method of the deployment. This can be updated
dynamically without changing the version of the deployment and
Expand Down
3 changes: 2 additions & 1 deletion python/ray/serve/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ def _validate_ray_actor_options(self) -> None:
f'Got invalid type "{type(self.ray_actor_options)}" for '
"ray_actor_options. Expected a dictionary."
)

# Please keep this in sync with the docstring for the ray_actor_options
# kwarg in api.py.
allowed_ray_actor_options = {
# Resource options
"accelerator_type",
Expand Down