About these notes

These are paper-reading notes, not an original analysis. Most of the text is quoted from the Ray paper and cited.

1. Why RL needed a new framework

The central goal of an RL application is to learn a policy—a mapping from the state of the environment to a choice of action—that yields effective performance over time, e.g., winning a game or piloting a drone.[1]

The paper named three capabilities needed to find such a policy (§1): simulation to evaluate policies, distributed training to improve them, and serving to put the policy into closed-loop or open-loop control.[1]

An agent learns a policy in two steps: policy evaluation, then policy improvement. The paper’s pseudocode (Figure 2) shows where the three workloads sit:[1]

// evaluate policy by interacting with env. (e.g., simulator)
rollout(policy, environment):
    trajectory = []
    state = environment.initial_state()
    while (not environment.has_terminated()):
        action = policy.compute(state)                 // Serving
        state, reward = environment.step(action)       // Simulation
        trajectory.append(state, reward)
    return trajectory

// improve policy iteratively until it converges
train_policy(environment):
    policy = initial_policy()
    while (policy has not converged):
        trajectories = []
        for i from 1 to k:                             // evaluate policy by generating k rollouts
            trajectories.append(rollout(policy, environment))
        policy = policy.update(trajectories)           // Training
    return policy

In supervised learning, training and serving can be handled by separate systems. In RL they are coupled in one loop:

in RL all three of these workloads are tightly coupled in a single application, with stringent latency requirements between them.[1]

The paper’s argument was that stitching specialized systems together cost too much data movement and latency, so people built one-off systems for each RL application, and each of those systems had to solve scheduling, fault tolerance and data movement again (§1, §2).[1]

we need a dynamic computation framework that handles millions of heterogeneous tasks per second at millisecond-level latencies[1]

2. Requirements

The paper listed three requirements (§2):[1]

  • Fine-grained, heterogeneous computations
  • Flexible computation model: stateless and stateful computations
  • Dynamic execution

Fine-grained and heterogeneous: durations ran from milliseconds (taking an action) to hours (training), and the hardware mix included CPUs, GPUs and TPUs. Flexible: stateless work could run on any node, which made load balancing and moving computation to data easy, while stateful work suited parameter servers, repeated computation on GPU-backed data, and third-party simulators that did not expose their state. Dynamic: the order in which computations finished was not known in advance, and a result could decide what ran next, for example whether more simulations were needed.

Two further points from the paper: the framework had to handle millions of tasks per second to keep a large cluster busy (the paper’s footnote works out 1.28M tasks/s for 5 ms single-core tasks on 200 32-core nodes), and it was not meant to implement neural networks or simulators from scratch, but to integrate with existing ones.[1]

The paper also said what Ray was not. It was not a replacement for serving systems such as Clipper and TensorFlow Serving, which handled model management, testing and composition, and not a replacement for generic data-parallel frameworks such as Spark, since it lacked their functionality such as straggler mitigation and query optimization (§1).[1]

what are straggler mitigation and query optimization in Spark?

Straggler mitigation: a straggler is a task that runs much slower than its peers in the same stage. Spark’s answer is speculative execution. When spark.speculation is enabled (it is false by default), “if one or more tasks are running slowly in a stage, they will be re-launched”. The defaults check every 100 ms (spark.speculation.interval) and treat a task as slow when it exceeds 3× the median duration of successful tasks (spark.speculation.multiplier).[2] Query optimization: Spark SQL chooses an execution plan for a query. With Adaptive Query Execution, on by default since Spark 3.2.0, it “re-optimizes the query plan in the middle of query execution, based on accurate runtime statistics”.[3] Both exist for batch dataflow jobs. The paper’s point was only that Ray did not yet offer them (§1).[1]

3. Programming model

Ray modeled an application as a graph of dependent tasks that evolves during execution, and offered two programming abstractions on top of it: tasks and actors (§3).[1] The API was small (Table 1 of the paper):[1]

CallDescription (from the paper)
futures = f.remote(args)Execute function f remotely. f.remote() can take objects or futures as inputs and returns one or more futures. This is non-blocking.
objects = ray.get(futures)Return the values associated with one or more futures. This is blocking.
ready_futures = ray.wait(futures, k, timeout)Return the futures whose corresponding tasks have completed as soon as either k have completed or the timeout expires.
actor = Class.remote(args)Instantiate class Class as a remote actor, and return a handle to it.
futures = actor.method.remote(args)Call a method on the remote actor and return one or more futures. Both are non-blocking.

Tasks and actors

A task represents the execution of a remote function on a stateless worker. When a remote function is invoked, a future representing the result of the task is returned immediately.[1]

Remote functions operate on immutable objects and are expected to be stateless and side-effect free: their outputs are determined solely by their inputs. This implies idempotence, which simplifies fault tolerance through function re-execution on failure.[1]

An actor represents a stateful computation. Each actor exposes methods that can be invoked remotely and are executed serially.[1]

The paper summarized the trade-off in its Table 2:[1]

Tasks (stateless)Actors (stateful)
Fine-grained load balancingCoarse-grained load balancing
Support for object localityPoor locality support
High overhead for small updatesLow overhead for small updates
Efficient failure handlingOverhead from checkpointing

On the actor side, the paper’s reasoning was that

actors provide much more efficient fine-grained updates, as these updates are performed on internal rather than external state, which typically requires serialization and deserialization.[1]

why are third-party simulators hard to serialize? What do serialize and deserialize mean here?

A third-party simulator is an existing environment that the RL code calls but did not write. The paper cited OpenAI Gym[4] and DeepMind Lab[5] as examples, and its simulation benchmark used Gym’s Pendulum-v0 (§2, §5.2.3).[1] Serializing means turning in-memory state into bytes so it can be sent to another process or stored; deserializing rebuilds the state from those bytes. The paper described these simulators as ones “that do not expose their state” (§2) and as “opaque handles that are hard to serialize” (§3.1), and said actors “can be used to wrap” them.[1] My reading, not stated in the paper: if the state cannot be captured as bytes, it cannot be passed between stateless workers, so the simulator stays inside one long-lived actor and callers send it method calls.

Three additions to the basic API

The paper added three things to cover heterogeneity and flexibility (§3.1):[1]

  • ray.wait() waited for the first k available results instead of all of them, which suited tasks with heterogeneous durations.
  • Developers could specify resource requirements, so the scheduler could manage heterogeneous resources.
  • Remote functions could invoke other remote functions (nested remote functions). The paper said this was also critical for scalability, since it let multiple processes invoke remote functions in a distributed fashion.

4. Computation model

what is a dynamic task graph computation model?

The paper’s model was a graph of dependent tasks that evolves during execution, and “the execution of both remote functions and actor methods is automatically triggered by the system when their inputs become available” (§3.2).[1] “Dynamic” means the graph is not known up front: results decide what runs next (§2), and a running task can add more tasks through nested calls (§3.1).[1]

The paper’s Figure 3 implemented the pseudocode of Figure 2 in Ray:[1]

@ray.remote
def create_policy():
    # Initialize the policy randomly.
    return policy
 
@ray.remote(num_gpus=1)
class Simulator(object):
    def __init__(self):
        # Initialize the environment.
        self.env = Environment()
 
    def rollout(self, policy, num_steps):
        observations = []
        observation = self.env.current_state()
        for _ in range(num_steps):
            action = policy(observation)
            observation = self.env.step(action)
            observations.append(observation)
        return observations
 
@ray.remote(num_gpus=2)
def update_policy(policy, *rollouts):
    # Update the policy.
    return policy
 
@ray.remote
def train_policy():
    # Create a policy.
    policy_id = create_policy.remote()
    # Create 10 actors.
    simulators = [Simulator.remote() for _ in range(10)]
    # Do 100 steps of training.
    for _ in range(100):
        # Perform one rollout on each actor.
        rollout_ids = [s.rollout.remote(policy_id) for s in simulators]
        # Update the policy with the rollouts.
        policy_id = update_policy.remote(policy_id, *rollout_ids)
    return ray.get(policy_id)

The graph had two kinds of nodes, data objects and tasks, and the paper defined its edges like this:

Data edges capture the dependencies between data objects and tasks. More precisely, if data object D is an output of task T, we add a data edge from T to D. Similarly, if D is an input to T, we add a data edge from D to T. Control edges capture the computation dependencies that result from nested remote functions (Section 3.1): if task T1 invokes task T2, then we add a control edge from T1 to T2.[1]

Actor method calls are nodes too, with a third kind of edge:

To capture the state dependency across subsequent method invocations on the same actor, we add a third type of edge: a stateful edge. If method Mj is called right after method Mi on the same actor, then we add a stateful edge from Mi to Mj.[1]

flowchart LR T0["T0: train_policy"] T1["T1: create_policy"] policy1(["policy1"]) A10["A10: Simulator (actor 1)"] A20["A20: Simulator (actor 2)"] A11["A11: rollout"] A21["A21: rollout"] rollout11(["rollout11"]) rollout21(["rollout21"]) T2["T2: update_policy"] policy2(["policy2"]) A12["A12: rollout"] A22["A22: rollout"] rollout12(["rollout12"]) rollout22(["rollout22"]) T3["T3: update_policy"] T1 --> policy1 policy1 --> A11 policy1 --> A21 A11 --> rollout11 A21 --> rollout21 policy1 --> T2 rollout11 --> T2 rollout21 --> T2 T2 --> policy2 policy2 --> A12 policy2 --> A22 A12 --> rollout12 A22 --> rollout22 policy2 --> T3 rollout12 --> T3 rollout22 --> T3 A10 ==> A11 ==> A12 A20 ==> A21 ==> A22 T0 -.-> T1 & A10 & A20 & A11 & A21 & A12 & A22 & T2 & T3

Caption: the task graph for train_policy.remote() with two of the ten actors and two training iterations. Solid arrows are data edges, thick arrows are stateful edges, dotted arrows are control edges from train_policy. Rounded nodes are objects. Reconstructed from the labels of the paper’s Figure 4 and the code of Figure 3; rendering unchecked.[1]

Stateful edges are also what let actors take part in lineage:

Stateful edges help us embed actors in an otherwise stateless task graph, as they capture the implicit data dependency between successive method invocations sharing the internal state of an actor. Stateful edges also enable us to maintain lineage.[1]

5. Architecture

what is this execution engine, and how is it highly scalable and fault tolerant?

The paper’s answer was its system layer: a global control store, a distributed scheduler and a distributed object store, all “horizontally scalable and fault-tolerant” (§4.2).[1] Scalability came from distributing two components that were typically centralized in other frameworks, the task scheduler and the metadata store that held lineage and the object directory (§1).[1] Fault tolerance came in two forms, covered in the next question.

what is lineage-based fault tolerance, and how does it differ from replication-based fault tolerance?

The paper used both, for different things (§1):[1] lineage-based fault tolerance for tasks and actors, and replication-based fault tolerance for the metadata store. With lineage, lost objects were recovered by re-executing the tasks that produced them (§4.2.3), which worked because remote functions are idempotent (§3.1).[1] With replication, each GCS shard was chain-replicated (§4.2.1).[1] My inference, not stated in the paper: the GCS held the lineage itself, so it could not be rebuilt from lineage and was replicated instead. The general difference, from outside sources: lineage-based recovery stores the recipe for data and rebuilds lost pieces. Spark’s programming guide says that if an RDD partition is lost, it “will automatically be recomputed using the transformations that originally created it”.[6] Replication-based recovery keeps several copies of the state itself. In chain replication, servers form a chain, the head applies updates and passes state changes down the chain to the tail, and queries are answered by the tail.[7] The trade-off follows from this and is my reading, not a quote: lineage costs little in the normal case but needs recomputation after a failure, while replication pays on every write and recovers by switching to a surviving copy.

Ray’s architecture had two parts: an application layer that implemented the API, and a system layer that provided scalability and fault tolerance.[1]

Application layer

The paper described three kinds of process:[1]

  • Driver: “A process executing the user program.”
  • Worker: “A stateless process that executes tasks (remote functions) invoked by a driver or another worker.” A worker executed tasks serially, with no local state maintained across tasks.
  • Actor: “A stateful process that executes, when invoked, only the methods it exposes.” Unlike a worker, an actor was explicitly instantiated by a worker or a driver.

System layer

flowchart TB subgraph APP["Application layer"] direction LR D["Driver"] W["Worker"] A["Actor"] end subgraph SYS["System layer"] direction TB GCS[("Global Control Store (GCS)<br/>object table, task table,<br/>function table, event logs")] GS["Global scheduler(s)"] subgraph NODE["Each node"] direction LR LS["Local scheduler"] OS[("Object store<br/>(shared memory)")] end end TOOLS["Web UI, debugging, profiling,<br/>error diagnosis tools"] D & W & A --> LS LS --> GS LS <--> OS GS <--> GCS LS <--> GCS OS <--> GCS TOOLS --> GCS

Caption: the components in the paper’s Figure 5. Every system-layer component read and wrote shared state through the GCS. Arrows show the main interactions, not every message.[1]

5.1 Global Control Store (GCS)

The global control store (GCS) maintains the entire control state of the system, and it is a unique feature of our design. At its core, GCS is a key-value store with pubsub functionality.[1]

what is the difference between a normal key-value store and one with pub/sub functionality?

A plain key-value store answers reads and writes. A store with pub/sub also lets a client register interest in a key and be notified when it changes. The paper’s own use was in ray.get(): if the object did not exist yet, the node’s object store registered a callback with the Object Table “to be triggered when c’s entry has been created”, and the GCS fired it when the producing task finished (§4.3, Figure 7b).[1] This lets a waiting reader sleep instead of poll.

what is per-shard chain replication, and how does it give fault tolerance?

The paper sharded GCS tables by object and task IDs, and every shard was chain-replicated (§4.2.4), using one Redis key-value store per shard.[1] It built a lightweight chain replication layer on top of Redis (§5.1).[1] In the original chain replication design (van Renesse and Schneider, OSDI 2004), servers are linearly ordered. The head handles updates and forwards state changes down the chain, the tail answers queries, and a master detects failures and reconfigures the chain. The design gives strong consistency.[7] The Ray paper said it built this layer “[t]o maintain low latency while providing strong consistency and fault tolerance” (§5.1).[1]

what are lineage-based solutions, and how do coarse-grained and fine-grained parallelism differ?

The paper’s point was about scale of the lineage record. Existing lineage-based systems (it cited Spark, CIEL and Dryad, among others) “focus on coarse-grained parallelism and can therefore use a single node (e.g., master, driver) to store the lineage without impacting performance.”[1] Coarse-grained means relatively few, large operations, so there is little lineage to record. Fine-grained means very many small tasks, such as millisecond simulations at millions of tasks per second, where “this design is not scalable”.[1] The paper’s response was to “decouple the durable lineage storage from the other system components, allowing each to scale independently.”[1]

The second design choice is where object metadata lives:

Many existing dataflow systems [64, 40, 48] couple these by storing object locations and sizes in a centralized scheduler, a natural design when the scheduler is not a bottleneck. However, the scale and granularity that Ray targets requires keeping the centralized scheduler off the critical path.[1]

Here “these” refers to task scheduling (choosing where to execute) and task dispatch (retrieving remote inputs). Ray stored object metadata in the GCS rather than the scheduler, “fully decoupling task dispatch from task scheduling.”[1]

The consequence was the paper’s main design principle:

the GCS significantly simplifies Ray’s overall design, as it enables every component in the system to be stateless. This not only simplifies support for fault tolerance (i.e., on failure, components simply restart and read the lineage from the GCS), but also makes it easy to scale the distributed object store and scheduler independently, as all components share the needed state via the GCS.[1]

5.2 Bottom-up distributed scheduler

The paper said none of the cluster schedulers it knew of met the need to schedule millions of tasks per second, some as short as a few milliseconds (§4.2.2).[1] It grouped the alternatives in two:[1]

  • Centralized schedulers (Spark, CIEL, Dryad) “can provide locality but at latencies in the tens of ms”.
  • Distributed schedulers could scale, but work stealing did not consider data locality, Sparrow assumed tasks belonged to independent jobs, and Canary assumed the computation graph was known.

Ray’s design was a two-level hierarchy:

a two-level hierarchical scheduler consisting of a global scheduler and per-node local schedulers. To avoid overloading the global scheduler, the tasks created at a node are submitted first to the node’s local scheduler. A local scheduler schedules tasks locally unless the node is overloaded (i.e., its local task queue exceeds a predefined threshold), or it cannot satisfy a task’s requirements (e.g., lacks a GPU).[1]

Because decisions start at the leaves of the hierarchy, the paper called it a bottom-up scheduler.

flowchart TB subgraph N1["Node 1"] D1["Driver"] --> LS1["Local scheduler"] W1["Workers"] --> LS1 end subgraph N2["Node N"] W2["Workers"] --> LS2["Local scheduler"] end LS1 -- "forward only if overloaded<br/>or requirements not met" --> GS["Global scheduler<br/>(replicas possible)"] LS2 -- "forward only if overloaded<br/>or requirements not met" --> GS LS1 -. "heartbeat: queue size,<br/>resource availability" .-> GS LS2 -. "heartbeat" .-> GS GS <-- "object locations and sizes" --> GCS[("GCS")] GS -- "place task" --> LS2 LS1 -- "schedule locally<br/>(common case)" --> W1

Caption: the flow in the paper’s Figure 6. Most tasks stayed on the node that created them. The paper’s figure scaled arrow thickness with request rate, which this diagram does not.[1]

When the global scheduler did get a task, it first found the nodes that had enough resources of the requested type, and of these it selected the node with the lowest estimated waiting time. The paper defined that time as the sum of two terms:[1]

  1. the estimated queueing time: task queue size times average task execution time
  2. the estimated transfer time of the task’s remote inputs: total size of remote inputs divided by average bandwidth

The global scheduler learned queue sizes and resource availability through heartbeats, and input locations and sizes from the GCS. It computed the average task execution time and average bandwidth with “simple exponential averaging”. If it became a bottleneck, more replicas could be started, all sharing state through the GCS.[1]

5.3 In-memory distributed object store

To minimize task latency, we implement an in-memory distributed storage system to store the inputs and outputs of every task, or stateless computation. On each node, we implement the object store via shared memory. This allows zero-copy data sharing between tasks running on the same node. As a data format, we use Apache Arrow.[1]

what other in-memory distributed object stores and data formats exist?

Outside the paper, a few points of comparison, each from the project’s own description. Stores: Memcached is “an in-memory key-value store for small arbitrary data (strings, objects)”;[8] Redis is an in-memory database, and the paper used it as the storage engine of each GCS shard, not as the object store;[9] Alluxio sits between compute applications and storage systems and has a “memory-first tiered architecture”.[10] Plasma, the store Ray built, holds immutable objects in shared memory with zero-copy reads, and was developed as part of Ray before moving to Apache Arrow.[11] Formats: the Apache Arrow columnar format is language-agnostic and in-memory, and is “Relocatable without “pointer swizzling”, allowing for true zero-copy access in shared memory”;[12] FlatBuffers lets you “Access the data directly without unpacking or parsing”;[13] Protocol Buffers is a “language-neutral, platform-neutral extensible mechanism for serializing structured data”.[14] My reading, not stated in the paper: the zero-copy property is what mattered for Ray’s choice, since a task read its arguments straight from shared memory (§4.3, step 9).

Per the paper, if a task’s inputs were not local they were replicated to the local object store before execution, and a task wrote its outputs to the local object store. Replication removed the bottleneck of hot objects and meant a task only read and wrote local memory (§4.2.3). Objects were kept entirely in memory, and evicted to disk with an LRU policy when needed.[1]

how does an object store for immutable data differ from one for mutable data? What are consistency protocols, and how do different protocols achieve fault tolerance?

The paper only covered its own choice. Like Spark and Dryad, its object store was limited to immutable data, which “obviates the need for complex consistency protocols (as objects are not updated), and simplifies support for fault tolerance.”[1] Replicas of an immutable object can never disagree, so no protocol is needed to keep them in agreement, and a lost copy can be recomputed from lineage. A consistency model is “a contract between the programmer and a system”, under which reads, writes and updates behave predictably if the programmer follows the rules.[15] Immutable objects, whose state cannot change after creation, are “inherently thread-safe”, because no reader can see a half-updated value.[16] Chain replication is one example of a protocol for mutable data, and it gives strong consistency by routing writes through the head and reads from the tail.[7] I do not cover how other protocols handle failure, since that would need further sources.

what is lineage re-execution, and what are distributed objects?

Lineage re-execution: “In the case of node failure, Ray recovers any needed objects through lineage re-execution.” The lineage in the GCS tracked both stateless tasks and stateful actors during initial execution, and the task part was used to reconstruct objects in the store.[1] Distributed objects: the paper’s object store did not support them, meaning each object had to fit on a single node. Large matrices or trees “can be implemented at the application level as collections of futures.”[1]

what do event-driven, single-threaded schedulers and striped transfers mean?

What the paper stated (§4.2.4):[1] both the local and global schedulers were event-driven, single-threaded processes. Local schedulers kept cached state for local object metadata, tasks waiting for inputs, and tasks ready to dispatch to a worker. To move large objects between object stores, the object was striped across multiple TCP connections. General explanation, from outside sources. An event loop is an algorithm that “continually dispatches control flow for events”: it requests the next event, blocks until one arrives, then invokes the handler.[17] Plasma, Ray’s object store, was also a single-threaded event loop, built on the Redis event loop library.[11] Striping is “segmenting logically sequential data” so that consecutive segments go to different devices that can be accessed concurrently, which raises total throughput.[18]

5.4 Putting it together: add(a, b)

The paper walked through one example end to end (Figure 7): a driver on node N1 called add.remote(a, b), where a was stored on N1 and b on N2.[1]

Executing the task (Figure 7a). Step 0: add() was registered with the GCS and distributed to every worker.

  1. The driver submitted add(a, b) to the local scheduler.
  2. The local scheduler forwarded it to a global scheduler.
  3. The global scheduler looked up the locations of the arguments in the GCS.
  4. It decided to schedule the task on N2, which stored b.
  5. The local scheduler at N2 checked its object store for the arguments.
  6. a was missing, so it looked up a in the GCS.
  7. The GCS said a was on N1, so N2’s object store replicated it locally.
  8. All arguments were now local, so the local scheduler invoked add() on a local worker.
  9. The worker read the arguments through shared memory.

Returning the result (Figure 7b), when the driver called ray.get(idc):

  1. The driver checked the local object store for c.
  2. Not found, and the GCS had no entry yet, so N1’s object store registered a callback with the Object Table.
  3. Meanwhile add() finished on N2 and stored c in the local object store.
  4. That added c’s entry to the GCS.
  5. The GCS triggered the callback to N1’s object store.
  6. N1 replicated c from N2.
  7. c was returned to ray.get().

The paper also noted that N1 could have scheduled the task locally, and that the example involved many RPCs, though in many cases the number was much smaller, as “most tasks are scheduled locally, and the GCS replies are cached by the global and local schedulers.”[1]

Unless marked as outside the paper, this section follows the paper’s comparison with related systems (§6).[1]

Dynamic task graph systems: CIEL and Dask

Ray is closely related to CIEL [40] and Dask [48]. All three support dynamic task graphs with nested tasks and implement the futures abstraction. CIEL also provides lineage-based fault tolerance, while Dask, like Ray, fully integrates with Python.[1]

The paper named two differences with performance consequences:[1]

  1. Ray added an actor abstraction, which it said was needed for efficient stateful computation in distributed training and serving, to keep the model data collocated with the computation.
  2. Ray used a fully distributed and decoupled control plane and scheduler, instead of a single master storing all metadata.

The paper’s argument for the second difference used ring allreduce. For 100 MB on 16 nodes it submitted 32 rounds of 16 tasks in 200 ms. Dask reported a maximum scheduler throughput of 3k tasks/s on 512 cores, so with a centralized scheduler each round would incur at least about 5 ms of scheduling delay, which the paper said could mean up to 2× worse completion time.[1] These figures are the paper’s, from a particular benchmark setup, and I am not evaluating them here.

how does Ray differ from MapReduce, which also schedules computation for data locality?

From the paper, locality was not what separated them. It said centralized schedulers, such as Spark’s, CIEL’s and Dryad’s, “can provide locality but at latencies in the tens of ms” (§4.2.2).[1] The differences it drew were the execution model (bulk-synchronous, with tasks in a stage assumed alike), the lack of dynamic task graphs, the lack of an actor abstraction, and the centralized control plane and scheduler (§6).[1] The paper did not compare against MapReduce’s own scheduler beyond this grouping. From outside the paper: the Hadoop MapReduce documentation says that because compute and storage nodes are usually the same, the framework can “schedule tasks on the nodes where data is already present”.[19] So MapReduce also has data locality. My reading, not stated in the paper: the contrast was in the other differences listed above, not in locality itself.

Dataflow systems and the BSP model

Spark and MapReduce implement the BSP execution model, which assumes that tasks within the same stage perform the same computation and take roughly the same amount of time. Dryad relaxes this restriction but lacks support for dynamic task graphs. Furthermore, none of these systems provide an actor abstraction, nor implement a distributed scalable control plane and scheduler. Finally, Naiad [39] is a dataflow system that provides improved scalability for some workloads, but only supports static task graphs.[1]

BSP execution model? dynamic task graphs? actor abstraction? distributed scalable control plane and scheduler?

BSP is bulk-synchronous parallel. As the paper used it, work proceeded in stages with a barrier between them. Its simulation comparison built this as “an MPI implementation that submits 3n parallel simulation runs on n cores in 3 rounds, with a global barrier between rounds” (§5.2.3).[1] Dynamic task graphs: see section 4 above; static graphs are fixed before execution. Actor abstraction: see section 3. Control plane: the control state and decisions (here the GCS, scheduling and object metadata) as opposed to the data plane that moves data. In Figure 7 of the paper, solid lines were data plane operations and dotted lines were control plane operations. “Distributed scalable” then means those pieces are sharded or replicated rather than held by one master (§4.2).[1]

Machine learning frameworks and MPI

For TensorFlow and MXNet, the paper said they performed well on static DAGs of linear algebra operations but had limited support for the more general computation needed to couple training with simulation and embedded serving. TensorFlow Fold and MXNet’s internal C++ APIs offered some dynamic graph support, but neither fully supported modifying the DAG during execution in response to task progress, completion times or faults. OpenMPI could achieve high performance but “requires explicit coordination to handle heterogeneous and dynamic task graphs” and forced the programmer to handle fault tolerance explicitly.[1]

Actor systems

Orleans [14] and Akka [1] are two actor frameworks well suited to developing highly available and concurrent distributed systems. However, compared to Ray, they provide less support for recovery from data loss.[1]

On the details: in Orleans the developer had to explicitly checkpoint actor state and intermediate responses, and stateless Orleans actors could be replicated but “have no lineage”. Akka could persist actor state across failures but did not provide efficient fault tolerance for stateless computation. For message delivery, the paper said Orleans provided at-least-once and Akka at-most-once semantics, while Ray provided exactly-once semantics “as each method call is logged in the GCS and both arguments and results are immutable.”[1] The paper added that “in practice these limitations do not affect the performance of our applications.”[1]

what are at-most-once semantics?

As the paper used the terms, they describe how many times a message is delivered: at-least-once guarantees delivery but may deliver more than once, at-most-once never delivers more than once but may drop a message, and exactly-once is both. The Akka documentation defines them the same way: at-most-once means each message is delivered once or not at all, so messages may be lost; at-least-once means multiple attempts, so messages may be duplicated but not lost; exactly-once means delivered exactly once.[20]

Control planes and schedulers

Logically centralized control planes had been proposed before, in software-defined networks, GFS, Omega, MapReduce and BOOM. The paper said Ray differed from SDNs, BOOM and GFS by decoupling the storage of control-plane information from the logic that used it, so both could scale independently. Against Omega, in which schedulers coordinate through globally shared state, Ray added global schedulers to balance load across local ones and targeted millisecond-level rather than second-level scheduling (§6).[1]

Against other schedulers, the paper said:[1]

  • Most cluster systems (MapReduce, Spark, CIEL) used a centralized scheduler.
  • Sparrow was decentralized, but its schedulers made independent decisions, which limited the possible policies, and all tasks of a job went to the same global scheduler.
  • Mesos had a two-level scheduler, but its top level managed frameworks, not individual tasks.
  • Canary had each scheduler instance handle a portion of the task graph, but did not handle dynamic computation graphs.
  • Cilk’s work-stealing scheduler was provably efficient for dynamic task graphs, but with no central coordinator it was hard to extend to data locality and resource heterogeneity in a distributed setting.

7. Ray today

The sections above describe the 2018 design. Ray has changed since, and this section checks what still holds. It uses two sources: the current Ray docs, and the Ray 2.0 architecture whitepaper (October 2022), which says it “supersedes previous papers describing Ray” and that “the underlying architecture has changed considerably from versions 0.7 to 0.8”.[21] Both describe Ray as it is now and do not trace each change since 2018.

The paper itself flagged one open item. Storing lineage for each task “requires the implementation of garbage collection policies to bound storage costs in the GCS, a feature we are actively developing” (§7).[1] The current docs address it like this:

  • Lineage is bounded. Lineage reconstruction “can cause higher than usual driver memory usage because the driver keeps the descriptions of any tasks that may be re-executed”. The environment variable RAY_max_lineage_bytes (default 1 GB) evicts lineage when the threshold is exceeded.[22]
  • Lineage reconstruction has limits. Objects created by ray.put are not recoverable. By default, objects created by actor tasks are not reconstructable. Tasks are re-executed only up to their maximum number of retries (by default, a non-actor task can be retried up to 3 times and an actor task cannot).[22]
  • Objects are reference counted. Ray implements distributed reference counting, and objects “are reference counted and evicted when they fall out of scope”. The object store can spill to disk if it fills up.[23]

Three other parts of the 2018 design look different now:

  • Object metadata moved from the GCS to an owner. The docs say object data is in the object store, while “the metadata is stored at the object’s owner”, the worker process that created the original ObjectRef. Ray can recover from data loss but not from owner failure.[22] The paper put object metadata in the GCS (§4.2.1).[1]
  • The GCS is not fault tolerant by default. The docs call it the Global Control Service. It “isn’t fault tolerant because it stores all data in memory”, and if it fails the cluster fails. It can be backed by external Redis (officially supported) or an embedded RocksDB (alpha), after which it reloads state on restart.[24] The paper’s GCS was sharded and chain-replicated (§4.2.4).[1]
  • Scheduling. For tasks under the default strategy, data locality takes precedence over utilization, so Ray prefers a node that already holds the task’s large arguments. Locality-aware scheduling applies to tasks, not actors.[25]
does the bottom-up scheduler still exist?

Not in the paper’s form, according to the whitepaper.[21] Its description of scheduling differs from the paper in these ways:

  • Each node runs a raylet, which has a scheduler and the shared-memory object store (Plasma). The whitepaper does not mention a global scheduler; the phrase does not appear in its text.
  • The task’s caller asks for resources. It sends the request to a “preferred raylet” chosen from its local information about where the task’s arguments are. That raylet grants a lease on a local worker, or replies with the address of a remote raylet to retry at, which the whitepaper calls spillback scheduling.
  • Raylets get cluster-wide resource availability from the GCS, which polls each raylet every 100 ms by default and rebroadcasts. The whitepaper says this view is only eventually consistent and may be stale.
  • The default policy is a hybrid one: pack tasks onto the local node until its critical resource utilization passes a threshold (50% by default), then onto other nodes in node-ID order, then pick the least-utilized node.

My inference, not stated in the whitepaper: the paper’s idea of trying locally first and escalating only when needed survives in the lease and spillback path. The escalation target is now another raylet, not a separate global scheduler, and load information comes from the GCS, not from heartbeats to a global scheduler.

what happened to the GCS design and to garbage collection?

The whitepaper says the GCS was renamed from Global Control Store to Global Control Service and “features a completely updated design”. It describes the GCS as “a server that manages cluster-level metadata, such as the locations of actors”.[21] Each ObjectRef is managed by one worker, its owner, so system metadata is “naturally distributed over multiple worker processes”.[21] On lineage garbage collection, the whitepaper says each worker caches lineage and evicts it when the total size exceeds a threshold (default 1 GB), and that the owner centralizes the logic needed to garbage collect objects and system metadata.[21] So lineage now sits with workers, where the paper put it in the GCS (§4.2.1).[1]

References

Footnotes


  1. Moritz, P., Nishihara, R., Wang, S., Tumanov, A., Liaw, R., Liang, E., Elibol, M., Yang, Z., Paul, W., Jordan, M. I., Stoica, I. “Ray: A Distributed Framework for Emerging AI Applications.” 13th USENIX Symposium on Operating Systems Design and Implementation (OSDI), 2018. arXiv:1712.05889v2. https://arxiv.org/abs/1712.05889. DOI 10.48550/arXiv.1712.05889. Accessed 2026-11-28. Section and figure locators in this post refer to the paper’s text.↩︎↩2↩3↩4↩5↩6↩7↩8↩9↩10↩11↩12↩13↩14↩15↩16↩17↩18↩19↩20↩21↩22↩23↩24↩25↩26↩27↩28↩29↩30↩31↩32↩33↩34↩35↩36↩37↩38↩39↩40↩41↩42↩43↩44↩45↩46↩47↩48↩49↩50↩51↩52↩53↩54↩55↩56↩57↩58↩59↩60↩61↩62↩63↩64↩65↩66↩67↩68↩69↩70↩71↩72↩73↩74↩75↩76↩77↩78↩79

  2. Apache Spark documentation. “Configuration” (spark.speculation, spark.speculation.interval, spark.speculation.multiplier). https://spark.apache.org/docs/latest/configuration.html. Accessed 2026-11-28.↩︎

  3. Apache Spark documentation. “Performance Tuning” (Adaptive Query Execution). https://spark.apache.org/docs/latest/sql-performance-tuning.html. Accessed 2026-11-28.↩︎

  4. Brockman, G., Cheung, V., Pettersson, L., Schneider, J., Schulman, J., Tang, J., Zaremba, W. “OpenAI Gym.” arXiv:1606.01540, 5 Jun 2016. https://arxiv.org/abs/1606.01540. Accessed 2026-11-28.↩︎

  5. Beattie, C., Leibo, J. Z., Teplyashin, D., et al. “DeepMind Lab.” arXiv:1612.03801, 2016. https://arxiv.org/abs/1612.03801. Accessed 2026-11-28.↩︎

  6. Apache Spark documentation. “RDD Programming Guide.” https://spark.apache.org/docs/latest/rdd-programming-guide.html. Accessed 2026-11-28.↩︎

  7. van Renesse, R., Schneider, F. B. “Chain Replication for Supporting High Throughput and Availability.” OSDI 2004. Abstract page: https://www.cs.cornell.edu/fbs/publications/ChainReplicOSDI.html. Accessed 2026-11-28. I read the abstract page, not the full paper.↩︎↩2↩3

  8. Memcached documentation. https://docs.memcached.org/. Accessed 2026-11-28.↩︎

  9. Redis documentation. “Redis as an in-memory data structure store.” https://redis.io/docs/latest/develop/get-started/data-structure-store/. Accessed 2026-11-28.↩︎

  10. Alluxio documentation. “Introduction.” https://docs.alluxio.io/os/user/stable/en/overview/Getting-Started.html. Accessed 2026-11-28.↩︎

  11. Moritz, P., Nishihara, R. “Plasma In-Memory Object Store.” Apache Arrow blog, 2017-08-08. https://arrow.apache.org/blog/2017/08/08/plasma-in-memory-object-store/. Accessed 2026-11-28.↩︎↩2

  12. Apache Arrow documentation. “Arrow Columnar Format.” https://arrow.apache.org/docs/format/Columnar.html. Accessed 2026-11-28.↩︎

  13. FlatBuffers documentation. https://flatbuffers.dev/. Accessed 2026-11-28.↩︎

  14. Protocol Buffers documentation. “Overview.” https://protobuf.dev/overview/. Accessed 2026-11-28.↩︎

  15. Wikipedia. “Consistency model.” https://en.wikipedia.org/wiki/Consistency_model. Accessed 2026-11-28. Secondary source.↩︎

  16. Wikipedia. “Immutable object.” https://en.wikipedia.org/wiki/Immutable_object. Accessed 2026-11-28. Secondary source.↩︎

  17. Wikipedia. “Event loop.” https://en.wikipedia.org/wiki/Event_loop. Accessed 2026-11-28. Secondary source.↩︎

  18. Wikipedia. “Data striping.” https://en.wikipedia.org/wiki/Data_striping. Accessed 2026-11-28. Secondary source.↩︎

  19. Apache Hadoop documentation. “MapReduce Tutorial.” https://hadoop.apache.org/docs/stable/hadoop-mapreduce-client/hadoop-mapreduce-client-core/MapReduceTutorial.html. Accessed 2026-11-28.↩︎

  20. Akka documentation. “Message Delivery Reliability.” https://doc.akka.io/libraries/akka-core/current/general/message-delivery-reliability.html. Accessed 2026-11-28.↩︎

  21. Ray Team. “Ray v2 Architecture” (Ray 2.0 whitepaper), October 2022. Official document: https://docs.google.com/document/d/1tBw9A4j62ruI5omIJbMxly-la5w4q_TjyJgJL_jN2fI/preview. Read through a third-party raw copy at https://raw.githubusercontent.com/halitum/ray-v2-architecture-zh/main/original/Ray-2.0-Architecture-whitepaper.md, not the official URL. Accessed 2026-11-28. Sections: “Distributed scheduler”, “Scheduling policies”, “Default Hybrid Policy”, “Resource fulfillment”, “Large objects and lineage reconstruction”.↩︎↩2↩3↩4↩5

  22. Ray documentation. “Object Fault Tolerance.” https://docs.ray.io/en/latest/ray-core/fault_tolerance/objects.html. Accessed 2026-11-28.↩︎↩2↩3

  23. Ray documentation. “Memory Management.” https://docs.ray.io/en/latest/ray-core/scheduling/memory-management.html. Accessed 2026-11-28.↩︎

  24. Ray documentation. “GCS Fault Tolerance.” https://docs.ray.io/en/latest/ray-core/fault_tolerance/gcs.html. Accessed 2026-11-28.↩︎

  25. Ray documentation. “Scheduling.” https://docs.ray.io/en/latest/ray-core/scheduling/index.html. Accessed 2026-11-28.↩︎