Overview
Ray 2.3, released on February 15, 2023, introduces compiled graphs and improves overall performance of the distributed computing framework.
Main Features
Compiled graphs
Compiled graphs (CompiledDAG) optimize task pipelines by pre-compiling the execution graph, reducing latency between steps.
python
import ray
ray.init()
@ray.remote
def transform(data):
return [x * 2 for x in data]
@ray.remote
def aggregate(results):
return sum(results)
# Distributed task pipeline
batches = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
futures = [transform.remote(batch) for batch in batches]
results = ray.get(futures)
print(results) # [[2,4,6], [8,10,12], [14,16,18]]
Performance improvements
The Ray runtime benefits from object serialization optimizations and memory management improvements, reducing overhead for fine-grained tasks.
python
import ray
import numpy as np
@ray.remote
class Counter:
def __init__(self):
self.n = 0
def increment(self):
self.n += 1
return self.n
# Distributed actor
counter = Counter.remote()
futures = [counter.increment.remote() for _ in range(100)]
print(ray.get(futures[-1])) # 100
