ray.serve.config.DeploymentActorConfig#
- pydantic model ray.serve.config.DeploymentActorConfig[source]#
Configuration for a deployment-scoped actor.
Deployment-scoped actors are long-lived actors managed by the Serve controller that outlive any single replica but are cleaned up when the deployment is deleted or serve.shutdown() is called. They are shared by all replicas of a deployment.
Example
from ray import serve from ray.serve.config import DeploymentActorConfig @ray.remote class PrefixTreeActor: def __init__(self, max_depth: int = 100): self.max_depth = max_depth def insert(self, text: str): self.max_depth += 1 @serve.deployment( deployment_actors=[ DeploymentActorConfig( name="prefix_tree", actor_class=PrefixTreeActor, init_kwargs={"max_depth": 100}, actor_options={"num_cpus": 0.1}, ), ], ) class MyDeployment: def __init__(self): self.tree = serve.get_deployment_actor("prefix_tree") def __call__(self, request): ray.get(self.tree.insert.remote(request.text))
PublicAPI (alpha): This API is in alpha and may change before becoming stable.
- field actor_class: type | str | ActorClass [Required]#
The actor class for this deployment-scoped actor. Can be a @ray.remote-decorated class or an import path string (e.g. ‘my_module:PrefixTreeActor’).