You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Serve] Add label_selector and bundle_label_selector to Serve API (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>
0 commit comments