Repository navigation
[data] Tolerate actor deaths during init in ActorPoolMapOperator via DataContext.max_consecutive_actor_init_deaths - #64846
Conversation
…ontext.max_actor_init_failures A single actor whose __init__ fails (e.g. an LLM engine failing to boot) currently kills the whole Dataset job: the readiness ref resolves with ActorDiedError, _ActorPool.pending_to_running re-raises it, and the unguarded metadata-task path propagates it out of the streaming executor. max_restarts=-1 does not help because Ray Core does not restart actors whose creation task failed (USER_ERROR zeroes remaining_restarts), and max_errored_blocks only guards the data-task path. At N-actor pools any per-boot flake probability p becomes job-death probability 1-(1-p)^N. Catch the failure at the pool boundary and charge it against a new per-operator budget, DataContext.max_actor_init_failures (default 0 = today's fail-fast behavior; -1 = unlimited; env RAY_DATA_MAX_ACTOR_INIT_FAILURES). Tolerated failures are logged and the actor autoscaler starts a replacement (the pool is below its target size). To avoid endless crash loops on deterministic misconfiguration, a systemic guard re-raises when no actor of the operator has ever initialized successfully after max(initial pool size, 3) failures. Signed-off-by: xyuzh <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces a per-operator budget for actor initialization failures in Ray Data, allowing failed actors to be replaced up to a specified limit (DataContext.max_actor_init_failures). It also implements a systemic failure guard to fail fast if no actors can initialize successfully, preventing infinite crash loops. Unit and integration tests have been added to verify this behavior. No review comments were provided, so there is no additional feedback.
…unting Replace the cumulative failure budget plus hardcoded systemic-failure threshold with a single consecutive-failure counter that resets whenever an actor initializes successfully. This matches the semantics of actor_init_max_retries, removes the magic constant and the _any_actor_started flag, and renames the config to max_consecutive_actor_init_failures to make the semantics explicit. Signed-off-by: xyuzh <[email protected]>
| actor_init_retry_on_errors: bool = DEFAULT_ACTOR_INIT_RETRY_ON_ERRORS | ||
| actor_init_max_retries: int = DEFAULT_ACTOR_INIT_MAX_RETRIES |
There was a problem hiding this comment.
How come you need consecutive retries, rather than these 2 vars?
There was a problem hiding this comment.
These are at different level,
actor_init_retry_on_errors: bool = DEFAULT_ACTOR_INIT_RETRY_ON_ERRORS
actor_init_max_retries: int = DEFAULT_ACTOR_INIT_MAX_RETRIES
catches user code exceptions but when there is a hardware failure this level doesn't raise.
Failure handling at this PR is for _task_done_callback which is when an actor doesn't return and we reschedule this actor at potentially different hardware.
There was a problem hiding this comment.
Hmm so we have retries in the Actor __init__ function itself, and we have retries on the driver? Is it possible to unify both then? How come
ray/python/ray/data/_internal/execution/operators/actor_pool_map_operator.py
Lines 659 to 672 in 413f9d9
There was a problem hiding this comment.
oh i see https://docs.ray.io/en/latest/ray-core/api/doc/ray.exceptions.RayActorError.html#ray-exceptions-rayactorerror, this means outside of the ray task, and since ray creation task is also a task, this can fail before init can be called?
if that's the case, then I think it's fine to catch the exception. I'm wondering if we should narrow it further with ActorDiedError or ActorUnavailableError
There was a problem hiding this comment.
- this can fail before init can be called?
- yes
This error could fall to ActorDiedError OwnerDiedError, ActorUnavailableError
RayError is the right catch
… from in-process UDF init retries 'actor init failure' was ambiguous next to actor_init_retry_on_errors / actor_init_max_retries, which retry the UDF constructor in-process inside a live actor. The new knob counts actor deaths (Ray's own vocabulary: ActorDiedError), so name it accordingly and cross-reference the two mechanisms in the DataContext docstrings. Signed-off-by: xyuzh <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 1c28913. Configure here.
… helper Signed-off-by: xyuzh <[email protected]>
| def test_actor_init_death_budget_with_in_actor_retries( | ||
| ray_start_regular_shared_2_cpus, restore_data_context | ||
| ): | ||
| """Tests that the pool-level death budget counts actor incarnations, not |
There was a problem hiding this comment.
not sure what actor incarnations are, but could you explain why the test succeeds? Like you fail 3 times in the init function, but we succeed because we fail 2x init, then register consecutive death as 1, then do that again?)
There was a problem hiding this comment.
incarnations mean actor process
ctx.actor_init_max_retries = 1 allows a single actor to fail once so
T1: actor process 1, it fails once and retries
T2: actor process 1, it fails again and dies
T3: (ctx.max_consecutive_actor_init_deaths = 1) restart actor process 2
T4: actor process 2, it fails again and dies and retries
T5: actor process 2, it succeeds
There was a problem hiding this comment.
I see, i think that would be helpful in the docstring
| assert len(result.take_all()) == 10 | ||
|
|
||
|
|
||
| def test_on_actor_init_death_unit( |
There was a problem hiding this comment.
Im curious, how come it has to be consecutive, what about non-consecutive? Is checking for consecutive more defensive against hardware failures?
There was a problem hiding this comment.
consecutiveness decides if the error is deterministic.
Normally such failures(for large scale data pipeline) should be rare and low probability, if it happens consecutively we should tolerate it as it mostly should be a bug
| # Consecutive actor deaths during initialization; resets whenever an actor | ||
| # of this operator initializes successfully (see | ||
| # ``DataContext.max_consecutive_actor_init_deaths``). | ||
| self._consecutive_actor_init_deaths = 0 |
There was a problem hiding this comment.
hmm also this is a global variable, should we make this per-actor?
There was a problem hiding this comment.
This defines the behavior of actors globally
Why make it per actor?
There was a problem hiding this comment.
My reasoning is that actors are scheduled across nodes. Some nodes are healthier than others, so an actor trying to schedule on the same node 3 times would trigger the failure, rather than 3 separate actors scheduling on 3 separate nodes (and the reason we could tolerate this in ray data is that maybe it's a temporary network partition, and all actors fail consecutively). Now i'm not sure how common that is, but wanted ur thoughts.
There was a problem hiding this comment.
In my case where I use 200 nodes and each node has 192 cores I am able to get the workload running with the fix applied.
SPREAD is the default for Ray data so I think it's less of a concern
Signed-off-by: xyuzh <[email protected]>
…meline Spell out how actor_init_max_retries and max_consecutive_actor_init_deaths interact in test_actor_init_death_budget_with_in_actor_retries: two init attempts per actor process, one budget charge per dead process. Collapse the comment above the mapper that restated the same walkthrough. Signed-off-by: xyuzh <[email protected]>
…DataContext.max_consecutive_actor_init_deaths (ray-project#64846) ## Why are these changes needed? A single actor whose `__init__` fails (e.g. an LLM engine failing to boot) kills the whole Dataset job: the readiness ref resolves with `ActorDiedError`, `_ActorPool.pending_to_running` re-raises it, and the metadata-task branch of `process_completed_tasks` has no guard (`max_errored_blocks` only protects the `DataOpTask` branch), so the exception fails the execution. `max_restarts=-1` (Ray Data's own default) cannot help because Ray Core does not restart actors whose creation task failed — the death is a `USER_ERROR` and `gcs_actor_manager` zeroes `remaining_restarts`. At an N-actor pool, any per-boot flake probability p becomes job-death probability 1-(1-p)^N: at 1,600 vLLM engines, three separate boot-flake classes (port races, VRAM residue, ramp-wave timeouts) each repeatedly killed full production runs. This PR catches the failure at the pool boundary (`_task_done_callback`) and charges it against a new per-operator budget, `DataContext.max_consecutive_actor_init_deaths` (env `RAY_DATA_MAX_CONSECUTIVE_ACTOR_INIT_DEATHS`; default `0` preserves today's fail-fast behavior; `-1` = unlimited). The counter is **consecutive**: it resets whenever any actor of the operator initializes successfully — the same semantics as the existing `actor_init_max_retries`. Sporadic boot flakes in a progressing pipeline are tolerated indefinitely within the budget, while a systemically broken UDF (bad model path) never resets the counter and exhausts the budget, so no separate systemic-failure heuristic or hardcoded threshold is needed. Tolerated failures are logged with a running count and the actor autoscaler starts a replacement (the pool is below target size, and the below-min branch runs before the no-input guard, so no explicit re-provision is needed). Counting is per actor incarnation, after any in-actor `actor_init_retry_on_errors` retries. ## Production-scale evidence Two byte-identical 1,600-engine / 70M-caption video-captioning runs on Anyscale (CoreWeave, RTX PRO 6000 fleet), same input corpus and knobs; the only variable is boot-failure handling (run against the earlier cumulative-budget revision of this patch; the consecutive-counting revision is strictly more permissive for the interleaved-flake pattern observed): | | Baseline (app-level workaround that swallows pending_to_running errors) | This patch (workaround disabled, budget=200) | |---|---|---| | Outcome | SUCCEEDED | SUCCEEDED | | Captions written | 69,982,028 | 69,982,028 (identical) | | Wall time | 5,525 s | 5,778 s | | Real engine-boot failures absorbed | 2 | 8 (single ramp-wave burst; every one logged and the pool recovered to its full 1,500 floor) | A separate fault-injection job validated both semantics deterministically on the same stack: 3 injected creation-task failures with budget 5 → dataset completes with correct output; budget 1 → tolerates one, then re-raises the original `ActorDiedError` after exactly 2 incarnations. Companion PR for the GCS-side half of the same incident: ray-project#64845. ## Related issue number None found — searched open PRs/issues for actor init/boot failure tolerance before opening; no in-flight work. Adjacent context: the vLLM batch stage's `os._exit(1)` workaround handles post-boot engine death via `max_restarts` (see ray-project#59522), but nothing covers creation-task failures. ## Checks - [x] I've signed off every commit (DCO). - [x] I've run pre-commit on the changed files. - [x] Testing strategy: - New tests in `python/ray/data/tests/test_actor_pool_map_operator.py`: `test_actor_init_death_budget` (parametrized: budget covers / exceeded / unlimited), `test_actor_init_death_budget_with_in_actor_retries` (proves incarnation-level counting), `test_on_actor_init_death_unit` (raise timing against the consecutive budget, reset-on-success, re-raise identity). - `python -m pytest python/ray/data/tests/test_actor_pool_map_operator.py -k "init_death or init_failure"` → 8 passed (pytest 7.4.4). Existing `test_actor_init_failure_retry` and `test_actor_pool_map_operator_init` pass unchanged. Per the repo's AI contribution policy: AI assistance was used to develop this change; every changed line was reviewed, the tests above were run locally, and the change was exercised end-to-end at production scale as described. --------- Signed-off-by: xyuzh <[email protected]>
…DataContext.max_consecutive_actor_init_deaths (ray-project#64846) ## Why are these changes needed? A single actor whose `__init__` fails (e.g. an LLM engine failing to boot) kills the whole Dataset job: the readiness ref resolves with `ActorDiedError`, `_ActorPool.pending_to_running` re-raises it, and the metadata-task branch of `process_completed_tasks` has no guard (`max_errored_blocks` only protects the `DataOpTask` branch), so the exception fails the execution. `max_restarts=-1` (Ray Data's own default) cannot help because Ray Core does not restart actors whose creation task failed — the death is a `USER_ERROR` and `gcs_actor_manager` zeroes `remaining_restarts`. At an N-actor pool, any per-boot flake probability p becomes job-death probability 1-(1-p)^N: at 1,600 vLLM engines, three separate boot-flake classes (port races, VRAM residue, ramp-wave timeouts) each repeatedly killed full production runs. This PR catches the failure at the pool boundary (`_task_done_callback`) and charges it against a new per-operator budget, `DataContext.max_consecutive_actor_init_deaths` (env `RAY_DATA_MAX_CONSECUTIVE_ACTOR_INIT_DEATHS`; default `0` preserves today's fail-fast behavior; `-1` = unlimited). The counter is **consecutive**: it resets whenever any actor of the operator initializes successfully — the same semantics as the existing `actor_init_max_retries`. Sporadic boot flakes in a progressing pipeline are tolerated indefinitely within the budget, while a systemically broken UDF (bad model path) never resets the counter and exhausts the budget, so no separate systemic-failure heuristic or hardcoded threshold is needed. Tolerated failures are logged with a running count and the actor autoscaler starts a replacement (the pool is below target size, and the below-min branch runs before the no-input guard, so no explicit re-provision is needed). Counting is per actor incarnation, after any in-actor `actor_init_retry_on_errors` retries. ## Production-scale evidence Two byte-identical 1,600-engine / 70M-caption video-captioning runs on Anyscale (CoreWeave, RTX PRO 6000 fleet), same input corpus and knobs; the only variable is boot-failure handling (run against the earlier cumulative-budget revision of this patch; the consecutive-counting revision is strictly more permissive for the interleaved-flake pattern observed): | | Baseline (app-level workaround that swallows pending_to_running errors) | This patch (workaround disabled, budget=200) | |---|---|---| | Outcome | SUCCEEDED | SUCCEEDED | | Captions written | 69,982,028 | 69,982,028 (identical) | | Wall time | 5,525 s | 5,778 s | | Real engine-boot failures absorbed | 2 | 8 (single ramp-wave burst; every one logged and the pool recovered to its full 1,500 floor) | A separate fault-injection job validated both semantics deterministically on the same stack: 3 injected creation-task failures with budget 5 → dataset completes with correct output; budget 1 → tolerates one, then re-raises the original `ActorDiedError` after exactly 2 incarnations. Companion PR for the GCS-side half of the same incident: ray-project#64845. ## Related issue number None found — searched open PRs/issues for actor init/boot failure tolerance before opening; no in-flight work. Adjacent context: the vLLM batch stage's `os._exit(1)` workaround handles post-boot engine death via `max_restarts` (see ray-project#59522), but nothing covers creation-task failures. ## Checks - [x] I've signed off every commit (DCO). - [x] I've run pre-commit on the changed files. - [x] Testing strategy: - New tests in `python/ray/data/tests/test_actor_pool_map_operator.py`: `test_actor_init_death_budget` (parametrized: budget covers / exceeded / unlimited), `test_actor_init_death_budget_with_in_actor_retries` (proves incarnation-level counting), `test_on_actor_init_death_unit` (raise timing against the consecutive budget, reset-on-success, re-raise identity). - `python -m pytest python/ray/data/tests/test_actor_pool_map_operator.py -k "init_death or init_failure"` → 8 passed (pytest 7.4.4). Existing `test_actor_init_failure_retry` and `test_actor_pool_map_operator_init` pass unchanged. Per the repo's AI contribution policy: AI assistance was used to develop this change; every changed line was reviewed, the tests above were run locally, and the change was exercised end-to-end at production scale as described. --------- Signed-off-by: xyuzh <[email protected]> Signed-off-by: 400Ping <[email protected]>
…DataContext.max_consecutive_actor_init_deaths (ray-project#64846) ## Why are these changes needed? A single actor whose `__init__` fails (e.g. an LLM engine failing to boot) kills the whole Dataset job: the readiness ref resolves with `ActorDiedError`, `_ActorPool.pending_to_running` re-raises it, and the metadata-task branch of `process_completed_tasks` has no guard (`max_errored_blocks` only protects the `DataOpTask` branch), so the exception fails the execution. `max_restarts=-1` (Ray Data's own default) cannot help because Ray Core does not restart actors whose creation task failed — the death is a `USER_ERROR` and `gcs_actor_manager` zeroes `remaining_restarts`. At an N-actor pool, any per-boot flake probability p becomes job-death probability 1-(1-p)^N: at 1,600 vLLM engines, three separate boot-flake classes (port races, VRAM residue, ramp-wave timeouts) each repeatedly killed full production runs. This PR catches the failure at the pool boundary (`_task_done_callback`) and charges it against a new per-operator budget, `DataContext.max_consecutive_actor_init_deaths` (env `RAY_DATA_MAX_CONSECUTIVE_ACTOR_INIT_DEATHS`; default `0` preserves today's fail-fast behavior; `-1` = unlimited). The counter is **consecutive**: it resets whenever any actor of the operator initializes successfully — the same semantics as the existing `actor_init_max_retries`. Sporadic boot flakes in a progressing pipeline are tolerated indefinitely within the budget, while a systemically broken UDF (bad model path) never resets the counter and exhausts the budget, so no separate systemic-failure heuristic or hardcoded threshold is needed. Tolerated failures are logged with a running count and the actor autoscaler starts a replacement (the pool is below target size, and the below-min branch runs before the no-input guard, so no explicit re-provision is needed). Counting is per actor incarnation, after any in-actor `actor_init_retry_on_errors` retries. ## Production-scale evidence Two byte-identical 1,600-engine / 70M-caption video-captioning runs on Anyscale (CoreWeave, RTX PRO 6000 fleet), same input corpus and knobs; the only variable is boot-failure handling (run against the earlier cumulative-budget revision of this patch; the consecutive-counting revision is strictly more permissive for the interleaved-flake pattern observed): | | Baseline (app-level workaround that swallows pending_to_running errors) | This patch (workaround disabled, budget=200) | |---|---|---| | Outcome | SUCCEEDED | SUCCEEDED | | Captions written | 69,982,028 | 69,982,028 (identical) | | Wall time | 5,525 s | 5,778 s | | Real engine-boot failures absorbed | 2 | 8 (single ramp-wave burst; every one logged and the pool recovered to its full 1,500 floor) | A separate fault-injection job validated both semantics deterministically on the same stack: 3 injected creation-task failures with budget 5 → dataset completes with correct output; budget 1 → tolerates one, then re-raises the original `ActorDiedError` after exactly 2 incarnations. Companion PR for the GCS-side half of the same incident: ray-project#64845. ## Related issue number None found — searched open PRs/issues for actor init/boot failure tolerance before opening; no in-flight work. Adjacent context: the vLLM batch stage's `os._exit(1)` workaround handles post-boot engine death via `max_restarts` (see ray-project#59522), but nothing covers creation-task failures. ## Checks - [x] I've signed off every commit (DCO). - [x] I've run pre-commit on the changed files. - [x] Testing strategy: - New tests in `python/ray/data/tests/test_actor_pool_map_operator.py`: `test_actor_init_death_budget` (parametrized: budget covers / exceeded / unlimited), `test_actor_init_death_budget_with_in_actor_retries` (proves incarnation-level counting), `test_on_actor_init_death_unit` (raise timing against the consecutive budget, reset-on-success, re-raise identity). - `python -m pytest python/ray/data/tests/test_actor_pool_map_operator.py -k "init_death or init_failure"` → 8 passed (pytest 7.4.4). Existing `test_actor_init_failure_retry` and `test_actor_pool_map_operator_init` pass unchanged. Per the repo's AI contribution policy: AI assistance was used to develop this change; every changed line was reviewed, the tests above were run locally, and the change was exercised end-to-end at production scale as described. --------- Signed-off-by: xyuzh <[email protected]>

Why are these changes needed?
A single actor whose
__init__fails (e.g. an LLM engine failing to boot) kills the whole Dataset job: the readiness ref resolves withActorDiedError,_ActorPool.pending_to_runningre-raises it, and the metadata-task branch ofprocess_completed_taskshas no guard (max_errored_blocksonly protects theDataOpTaskbranch), so the exception fails the execution.max_restarts=-1(Ray Data's own default) cannot help because Ray Core does not restart actors whose creation task failed — the death is aUSER_ERRORandgcs_actor_managerzeroesremaining_restarts. At an N-actor pool, any per-boot flake probability p becomes job-death probability 1-(1-p)^N: at 1,600 vLLM engines, three separate boot-flake classes (port races, VRAM residue, ramp-wave timeouts) each repeatedly killed full production runs.This PR catches the failure at the pool boundary (
_task_done_callback) and charges it against a new per-operator budget,DataContext.max_consecutive_actor_init_deaths(envRAY_DATA_MAX_CONSECUTIVE_ACTOR_INIT_DEATHS; default0preserves today's fail-fast behavior;-1= unlimited). The counter is consecutive: it resets whenever any actor of the operator initializes successfully — the same semantics as the existingactor_init_max_retries. Sporadic boot flakes in a progressing pipeline are tolerated indefinitely within the budget, while a systemically broken UDF (bad model path) never resets the counter and exhausts the budget, so no separate systemic-failure heuristic or hardcoded threshold is needed. Tolerated failures are logged with a running count and the actor autoscaler starts a replacement (the pool is below target size, and the below-min branch runs before the no-input guard, so no explicit re-provision is needed). Counting is per actor incarnation, after any in-actoractor_init_retry_on_errorsretries.Production-scale evidence
Two byte-identical 1,600-engine / 70M-caption video-captioning runs on Anyscale (CoreWeave, RTX PRO 6000 fleet), same input corpus and knobs; the only variable is boot-failure handling (run against the earlier cumulative-budget revision of this patch; the consecutive-counting revision is strictly more permissive for the interleaved-flake pattern observed):
A separate fault-injection job validated both semantics deterministically on the same stack: 3 injected creation-task failures with budget 5 → dataset completes with correct output; budget 1 → tolerates one, then re-raises the original
ActorDiedErrorafter exactly 2 incarnations.Companion PR for the GCS-side half of the same incident: #64845.
Related issue number
None found — searched open PRs/issues for actor init/boot failure tolerance before opening; no in-flight work. Adjacent context: the vLLM batch stage's
os._exit(1)workaround handles post-boot engine death viamax_restarts(see #59522), but nothing covers creation-task failures.Checks
python/ray/data/tests/test_actor_pool_map_operator.py:test_actor_init_death_budget(parametrized: budget covers / exceeded / unlimited),test_actor_init_death_budget_with_in_actor_retries(proves incarnation-level counting),test_on_actor_init_death_unit(raise timing against the consecutive budget, reset-on-success, re-raise identity).python -m pytest python/ray/data/tests/test_actor_pool_map_operator.py -k "init_death or init_failure"→ 8 passed (pytest 7.4.4). Existingtest_actor_init_failure_retryandtest_actor_pool_map_operator_initpass unchanged.Per the repo's AI contribution policy: AI assistance was used to develop this change; every changed line was reviewed, the tests above were run locally, and the change was exercised end-to-end at production scale as described.