Wait for resources to become available between actor pool stages - #2357
Wait for resources to become available between actor pool stages#2357ayushdg wants to merge 4 commits into
Conversation
Signed-off-by: Ayush Dattagupta <ayushdg95@gmail.com>
Signed-off-by: Ayush Dattagupta <ayushdg95@gmail.com>
Signed-off-by: Ayush Dattagupta <ayushdg95@gmail.com>
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
/ok to test 0f04448 |
Signed-off-by: Ayush Dattagupta <ayushdg95@gmail.com>
|
@greptile review |
Greptile SummaryThis PR adds resource high-water tracking and bounded polling between Ray actor-pool stages so asynchronous actor teardown can release capacity before the next pool is sized. Major changes:
Confidence Score: 4/5The PR should not merge until polling is bounded by the configured timeout. The new loop checks its deadline before sleeping for an unrestricted polling interval, allowing valid configuration values to delay degradation or failure well beyond the promised timeout. Files Needing Attention: nemo_curator/backends/ray_actor_pool/utils.py Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Finish stage] --> B[Kill stage actors]
B --> C[Update resource high-water baseline]
C --> D[Calculate intended actor count]
D --> E[Poll currently available resources]
E --> F{Enough for intended pool?}
F -->|Yes| G[Start intended actor pool]
F -->|No| H{Timeout reached?}
H -->|No| I[Sleep for polling interval]
I --> E
H -->|Yes, at least one actor fits| J[Start degraded actor pool]
H -->|Yes, no actor fits| K[Raise TimeoutError]
Reviews (1): Last reviewed commit: "Reduce interval and timeout defaults" | Re-trigger Greptile |
| f" Waiting for resources for {stage.name}: CPUs={available_resources[0]}/{required_cpus}, " | ||
| f"GPUs={available_resources[1]}/{required_gpus}" | ||
| ) | ||
| time.sleep(interval) |
There was a problem hiding this comment.
Polling overshoots resource timeout
When resource_wait_interval_s exceeds the time remaining before resource_wait_timeout_s, this unbounded sleep delays degradation or failure beyond the configured timeout; for example, a 5-second timeout with a 60-second interval blocks for about 60 seconds.
| time.sleep(interval) | |
| time.sleep(min(interval, max(0.0, deadline - time.monotonic()))) |
Description
Ray actor pool executor goes stage by stage kills all actors and the end of the stage and restarts new set of actors for the next stage.
The executor gauges how many actors it can start by looking at
cluster.available_resources.But given that ray.kill is async and it may take time for the available resources to update, the default sleep of 0.2s may not be enough for all machines to free up existing processes.
This may lead to fewer resources being spun up for future stages or no resources available at all leading to errors.
The new proposed solution adds the following:
intervalsecondstimeouts the stage starts with whatever is available.Here's the new process:
a. If a stage now has enough resources to get these actors, start the stage.
b. If a stage doesn't have enough resources to get these actors, sleep for
intervalseconds and recheck.c. If a stage doesn't have enough resources to get these actors even after timeout, start as many actors as possible with the given shape or error out if even 1 cannot be started.
Usage
# Add snippet demonstrating usageChecklist