Skip to content

Commit 9697d7a

Browse files
ppiegazedocsy
andauthored
docsy(v2): document Ray autoscaler_options (AutoscalerOptionsConfig) (#1463)
* docs: document Ray autoscaler_options / AutoscalerOptionsConfig The Ray page documented enable_autoscaling, the on/off switch, but nothing that configures it: no autoscaler_options row and no mention of AutoscalerOptionsConfig anywhere. The generated reference already carries the class (content/api-reference/integrations/ray/autoscaleroptionsconfig.md, added by regen #1442), so only the narrative lagged. Its generated parameter table has empty descriptions, since the generator does not parse the docstring field list, which is why the narrative table is worth having. New in v2.6.1: autoscaler_options has 0 occurrences in v2.6.0:plugins/ray/src/flyteplugins/ray/task.py and 4 in v2.6.1. Three behaviors documented because they are not inferable from the signature: - autoscaler_options does not enable autoscaling. The Go plugin sets EnableInTreeAutoscaling and AutoscalerOptions as independent fields on the RayCluster spec (flyteorg/flyte ray.go:267-268), and KubeRay creates the sidecar only when in-tree autoscaling is on, so options alone do nothing. - Unset fields keep KubeRay defaults rather than being zeroed: buildAutoscalerOptions applies idle_timeout_seconds only when > 0 and upscaling_mode only when not UNSPECIFIED (ray.go:208-236). - resources takes tuples for request/limit pairs. Upscaling mode uses the SDK spelling (CONSERVATIVE), not the KubeRay string the plugin maps it to ("Conservative"). Must rebase onto #1458 before merge: it is editing the same section of this page. Co-Authored-By: docsy <docsy@union.ai> Signed-off-by: Peeter Piegaze <1153481+ppiegaze@users.noreply.github.com> * docs: correct two false claims about autoscaler_options The "unset keeps the KubeRay default" sentence was false for resources. buildAutoscalerOptions assigns Resources inside an `err == nil` guard that cannot fail: ToK8sResourceRequirements(nil) returns a non-nil empty struct with a nil error (utils.go:53-55), so Resources is always non-nil whenever autoscaler_options is passed. KubeRay then takes the replace branch at pod.go:730-731 and overwrites its 500m/512Mi request and limit defaults wholesale. env is assigned unguarded too, but KubeRay appends it behind a len > 0 check (pod.go:739-740), so an empty env really is a no-op. The upscaling_mode table listed four graded options. Ray maps DEFAULT and AGGRESSIVE to the same upscaling_speed of 1000 and calls the second branch redundant in its own source (autoscaling_config.py:107-116). UNSPECIFIED never reaches the CR: ray.go:143 drops it. Only CONSERVATIVE differs, at upscaling_speed 1, which caps a scale-up step at the current node count rather than imposing a ceiling. Co-Authored-By: docsy <docsy@union.ai> Signed-off-by: Peeter Piegaze <1153481+ppiegaze@users.noreply.github.com> * docs: make the autoscaler snippet runnable and state the idle timeout default The block opens with an import line, so it reads as self-contained, but flyte.Resources had nothing importing flyte. Matches the convention used by the reusable-cluster snippet further down the page. idle_timeout_seconds defaults to 60 in KubeRay (raycluster_types.go:226-228, v1.6.2). An explicit 0 does not disable idle removal: buildAutoscalerOptions guards the assignment on `> 0` (ray.go:140), so a 0 is dropped and the KubeRay default applies. Co-Authored-By: docsy <docsy@union.ai> Signed-off-by: Peeter Piegaze <1153481+ppiegaze@users.noreply.github.com> * docs: import flyte in the Ray configuration snippet too Pre-existing, not introduced here, but fixing only the autoscaler snippet left the page with two import-opening blocks where one imported flyte and one did not. This block opens with an import line and calls flyte.TaskEnvironment, so it has the same defect. The page rule is now uniform: a block that opens with imports and uses flyte.* imports flyte. The three blocks that open mid-expression are fragments by design and are left alone. Co-Authored-By: docsy <docsy@union.ai> Signed-off-by: Peeter Piegaze <1153481+ppiegaze@users.noreply.github.com> --------- Signed-off-by: Peeter Piegaze <1153481+ppiegaze@users.noreply.github.com> Co-authored-by: docsy <docsy@union.ai>
1 parent 0cb254d commit 9697d7a

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

content/integrations/ray/_index.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ image = (
5151
Create a `RayJobConfig` and pass it as `plugin_config` to a `TaskEnvironment`:
5252

5353
```python
54+
import flyte
5455
from flyteplugins.ray import HeadNodeConfig, RayJobConfig, WorkerNodeConfig
5556

5657
ray_config = RayJobConfig(
@@ -76,6 +77,7 @@ ray_env = flyte.TaskEnvironment(
7677
| `worker_node_config` | `List[WorkerNodeConfig]` | **Required.** List of worker group configurations |
7778
| `head_node_config` | `HeadNodeConfig` | Head node configuration (optional) |
7879
| `enable_autoscaling` | `bool` | Enable Ray autoscaler (default: `False`) |
80+
| `autoscaler_options` | `AutoscalerOptionsConfig` | Tune the autoscaler sidecar. Has no effect unless `enable_autoscaling` is `True` |
7981
| `runtime_env` | `dict` | Ray runtime environment (pip packages, env vars, etc.) |
8082
| `address` | `str` | Connect to an existing Ray cluster instead of provisioning one |
8183
| `shutdown_after_job_finishes` | `bool` | Shut down the cluster after the job completes (default: `False`) |
@@ -118,6 +120,40 @@ ready: if the dashboard cannot start, `ray start --head` fails and KubeRay recyc
118120
the head pod in a loop. A head pod at 1 CPU and 1000Mi has been observed failing
119121
this way.
120122

123+
### `AutoscalerOptionsConfig` parameters
124+
125+
Setting `enable_autoscaling=True` runs the Ray autoscaler with KubeRay's defaults. Pass `autoscaler_options` to tune it:
126+
127+
```python
128+
import flyte
129+
from flyteplugins.ray import AutoscalerOptionsConfig, RayJobConfig, WorkerNodeConfig
130+
131+
ray_config = RayJobConfig(
132+
worker_node_config=[
133+
WorkerNodeConfig(group_name="ray-group", replicas=1, min_replicas=1, max_replicas=5)
134+
],
135+
enable_autoscaling=True,
136+
autoscaler_options=AutoscalerOptionsConfig(
137+
upscaling_mode=AutoscalerOptionsConfig.UpscalingMode.CONSERVATIVE,
138+
idle_timeout_seconds=120,
139+
resources=flyte.Resources(cpu=("500m", "1"), memory=("512Mi", "1Gi")),
140+
),
141+
)
142+
```
143+
144+
| Parameter | Type | Description |
145+
|-----------|------|-------------|
146+
| `upscaling_mode` | `AutoscalerOptionsConfig.UpscalingMode` | Rate limiting on adding nodes. `CONSERVATIVE` holds the number of pending worker pods to at most the current cluster size. `DEFAULT` and `AGGRESSIVE` are the same setting: no rate limit. Leaving the field unset, or passing `UNSPECIFIED`, also means no rate limit |
147+
| `idle_timeout_seconds` | `int` | Seconds a node may sit idle before the autoscaler removes it (default: 60). An explicit `0` is dropped and the default applies |
148+
| `image` | `str` | Container image for the autoscaler sidecar |
149+
| `env` | `Dict[str, str]` | Environment variables for the autoscaler container |
150+
| `resources` | `Resources` | Requests and limits for the autoscaler sidecar |
151+
152+
Every field is optional. Leaving `upscaling_mode`, `idle_timeout_seconds`, `image`, or `env` unset keeps the KubeRay default. `resources` is the exception: whenever you pass `autoscaler_options`, whatever you give for `resources` replaces the sidecar's default 500m CPU and 512Mi memory requests and limits outright. Omit it and the sidecar runs with no requests or limits at all; set only a request and it also loses the default limits. Set `resources` explicitly, on both sides. It accepts tuples to set a request and a limit together, as in `flyte.Resources(cpu=("500m", "1"))`.
153+
154+
> [!NOTE] The options do not switch autoscaling on
155+
> `autoscaler_options` only configures the autoscaler sidecar, and the sidecar is created only when `enable_autoscaling` is `True`. Passing options on their own changes nothing.
156+
121157
### Connecting to an existing cluster
122158

123159
To connect to an existing Ray cluster instead of provisioning a new one, set the `address` parameter:

0 commit comments

Comments
 (0)