Repository navigation
[Data] (Data Fault Tolerance 1/n) Add linear application layer lineage tracker - #65519
Conversation
Signed-off-by: davik <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces a LineageTracker class to manage task lineage graphs and track object reuse status during reconstruction, along with a comprehensive suite of linear lineage tracking tests. The feedback suggests validating that all task dependencies originate from a single parent, replacing a recursive parent-tracing function with an iterative loop to prevent potential recursion limit errors on deep chains, and simplifying a dependency check loop using Python's in operator.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
Reviewed by Cursor Bugbot for commit 4cf8de4. Configure here.
Signed-off-by: davik <[email protected]>
| OBJECT_UNRELATED -> object is unrelated to this reconstruction attempt. | ||
| we might want to raise on this status when handling it outside of testing. |
There was a problem hiding this comment.
Nit: I think that since we don't have a notion of a reconstruction plan as of this PR, OBJECT_UNRELATED is a moot case.
Would it make sense to drop this and add it in the follow up? Not a hard blocker, since the next PR should address this anyway.
There was a problem hiding this comment.
I'm leaning towards just keeping it. This way, the followup PR doesn't need to change the enum.
| tracker.register_task_complete(parent_task_id) | ||
| tracker.register_task_submission( | ||
| child_task_id, dependencies=_dependencies(parent_task_id, output_indices) | ||
| ) |
There was a problem hiding this comment.
Again, is it essential for the parent task to complete before the child task is registered/submitted? We should double check this, because our tests assume this
There was a problem hiding this comment.
lineage tracker should support both scenarios. We shouldn't fail just because task completed before downstream registration.
Co-authored-by: Ayush Kumar <[email protected]> Signed-off-by: Kunchen (David) Dai <[email protected]>
| @@ -0,0 +1,438 @@ | |||
| import sys | |||
There was a problem hiding this comment.
I think this test doesn't have any dependencies on Ray. For future PRs, could we put these types of tests under python/ray/data/tests/unit?
…acker (#65642) ## Description **Note**: This PR is a no-op and simply adds additional functionality to the Ray Data lineage tracking framework to support fan-out tasks. This PR builds on top of #65519 and introduces the ability to track fan-out tasks via plans. We define fan-out tasks as those whose outputs are consumed by more than one downstream tasks. At a high level, we support plans via the following steps: <img width="3318" height="1911" alt="image" src="https://github.com/user-attachments/assets/c9629b38-5a3a-4f74-acd8-82c4c908ea3d" /> 1. When a task fails, we set that task as the `target task`. A reconstruction plan ID associated with the target task is created. 2. From there, we begin walking up the task lineage graph. For each upstream parent, we create a plan entry that tracks the dependencies produced by that parent task that are necessary to reconstruct the downstream tasks that ultimately leads to the target task. 3. Once we've reached the root, we begin resubmission starting from the root task. 4. For each resubmitted task that completes, we check its reconstruction plan in the lineage graph and only pass the outputs that are needed in the plan to downstream tasks. 5. This continues until the target task is reconstructed. ## Related issues ## Additional information --------- Signed-off-by: davik <[email protected]> Co-authored-by: davik <[email protected]>
…acker (ray-project#65642) ## Description **Note**: This PR is a no-op and simply adds additional functionality to the Ray Data lineage tracking framework to support fan-out tasks. This PR builds on top of ray-project#65519 and introduces the ability to track fan-out tasks via plans. We define fan-out tasks as those whose outputs are consumed by more than one downstream tasks. At a high level, we support plans via the following steps: <img width="3318" height="1911" alt="image" src="https://github.com/user-attachments/assets/c9629b38-5a3a-4f74-acd8-82c4c908ea3d" /> 1. When a task fails, we set that task as the `target task`. A reconstruction plan ID associated with the target task is created. 2. From there, we begin walking up the task lineage graph. For each upstream parent, we create a plan entry that tracks the dependencies produced by that parent task that are necessary to reconstruct the downstream tasks that ultimately leads to the target task. 3. Once we've reached the root, we begin resubmission starting from the root task. 4. For each resubmitted task that completes, we check its reconstruction plan in the lineage graph and only pass the outputs that are needed in the plan to downstream tasks. 5. This continues until the target task is reconstructed. ## Related issues ## Additional information --------- Signed-off-by: davik <[email protected]> Co-authored-by: davik <[email protected]>
…e tracker (ray-project#65519) ## Description **Note**: This PR is a no-op on Ray Data's behavior ### Motivation Ray Data has largely relied on Core's lineage reconstruction for providing fault tolerance via replay of failed lineages. Although Core's lineage reconstruction provided fault tolerance for free by simply using core's APIs, it also left the following areas where an application level fault tolerance mechanism could provide even more improvements. * Primarily, ray data relies on the driver to perform the scheduling for each data processing task. However, Core's lineage reconstruction automatically schedules reconstruction tasks outside of ray data scheduler's knowledge, leading to instability. * Next, Core's reconstruction eagerly reconstructs any failed objects (on the same actors in the case of actor tasks), but this behavior is not necessarily always desirable when sometime batching reconstruction may lead to improved performance. These factors led us to rethink Ray Data fault tolerance. This PR is the first in a series of PR that reworks lineage reconstruction capabilities at the Data level to provide enhanced stability and fault tolerance performance. ### What this PR do? This PR specifically introduces the framework behind how we will track lineage at the application level. As an initial step, we provide specifically the capability to track linear DAGs first. Fan-ins and fan-outs will be supported in a followup PR. At a high level, we now track the lineage via `lineage_tracker`. The tracker builds a graph to track the dependency chain of each submitted task up to a root task. Each node within the graph corresponds to a single task. Each edge corresponds to a dependency between the tasks. <img width="2921" height="2075" alt="image" src="https://github.com/user-attachments/assets/72857eed-941f-41f7-99aa-fe7381d7e363" /> For example, in the diagram above, task 1 corresponds to `task node 1` that's added to the graph by the lineage tracker. Task 2 depends on the argument produced by task 1, and thus, there exists an edge from `task node 1` to `task node 2`. The lineage tracker interacts with the existing Ray Data logic at a couple of key points: * Upon fresh task submission, `register_task_submission` is invoked to add the task node and the edges from the parents to the new task node. * Upon task completion, `register_task_complete` is invoked to register the task as completed. * Upon task failure, `register_failed_task` is invoked to trace back up the dependency chain and return the root task(s) necessary for triggering resubmission. * Upon re-execution task's argument return, `get_pending_children` and `get_object_reuse_status` is invoked to determine if a downstream child that's part of the reconstruction should be resubmitted. To conclude, the current PR introduces the lineage tracking framework necessary for application level fault tolerance for a linear pipeline. The current changes focuses on building the dependency graph, and later PRs will focus on reconstruction as well as integration into Ray Data. ## Related issues ## Additional information --------- Signed-off-by: davik <[email protected]> Signed-off-by: Kunchen (David) Dai <[email protected]> Co-authored-by: davik <[email protected]> Co-authored-by: Ayush Kumar <[email protected]>
…acker (ray-project#65642) ## Description **Note**: This PR is a no-op and simply adds additional functionality to the Ray Data lineage tracking framework to support fan-out tasks. This PR builds on top of ray-project#65519 and introduces the ability to track fan-out tasks via plans. We define fan-out tasks as those whose outputs are consumed by more than one downstream tasks. At a high level, we support plans via the following steps: <img width="3318" height="1911" alt="image" src="https://github.com/user-attachments/assets/c9629b38-5a3a-4f74-acd8-82c4c908ea3d" /> 1. When a task fails, we set that task as the `target task`. A reconstruction plan ID associated with the target task is created. 2. From there, we begin walking up the task lineage graph. For each upstream parent, we create a plan entry that tracks the dependencies produced by that parent task that are necessary to reconstruct the downstream tasks that ultimately leads to the target task. 3. Once we've reached the root, we begin resubmission starting from the root task. 4. For each resubmitted task that completes, we check its reconstruction plan in the lineage graph and only pass the outputs that are needed in the plan to downstream tasks. 5. This continues until the target task is reconstructed. ## Related issues ## Additional information --------- Signed-off-by: davik <[email protected]> Co-authored-by: davik <[email protected]>
… streaming executor (#66220) ## Description Note: By default the changes introduced in this PR are a no-op in Ray Data. Data lineage reconstruction is enabled only when the job turns off Ray Core lineage reconstruction via the JobConfig (`JobConfig(_disable_job_level_lineage_reconstruction=True)`, #65487) This PR wires the lineage tracker introduced in #65519 and developed to support fan-in and fan-out tasks in #65642, #66136. This is a part of a larger effort to introduce lineage reconstruction as a first class construct in Ray Data for application-level fault tolerance. A more detailed proposal can be found on this Ray Enhancement Proposal (ray-project/enhancements#74) A task serves at most one reconstruction plan here; batching several plans onto one seed re-execution is a follow-up PR. ## Additional Information I've broken down the changes introduced in this PR at a higher level below. ### Concepts This is a representation of block lineage and how it dictates which tasks need to be submitted for reconstruction. <img width="3045" height="1400" alt="lineage_diagram" src="https://github.com/user-attachments/assets/b7164ae8-369e-4b68-87c2-665fe253bcca" /> As seen in the sketch above, lineage for a fan-out pipeline results in certain blocks being pruned as they are not required to reconstruct the lost object(s). Conversely, fan-in pipelines require a number of ancestor blocks to be reconstructed. This has a direct impact on the number of re-submitted tasks with Data lineage reconstruction. At a high level, the sketch below shows that lineage reconstruction and regular Ray Data task execution run in tandem during a pipeline. The main ideas to grasp are the following: - Blocks that are emitted by reconstruction tasks that are NOT part of a lost block's lineage are pruned, or NOT propagated downstream - Blocks produced by reconstruction tasks that are part of a lost block's lineage are withheld in a separate data structure (while accounting for their resource usage). When all reconstruction blocks in a dependency set are ready, they are bundled and added to the operator outqueue for a child reconstruction task to consume <img width="1946" height="1626" alt="fan_in_fan_out_LR" src="https://github.com/user-attachments/assets/9f1ecda1-cb38-48f7-a1f4-08f4e840e9d6" /> #### Building the lineage graph while the dataset executes 1. A `LineageTracker` instance is declared for the DAG's streaming executor 2. An operator that reads directly from an `InputDataBuffer` is a 'seed' operator. Its input is durable and resubmittable (a `ReadTask`/`FileManifest`, or the data itself for `from_*`), so it retains that bundle in a map in case it ever needs to re-submit seed tasks. The tracker stores IDs, never actual `RefBundle`s. 3. **On task submission**:`MapOperator._submit_data_task` registers any task to be submitted with the `LineageTracker`, keeping track of whether it's a fresh task or a reconstruction task, and assigning it a logical Ray Data task ID - A producing task registers each block that is produced with the `LineageTracker`, via `_output_ready_callback`. Specifically, a tuple of (producing task logical ID, output index). A consuming task during submission time (3.) looks up the above dependencies to add edges in the lineage graph 5. **On task completion**: The `LineageTracker` marks the task in the graph as complete. #### Triggering lineage reconstruction when any output block is lost 1. The callback `DataOpTask.on_data_ready` catches an `ObjectLostError`, and triggers data lineage reconstruction 2. The `LineageTracker` traces the lost object's lineage, back to its seed task, and opens a reconstruction plan for it (or folds to an existing plan, if already open) 3. The streaming executor aborts the lost task so its operator releases resources, these will be requested again by the triggered reconstruction tasks 4. The streaming executor also clears the completion state for the DAG (if necessary), and re-submits the seed task. #### Managing reconstructed blocks 1. As each reconstruction task emits blocks, check the reuse status of each block. `NEW` flows downstream as usual, `PRUNED`/`UNRELATED` is dropped these are not required to reconstruct lost objects, and `REUSED` is withheld so that it can be passed along to following reconstruction tasks 2. For a fan-in, the withheld objects must be released together, so that a downstream reconstruction task can accept inputs exactly as in its original attempt (maintaining the same order of blocks) ### Known Limitations in Current Implementation - No batching of seed tasks (if multiple reconstruction plans can be served by a single seed task). This is explicitly addressed in a follow up PR to enable batching of reconstruction plans. - Blocks lost after they're handed to an iterator (`iter_batches`, `iter_rows`, `take`, `take_all`) aren't reconstructed. This is going to be addressed as part of a follow up effort to integrate external consumers (e.g. Ray Train) with Data FT - No support for DAGs with shuffles. Lineage reconstruction for pipelines with `AllToAllOperator` / shuffles in the DAG needs to be scoped. We will work on this in the future. --------- Signed-off-by: Ayush Kumar <[email protected]> Signed-off-by: Ayush Kumar <[email protected]>

Description
Note: This PR is a no-op on Ray Data's behavior
Motivation
Ray Data has largely relied on Core's lineage reconstruction for providing fault tolerance via replay of failed lineages. Although Core's lineage reconstruction provided fault tolerance for free by simply using core's APIs, it also left the following areas where an application level fault tolerance mechanism could provide even more improvements.
These factors led us to rethink Ray Data fault tolerance. This PR is the first in a series of PR that reworks lineage reconstruction capabilities at the Data level to provide enhanced stability and fault tolerance performance.
What this PR do?
This PR specifically introduces the framework behind how we will track lineage at the application level. As an initial step, we provide specifically the capability to track linear DAGs first. Fan-ins and fan-outs will be supported in a followup PR.
At a high level, we now track the lineage via
lineage_tracker. The tracker builds a graph to track the dependency chain of each submitted task up to a root task. Each node within the graph corresponds to a single task. Each edge corresponds to a dependency between the tasks.For example, in the diagram above, task 1 corresponds to
task node 1that's added to the graph by the lineage tracker. Task 2 depends on the argument produced by task 1, and thus, there exists an edge fromtask node 1totask node 2.The lineage tracker interacts with the existing Ray Data logic at a couple of key points:
register_task_submissionis invoked to add the task node and the edges from the parents to the new task node.register_task_completeis invoked to register the task as completed.register_failed_taskis invoked to trace back up the dependency chain and return the root task(s) necessary for triggering resubmission.get_pending_childrenandget_object_reuse_statusis invoked to determine if a downstream child that's part of the reconstruction should be resubmitted.To conclude, the current PR introduces the lineage tracking framework necessary for application level fault tolerance for a linear pipeline. The current changes focuses on building the dependency graph, and later PRs will focus on reconstruction as well as integration into Ray Data.
Related issues
Additional information