A Ray task is a stateless unit of computation. Annotate a function withDocumentation Index
Fetch the complete documentation index at: https://ray-preview.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
@ray.remote and invoke it with .remote(...) to schedule it on the cluster.
Define and run tasks
ray.get blocks on the result. To process many futures concurrently, collect them into a list and call ray.get once.
Specify resource requirements
Declare CPU, GPU, memory, and custom resources on the decorator or per-call.Pass data to tasks
Tasks receive arguments by value. Large objects should be placed in the object store withray.put so they aren’t re-serialized for every call.
ObjectRef values directly between tasks; Ray will resolve them on the destination worker.
Multiple return values
Usenum_returns to return multiple objects.
Wait for results
Useray.wait to process the first N results as they finish.
Generators and streaming returns
For long-running tasks that produce data incrementally, use a remote generator.Cancel tasks
Retries on failure
By default, Ray retries failed tasks up to three times. Configure withmax_retries.
retry_exceptions=True to retry on application-level exceptions, not just worker failures.
Next steps
Actors
Persistent stateful workers.
Patterns
Effective ways to structure tasks in real applications.