acoustic-carpenter-78188
07/16/2026, 12:51 AMReusePolicy today only supports container/pod tasks (reusable actors). Ray tasks always pay full RayCluster cold-start cost on every run, even when many runs share an identical cluster spec.
This PR lets users opt a Ray task environment into a shared, reusable RayCluster:
ray_env = flyte.TaskEnvironment(
name="ray_env",
plugin_config=RayJobConfig(...),
reusable=flyte.ReusePolicy(replicas=1, idle_ttl=600),
)
What changed
Core stays plugin-agnostic, and the task type is unchanged — reuse is signaled through the task's custom spec:
• Core: plugins opt in to reuse via a supports_reuse_policy class attribute (checked by the TaskEnvironment reusable+plugin_config guard) and an apply_reuse_policy(task_template) hook that task serialization dispatches to instead of add_reusable. No Ray knowledge in reuse.py.
• Ray plugin: validates the policy (replicas maps to the number of shared clusters; only 1 supported for now, otherwise BadConfiguration) and records it under a reusePolicy key in the task's custom (RayJob) spec. The field is unknown to the RayJob proto and ignored by its unmarshalling — the task type stays ray, so backends without shared-cluster support simply run the task as a normal ephemeral Ray job.
• Backends with shared-cluster support route on the presence of `reusePolicy`: shared RayCluster (keyed by the Ray spec hash, so identical specs reuse one cluster) when present, ephemeral otherwise. The generic backend plugin interface lives in flyteorg/flyte#7460.
• Example: examples/plugins/ray_reusable_cluster.py.
Tests
• tests/flyte/internal/runtime/test_reuse.py — core behavior unchanged (9 passing).
• plugins/ray/tests/test_task.py — policy recorded in custom with type unchanged; multi-replica rejection (9 passing).
flyteorg/flyte-sdkacoustic-carpenter-78188
07/20/2026, 5:06 PMacoustic-carpenter-78188
07/24/2026, 10:04 PM