Skip to content

Conversation

@ryanaoleary
Copy link
Contributor

Why are these changes needed?

In KubeRay v1.5, new structured Resources and Labels fields will be added to both the HeadGroupSpec and WorkerGroupSpec to enable users to explicitly define these values without relying on rayStartParams. This support is implemented in ray-project/kuberay#4106. In order for this change to work with the Ray autoscaler, this PR adds support for checking the resources and labels field (with precedence over the values rayStartParams and k8s constainer spec) and generating the resulting autoscaling config. This change is compatible with older versions of KubeRay that do not have these new fields, since we fall back to the previous logic when the top-level fields aren't specified.

Example:

For a group spec specified like this:

workerGroupSpecs:
- groupName: worker-group-1
  replicas: 1
  resources:
    GPU: 8
    CPU: 16
  labels:
    ray.io/zone: us-west2-a
    ray.io/region: us-west2

The resulting autoscaling config for worker-group-1 would be:

"worker-group-1": {
  "labels": {" ray.io/zone": "us-west2-a", " ray.io/region": "us-west2"},
  ...
  "resources": {
    "CPU": 16,
    GPU: 8,
  },
},

Related issue number

Contributes to #51564

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run pre-commit jobs to lint the changes in this PR. (pre-commit setup)
  • 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 :(

@ryanaoleary ryanaoleary requested a review from a team as a code owner October 7, 2025 04:55
@ryanaoleary
Copy link
Contributor Author

cc: @MengjinYan @Future-Outlier @rueian

cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for top-level Resources and Labels fields in the KubeRay autoscaling configuration, which is a great enhancement for usability and alignment with upcoming KubeRay features. The implementation correctly prioritizes these new fields over older configuration methods. The accompanying tests are thorough and cover the new functionality well. I've identified a few areas for improvement, mainly concerning type consistency in function signatures and return values, which could prevent potential bugs and improve code clarity. There is also a minor documentation error in a docstring. Overall, this is a solid contribution.

@ray-gardener ray-gardener bot added kuberay Issues for the Ray/Kuberay integration that are tracked on the Ray side core Issues that should be addressed in Ray Core community-contribution Contributed by the community labels Oct 7, 2025
@MengjinYan MengjinYan self-assigned this Oct 7, 2025
Signed-off-by: Ryan O'Leary <[email protected]>
cursor[bot]

This comment was marked as outdated.

Signed-off-by: Ryan O'Leary <[email protected]>
cursor[bot]

This comment was marked as outdated.

Signed-off-by: Ryan O'Leary <[email protected]>
Copy link
Contributor

@MengjinYan MengjinYan left a comment

Choose a reason for hiding this comment

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

Just one curious question. Overall looks good!

Also you might need to fix the doc lint issue:

[2025-10-11T01:27:22Z] ./python/ray/autoscaler/_private/kuberay/autoscaling_config.py:            f"Ignoring labels: {labels_str} set in rayStartParams. Group labels are supported in the top-level Labels field starting in Kuberay v1.5"
[2025-10-11T01:27:22Z] ./python/ray/tests/kuberay/test_autoscaling_config.py:            "Ignoring labels: ray.io/accelerator-type=TPU-V4 set in rayStartParams. Group labels are supported in the top-level Labels field starting in Kuberay v1.5",
[2025-10-11T01:27:22Z] ./python/ray/tests/kuberay/test_autoscaling_config.py:            "Ignoring labels: instance-type=n2 set in rayStartParams. Group labels are supported in the top-level Labels field starting in Kuberay v1.5",
[2025-10-11T01:27:22Z] ******************************
[2025-10-11T01:27:22Z] *** Misspelled word found! ***
[2025-10-11T01:27:22Z] ******************************
[2025-10-11T01:27:22Z] Please fix the capitalization/spelling of "Kuberay" in the above files.```

@MengjinYan MengjinYan added the go add ONLY when ready to merge, run all tests label Oct 15, 2025
@ryanaoleary
Copy link
Contributor Author

Just one curious question. Overall looks good!

Also you might need to fix the doc lint issue:

[2025-10-11T01:27:22Z] ./python/ray/autoscaler/_private/kuberay/autoscaling_config.py:            f"Ignoring labels: {labels_str} set in rayStartParams. Group labels are supported in the top-level Labels field starting in Kuberay v1.5"
[2025-10-11T01:27:22Z] ./python/ray/tests/kuberay/test_autoscaling_config.py:            "Ignoring labels: ray.io/accelerator-type=TPU-V4 set in rayStartParams. Group labels are supported in the top-level Labels field starting in Kuberay v1.5",
[2025-10-11T01:27:22Z] ./python/ray/tests/kuberay/test_autoscaling_config.py:            "Ignoring labels: instance-type=n2 set in rayStartParams. Group labels are supported in the top-level Labels field starting in Kuberay v1.5",
[2025-10-11T01:27:22Z] ******************************
[2025-10-11T01:27:22Z] *** Misspelled word found! ***
[2025-10-11T01:27:22Z] ******************************
[2025-10-11T01:27:22Z] Please fix the capitalization/spelling of "Kuberay" in the above files.```

Oh I think I've seen this before, it's because I failed to capitalize the "R" in "KubeRay". Should be fixed with d0ea801.

Copy link
Contributor

@MengjinYan MengjinYan left a comment

Choose a reason for hiding this comment

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

Thanks!

@MengjinYan
Copy link
Contributor

@rueian if you want to take a look from autoscaler's perspective.

@MengjinYan
Copy link
Contributor

@jjyao @edoakes

Copy link
Collaborator

@edoakes edoakes left a comment

Choose a reason for hiding this comment

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

🚀

@edoakes edoakes merged commit e890cd1 into ray-project:master Oct 17, 2025
6 checks passed
justinyeh1995 pushed a commit to justinyeh1995/ray that referenced this pull request Oct 20, 2025
…Autoscaling config (ray-project#57260)

In KubeRay v1.5, new structured `Resources` and `Labels` fields will be
added to both the `HeadGroupSpec` and `WorkerGroupSpec` to enable users
to explicitly define these values without relying on `rayStartParams`.
This support is implemented in
ray-project/kuberay#4106. In order for this
change to work with the Ray autoscaler, this PR adds support for
checking the `resources` and `labels` field (with precedence over the
values `rayStartParams` and k8s constainer spec) and generating the
resulting autoscaling config. This change is compatible with older
versions of KubeRay that do not have these new fields, since we fall
back to the previous logic when the top-level fields aren't specified.

Example:

For a group spec specified like this:
```
workerGroupSpecs:
- groupName: worker-group-1
  replicas: 1
  resources:
    GPU: 8
    CPU: 16
  labels:
    ray.io/zone: us-west2-a
    ray.io/region: us-west2
```

The resulting autoscaling config for worker-group-1 would be:
```
"worker-group-1": {
  "labels": {" ray.io/zone": "us-west2-a", " ray.io/region": "us-west2"},
  ...
  "resources": {
    "CPU": 16,
    GPU: 8,
  },
},
``` 

## Related issue number

Contributes to ray-project#51564

---------

Signed-off-by: Ryan O'Leary <[email protected]>
xinyuangui2 pushed a commit to xinyuangui2/ray that referenced this pull request Oct 22, 2025
…Autoscaling config (ray-project#57260)

In KubeRay v1.5, new structured `Resources` and `Labels` fields will be
added to both the `HeadGroupSpec` and `WorkerGroupSpec` to enable users
to explicitly define these values without relying on `rayStartParams`.
This support is implemented in
ray-project/kuberay#4106. In order for this
change to work with the Ray autoscaler, this PR adds support for
checking the `resources` and `labels` field (with precedence over the
values `rayStartParams` and k8s constainer spec) and generating the
resulting autoscaling config. This change is compatible with older
versions of KubeRay that do not have these new fields, since we fall
back to the previous logic when the top-level fields aren't specified.

Example:

For a group spec specified like this:
```
workerGroupSpecs:
- groupName: worker-group-1
  replicas: 1
  resources:
    GPU: 8
    CPU: 16
  labels:
    ray.io/zone: us-west2-a
    ray.io/region: us-west2
```

The resulting autoscaling config for worker-group-1 would be:
```
"worker-group-1": {
  "labels": {" ray.io/zone": "us-west2-a", " ray.io/region": "us-west2"},
  ...
  "resources": {
    "CPU": 16,
    GPU: 8,
  },
},
```

## Related issue number

Contributes to ray-project#51564

---------

Signed-off-by: Ryan O'Leary <[email protected]>
Signed-off-by: xgui <[email protected]>
elliot-barn pushed a commit that referenced this pull request Oct 23, 2025
…Autoscaling config (#57260)

In KubeRay v1.5, new structured `Resources` and `Labels` fields will be
added to both the `HeadGroupSpec` and `WorkerGroupSpec` to enable users
to explicitly define these values without relying on `rayStartParams`.
This support is implemented in
ray-project/kuberay#4106. In order for this
change to work with the Ray autoscaler, this PR adds support for
checking the `resources` and `labels` field (with precedence over the
values `rayStartParams` and k8s constainer spec) and generating the
resulting autoscaling config. This change is compatible with older
versions of KubeRay that do not have these new fields, since we fall
back to the previous logic when the top-level fields aren't specified.

Example:

For a group spec specified like this:
```
workerGroupSpecs:
- groupName: worker-group-1
  replicas: 1
  resources:
    GPU: 8
    CPU: 16
  labels:
    ray.io/zone: us-west2-a
    ray.io/region: us-west2
```

The resulting autoscaling config for worker-group-1 would be:
```
"worker-group-1": {
  "labels": {" ray.io/zone": "us-west2-a", " ray.io/region": "us-west2"},
  ...
  "resources": {
    "CPU": 16,
    GPU: 8,
  },
},
``` 

## Related issue number

Contributes to #51564

---------

Signed-off-by: Ryan O'Leary <[email protected]>
Signed-off-by: elliot-barn <[email protected]>
landscapepainter pushed a commit to landscapepainter/ray that referenced this pull request Nov 17, 2025
…Autoscaling config (ray-project#57260)

In KubeRay v1.5, new structured `Resources` and `Labels` fields will be
added to both the `HeadGroupSpec` and `WorkerGroupSpec` to enable users
to explicitly define these values without relying on `rayStartParams`.
This support is implemented in
ray-project/kuberay#4106. In order for this
change to work with the Ray autoscaler, this PR adds support for
checking the `resources` and `labels` field (with precedence over the
values `rayStartParams` and k8s constainer spec) and generating the
resulting autoscaling config. This change is compatible with older
versions of KubeRay that do not have these new fields, since we fall
back to the previous logic when the top-level fields aren't specified.

Example:

For a group spec specified like this:
```
workerGroupSpecs:
- groupName: worker-group-1
  replicas: 1
  resources:
    GPU: 8
    CPU: 16
  labels:
    ray.io/zone: us-west2-a
    ray.io/region: us-west2
```

The resulting autoscaling config for worker-group-1 would be:
```
"worker-group-1": {
  "labels": {" ray.io/zone": "us-west2-a", " ray.io/region": "us-west2"},
  ...
  "resources": {
    "CPU": 16,
    GPU: 8,
  },
},
``` 

## Related issue number

Contributes to ray-project#51564

---------

Signed-off-by: Ryan O'Leary <[email protected]>
Aydin-ab pushed a commit to Aydin-ab/ray-aydin that referenced this pull request Nov 19, 2025
…Autoscaling config (ray-project#57260)

In KubeRay v1.5, new structured `Resources` and `Labels` fields will be
added to both the `HeadGroupSpec` and `WorkerGroupSpec` to enable users
to explicitly define these values without relying on `rayStartParams`.
This support is implemented in
ray-project/kuberay#4106. In order for this
change to work with the Ray autoscaler, this PR adds support for
checking the `resources` and `labels` field (with precedence over the
values `rayStartParams` and k8s constainer spec) and generating the
resulting autoscaling config. This change is compatible with older
versions of KubeRay that do not have these new fields, since we fall
back to the previous logic when the top-level fields aren't specified.

Example:

For a group spec specified like this:
```
workerGroupSpecs:
- groupName: worker-group-1
  replicas: 1
  resources:
    GPU: 8
    CPU: 16
  labels:
    ray.io/zone: us-west2-a
    ray.io/region: us-west2
```

The resulting autoscaling config for worker-group-1 would be:
```
"worker-group-1": {
  "labels": {" ray.io/zone": "us-west2-a", " ray.io/region": "us-west2"},
  ...
  "resources": {
    "CPU": 16,
    GPU: 8,
  },
},
```

## Related issue number

Contributes to ray-project#51564

---------

Signed-off-by: Ryan O'Leary <[email protected]>
Signed-off-by: Aydin Abiar <[email protected]>
Future-Outlier pushed a commit to Future-Outlier/ray that referenced this pull request Dec 7, 2025
…Autoscaling config (ray-project#57260)

In KubeRay v1.5, new structured `Resources` and `Labels` fields will be
added to both the `HeadGroupSpec` and `WorkerGroupSpec` to enable users
to explicitly define these values without relying on `rayStartParams`.
This support is implemented in
ray-project/kuberay#4106. In order for this
change to work with the Ray autoscaler, this PR adds support for
checking the `resources` and `labels` field (with precedence over the
values `rayStartParams` and k8s constainer spec) and generating the
resulting autoscaling config. This change is compatible with older
versions of KubeRay that do not have these new fields, since we fall
back to the previous logic when the top-level fields aren't specified.

Example:

For a group spec specified like this:
```
workerGroupSpecs:
- groupName: worker-group-1
  replicas: 1
  resources:
    GPU: 8
    CPU: 16
  labels:
    ray.io/zone: us-west2-a
    ray.io/region: us-west2
```

The resulting autoscaling config for worker-group-1 would be:
```
"worker-group-1": {
  "labels": {" ray.io/zone": "us-west2-a", " ray.io/region": "us-west2"},
  ...
  "resources": {
    "CPU": 16,
    GPU: 8,
  },
},
```

## Related issue number

Contributes to ray-project#51564

---------

Signed-off-by: Ryan O'Leary <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community core Issues that should be addressed in Ray Core go add ONLY when ready to merge, run all tests kuberay Issues for the Ray/Kuberay integration that are tracked on the Ray side

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants