[Serve] Add label_selector and bundle_label_selector to Serve API#57694
Conversation
Signed-off-by: Ryan O'Leary <ryanaoleary@google.com>
|
cc: @MengjinYan @eicherseiji I think this change can help enable TPU use-cases with Ray LLM, since it'll allow users to target the desired slice/topology based on labels like these: |
MengjinYan
left a comment
There was a problem hiding this comment.
The current change looks good.
At the same time, I have a general question, probably also to @eicherseiji as well: I'm not familiar with the serve codebase. But from the look at the code, the change in the PR seems not cover the whole code path from the replica config to actually creating the placement group where we need to apply the bundle label selector (e.g. CreatePlacementGroupRequest, DeploymentTargetState, DeploymentVersion, etc.).
Wondering if we should include the change to the rest of the code path in this PR as well?
|
Hi @ryanaoleary! Seems like it may be useful, but could you go into more detail about the problem this solved for you? I.e. is it typical to have multiple TPU node pools/heterogeneous compute in a TPU cluster? |
Signed-off-by: Ryan O'Leary <ryanaoleary@google.com>
The use-case would be for TPU multi-slice, where it's important that the Ray nodes reserved with some group of resources (i.e. a bundle of TPUs) are a part of the same actual TPU slice so that they can benefit from the high speed ICI interconnects. There are GKE webhooks that set some TPU information as env vars when the Pods are created, including topology and a unique identifier for the slice which we set as Ray node labels. They also inject For a RayCluster with multiple TPU slices (of the same topology or different), we currently only schedule using |
|
@ryanaoleary I see, thanks! Is there a reason we can't extend/re-use the |
In addition to the TPU support, in general, we want to have label support in all library APIs so that user can do scheduling based on node labels as well. |
I think just configuring |
|
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. |
|
@ryanaoleary I will review this PR next week |
|
thanks for working on this! Really looking forward to using label selectors in Serve. |
Sorry should be fixed with c225938 |
Signed-off-by: ryanaoleary <ryanaoleary@google.com>
Signed-off-by: ryanaoleary <ryanaoleary@google.com>
Signed-off-by: ryanaoleary <ryanaoleary@google.com>
…easible Signed-off-by: ryanaoleary <ryanaoleary@google.com>
|
I believe I fixed the CI error with 561f814, |
… module scope Signed-off-by: ryanaoleary <ryanaoleary@google.com>
Signed-off-by: Ryan O'Leary <113500783+ryanaoleary@users.noreply.github.com>
|
cc: @abrarsheikh for merge |
|
@MengjinYan want to take another pass at the core changes? |
Co-authored-by: Mengjin Yan <mengjinyan3@gmail.com> Signed-off-by: Ryan O'Leary <113500783+ryanaoleary@users.noreply.github.com>
Signed-off-by: ryanaoleary <ryanaoleary@google.com>
|
solid work on this @ryanaoleary 👍 |
Thank you again for your help!! |
…ray-project#57694) <!-- Thank you for your contribution! Please review https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before opening a pull request. --> <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? This PR adds the `label_selector` option to the supported list of Actor options for a Serve deployment. Additionally, we add `bundle_label_selector` to specify label selectors for bundles when `placement_group_bundles` are specified for the deployment. These two options are already supported for Tasks/Actors and placement groups respectively. Example use case: ``` llm_config = LLMConfig( model_loading_config={ "model_id": "meta-llama/Meta-Llama-3-70B-Instruct", "model_source": "huggingface", }, engine_kwargs=tpu_engine_config, resources_per_bundle={"TPU": 4}, runtime_env={"env_vars": {"VLLM_USE_V1": "1"}}, deployment_config={ "num_replicas": 4, "ray_actor_options": { # In a GKE cluster with multiple TPU node-pools, schedule # only to the desired slice. "label_selector": { "ray.io/tpu-topology": "4x4" # added by default by Ray } } } ) ``` The expected behaviors of these new fields is as follows: **Pack scheduling enabled** ---------------------------------------- **PACK/STRICT_PACK PG strategy:** - Standard PG without bundle_label_selector or fallback: - Sorts replicas by resource size (descending). Attempts to find the "best fit" node (minimizing fragmentation) that has available resources. Creates a Placement Group on that target node. - PG node label selector provided: - Same behavior as regular placement group but filters the list of candidate nodes to only those matching the label selector before finding the best fit - PG node label selector and fallback: Same as above but when scheduling tries the following: 1. Tries to find a node matching the primary placement_group_bundles and bundle_label_selector. 2. If no node fits, iterates through the placement_group_fallback_strategy. For each fallback entry, tries to find a node matching that entry's bundles and labels. 3. If a node is found, creates a PG on it. **SPREAD/STRICT_SPREAD PG strategy:** - If any deployment uses these strategies, the global logic falls back to "Spread Scheduling" (see below) **Spread scheduling enabled** ---------------------------------------- - Standard PG without bundle_label_selector or fallback: - Creates a Placement Group via Ray Core without specifying a target_node_id. Ray Core decides placement based on the strategy. - PG node label selector provided: - Serve passes the bundle_label_selector to the CreatePlacementGroupRequest. Ray Core handles the soft/hard constraint logic during PG creation. - PG node label selector and fallback: - Serve passes the bundle_label_selector to the CreatePlacementGroupRequest, fallback_strategy is not yet supported in the placement group options so this field isn't passed / considered. It's only used in the "best fit" node selection logic which is skipped for Spread scheduling. ## Related issue number ray-project#51564 ## 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 pre-commit jobs to lint the changes in this PR. ([pre-commit setup](https://docs.ray.io/en/latest/ray-contribute/getting-involved.html#lint-and-formatting)) - [ ] 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. - [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] Unit tests - [ ] Release tests - [ ] This PR is not tested :( --------- Signed-off-by: Ryan O'Leary <ryanaoleary@google.com> Signed-off-by: ryanaoleary <ryanaoleary@google.com> Signed-off-by: Ryan O'Leary <113500783+ryanaoleary@users.noreply.github.com> Co-authored-by: Cindy Zhang <cindyzyx9@gmail.com> Co-authored-by: Abrar Sheikh <abrar2002as@gmail.com> Co-authored-by: Mengjin Yan <mengjinyan3@gmail.com> Signed-off-by: jinbum-kim <jinbum9958@gmail.com>
…ray-project#57694) <!-- Thank you for your contribution! Please review https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before opening a pull request. --> <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? This PR adds the `label_selector` option to the supported list of Actor options for a Serve deployment. Additionally, we add `bundle_label_selector` to specify label selectors for bundles when `placement_group_bundles` are specified for the deployment. These two options are already supported for Tasks/Actors and placement groups respectively. Example use case: ``` llm_config = LLMConfig( model_loading_config={ "model_id": "meta-llama/Meta-Llama-3-70B-Instruct", "model_source": "huggingface", }, engine_kwargs=tpu_engine_config, resources_per_bundle={"TPU": 4}, runtime_env={"env_vars": {"VLLM_USE_V1": "1"}}, deployment_config={ "num_replicas": 4, "ray_actor_options": { # In a GKE cluster with multiple TPU node-pools, schedule # only to the desired slice. "label_selector": { "ray.io/tpu-topology": "4x4" # added by default by Ray } } } ) ``` The expected behaviors of these new fields is as follows: **Pack scheduling enabled** ---------------------------------------- **PACK/STRICT_PACK PG strategy:** - Standard PG without bundle_label_selector or fallback: - Sorts replicas by resource size (descending). Attempts to find the "best fit" node (minimizing fragmentation) that has available resources. Creates a Placement Group on that target node. - PG node label selector provided: - Same behavior as regular placement group but filters the list of candidate nodes to only those matching the label selector before finding the best fit - PG node label selector and fallback: Same as above but when scheduling tries the following: 1. Tries to find a node matching the primary placement_group_bundles and bundle_label_selector. 2. If no node fits, iterates through the placement_group_fallback_strategy. For each fallback entry, tries to find a node matching that entry's bundles and labels. 3. If a node is found, creates a PG on it. **SPREAD/STRICT_SPREAD PG strategy:** - If any deployment uses these strategies, the global logic falls back to "Spread Scheduling" (see below) **Spread scheduling enabled** ---------------------------------------- - Standard PG without bundle_label_selector or fallback: - Creates a Placement Group via Ray Core without specifying a target_node_id. Ray Core decides placement based on the strategy. - PG node label selector provided: - Serve passes the bundle_label_selector to the CreatePlacementGroupRequest. Ray Core handles the soft/hard constraint logic during PG creation. - PG node label selector and fallback: - Serve passes the bundle_label_selector to the CreatePlacementGroupRequest, fallback_strategy is not yet supported in the placement group options so this field isn't passed / considered. It's only used in the "best fit" node selection logic which is skipped for Spread scheduling. ## Related issue number ray-project#51564 ## 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 pre-commit jobs to lint the changes in this PR. ([pre-commit setup](https://docs.ray.io/en/latest/ray-contribute/getting-involved.html#lint-and-formatting)) - [ ] 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. - [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] Unit tests - [ ] Release tests - [ ] This PR is not tested :( --------- Signed-off-by: Ryan O'Leary <ryanaoleary@google.com> Signed-off-by: ryanaoleary <ryanaoleary@google.com> Signed-off-by: Ryan O'Leary <113500783+ryanaoleary@users.noreply.github.com> Co-authored-by: Cindy Zhang <cindyzyx9@gmail.com> Co-authored-by: Abrar Sheikh <abrar2002as@gmail.com> Co-authored-by: Mengjin Yan <mengjinyan3@gmail.com>
…ray-project#57694) <!-- Thank you for your contribution! Please review https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before opening a pull request. --> <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? This PR adds the `label_selector` option to the supported list of Actor options for a Serve deployment. Additionally, we add `bundle_label_selector` to specify label selectors for bundles when `placement_group_bundles` are specified for the deployment. These two options are already supported for Tasks/Actors and placement groups respectively. Example use case: ``` llm_config = LLMConfig( model_loading_config={ "model_id": "meta-llama/Meta-Llama-3-70B-Instruct", "model_source": "huggingface", }, engine_kwargs=tpu_engine_config, resources_per_bundle={"TPU": 4}, runtime_env={"env_vars": {"VLLM_USE_V1": "1"}}, deployment_config={ "num_replicas": 4, "ray_actor_options": { # In a GKE cluster with multiple TPU node-pools, schedule # only to the desired slice. "label_selector": { "ray.io/tpu-topology": "4x4" # added by default by Ray } } } ) ``` The expected behaviors of these new fields is as follows: **Pack scheduling enabled** ---------------------------------------- **PACK/STRICT_PACK PG strategy:** - Standard PG without bundle_label_selector or fallback: - Sorts replicas by resource size (descending). Attempts to find the "best fit" node (minimizing fragmentation) that has available resources. Creates a Placement Group on that target node. - PG node label selector provided: - Same behavior as regular placement group but filters the list of candidate nodes to only those matching the label selector before finding the best fit - PG node label selector and fallback: Same as above but when scheduling tries the following: 1. Tries to find a node matching the primary placement_group_bundles and bundle_label_selector. 2. If no node fits, iterates through the placement_group_fallback_strategy. For each fallback entry, tries to find a node matching that entry's bundles and labels. 3. If a node is found, creates a PG on it. **SPREAD/STRICT_SPREAD PG strategy:** - If any deployment uses these strategies, the global logic falls back to "Spread Scheduling" (see below) **Spread scheduling enabled** ---------------------------------------- - Standard PG without bundle_label_selector or fallback: - Creates a Placement Group via Ray Core without specifying a target_node_id. Ray Core decides placement based on the strategy. - PG node label selector provided: - Serve passes the bundle_label_selector to the CreatePlacementGroupRequest. Ray Core handles the soft/hard constraint logic during PG creation. - PG node label selector and fallback: - Serve passes the bundle_label_selector to the CreatePlacementGroupRequest, fallback_strategy is not yet supported in the placement group options so this field isn't passed / considered. It's only used in the "best fit" node selection logic which is skipped for Spread scheduling. ## Related issue number ray-project#51564 ## 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 pre-commit jobs to lint the changes in this PR. ([pre-commit setup](https://docs.ray.io/en/latest/ray-contribute/getting-involved.html#lint-and-formatting)) - [ ] 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. - [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] Unit tests - [ ] Release tests - [ ] This PR is not tested :( --------- Signed-off-by: Ryan O'Leary <ryanaoleary@google.com> Signed-off-by: ryanaoleary <ryanaoleary@google.com> Signed-off-by: Ryan O'Leary <113500783+ryanaoleary@users.noreply.github.com> Co-authored-by: Cindy Zhang <cindyzyx9@gmail.com> Co-authored-by: Abrar Sheikh <abrar2002as@gmail.com> Co-authored-by: Mengjin Yan <mengjinyan3@gmail.com> Signed-off-by: 400Ping <jiekaichang@apache.org>
Why are these changes needed?
This PR adds the
label_selectoroption to the supported list of Actor options for a Serve deployment. Additionally, we addbundle_label_selectorto specify label selectors for bundles whenplacement_group_bundlesare specified for the deployment. These two options are already supported for Tasks/Actors and placement groups respectively.Example use case:
The expected behaviors of these new fields is as follows:
Pack scheduling enabled
PACK/STRICT_PACK PG strategy:
Standard PG without bundle_label_selector or fallback:
PG node label selector provided:
PG node label selector and fallback:
Same as above but when scheduling tries the following:
SPREAD/STRICT_SPREAD PG strategy:
Spread scheduling enabled
Related issue number
#51564
Checks
git commit -s) in this PR.method in Tune, I've added it in
doc/source/tune/api/under thecorresponding
.rstfile.