-
Notifications
You must be signed in to change notification settings - Fork 21
Fix/eval scheduler actor wedge #238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ekirimlioglu
wants to merge
5
commits into
RapidFireAI:main
Choose a base branch
from
ekirimlioglu:fix/eval-scheduler-actor-wedge
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f345f1b
fix(evals): prevent scheduler wedge on dispatch failure or actor death
ekirimlioglu d4eb616
test(evals): cover PipelineScheduler bookkeeping + add wedge repro
ekirimlioglu 474b9ef
chore(evals): trim verbose comments and prints in scheduler wedge work
ekirimlioglu 6e7e220
test(evals): fold wedge repro into pipeline_scheduler tests
ekirimlioglu 5728903
fix(evals): avoid busy-spin in scheduler busy-loop on partial batch c…
ekirimlioglu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| """Tests for PipelineScheduler bookkeeping. | ||
|
|
||
| Invariant: an actor marked busy by schedule() must be freed by either | ||
| set_completed_task(actor_id) or remove_pipeline(pipeline_id). If neither | ||
| is called, the controller's busy-loop wedges. | ||
| """ | ||
|
|
||
| from rapidfireai.evals.scheduling.pipeline_scheduler import PipelineScheduler | ||
|
|
||
|
|
||
| class TestPipelineSchedulerBookkeeping: | ||
| def test_schedule_marks_actor_busy(self): | ||
| scheduler = PipelineScheduler(pipeline_ids=[1, 2], num_actors=2, num_shards=3) | ||
| result = scheduler.schedule() | ||
| actor_id = result["actor_id"] | ||
| pipeline_id = result["pipeline_id"] | ||
| assert actor_id in (0, 1) | ||
| assert pipeline_id in (1, 2) | ||
| assert scheduler.actor_current_pipeline[actor_id] == pipeline_id | ||
|
|
||
| def test_set_completed_task_frees_actor_and_advances_progress(self): | ||
| scheduler = PipelineScheduler(pipeline_ids=[1], num_actors=1, num_shards=2) | ||
| result = scheduler.schedule() | ||
| actor_id = result["actor_id"] | ||
| assert scheduler.actor_current_pipeline[actor_id] == 1 | ||
| assert scheduler.pipeline_shards_completed[1] == 0 | ||
|
|
||
| scheduler.set_completed_task(actor_id) | ||
|
|
||
| assert scheduler.actor_current_pipeline[actor_id] == -1 | ||
| assert scheduler.pipeline_shards_completed[1] == 1 | ||
|
|
||
| def test_remove_pipeline_frees_actor_on_dispatch_failure(self): | ||
| scheduler = PipelineScheduler(pipeline_ids=[1, 2], num_actors=2, num_shards=2) | ||
|
|
||
| first = scheduler.schedule() | ||
| actor_id = first["actor_id"] | ||
| pipeline_id = first["pipeline_id"] | ||
| assert scheduler.actor_current_pipeline[actor_id] == pipeline_id | ||
|
|
||
| scheduler.remove_pipeline(pipeline_id) | ||
|
|
||
| assert scheduler.actor_current_pipeline[actor_id] == -1 | ||
| assert pipeline_id not in scheduler.pipeline_ids | ||
|
|
||
| second = scheduler.schedule() | ||
| assert second["pipeline_id"] != -1 | ||
| assert second["actor_id"] != -1 | ||
|
|
||
| def test_dispatch_failure_does_not_wedge_remaining_pipelines(self): | ||
| scheduler = PipelineScheduler(pipeline_ids=[1, 2], num_actors=1, num_shards=1) | ||
|
|
||
| first = scheduler.schedule() | ||
| failed_pipeline = first["pipeline_id"] | ||
| actor_id = first["actor_id"] | ||
| scheduler.remove_pipeline(failed_pipeline) | ||
| assert scheduler.actor_current_pipeline[actor_id] == -1 | ||
|
|
||
| second = scheduler.schedule() | ||
| survivor = second["pipeline_id"] | ||
| assert survivor != -1 | ||
| assert survivor != failed_pipeline | ||
| scheduler.set_completed_task(second["actor_id"]) | ||
|
|
||
| terminal = scheduler.schedule() | ||
| assert terminal["pipeline_id"] is None | ||
|
|
||
| def test_all_actors_busy_returns_busy_sentinel(self): | ||
| scheduler = PipelineScheduler(pipeline_ids=[1, 2], num_actors=2, num_shards=4) | ||
| scheduler.schedule() | ||
| scheduler.schedule() | ||
| result = scheduler.schedule() | ||
| assert result == {"pipeline_id": -1, "actor_id": -1, "shard_id": -1} | ||
|
|
||
| def test_set_completed_task_idempotent_on_free_actor(self): | ||
| scheduler = PipelineScheduler(pipeline_ids=[1], num_actors=1, num_shards=1) | ||
| assert scheduler.actor_current_pipeline[0] == -1 | ||
| scheduler.set_completed_task(0) | ||
| assert scheduler.actor_current_pipeline[0] == -1 | ||
| assert scheduler.pipeline_shards_completed[1] == 0 | ||
|
|
||
| def test_actor_leaks_busy_when_neither_completion_nor_removal_called(self): | ||
| """Regression: if dispatch fails and the controller forgets remove_pipeline, | ||
| schedule() returns the busy sentinel indefinitely. This is the wedge the | ||
| controller fix in run_multi_pipeline_inference prevents.""" | ||
| scheduler = PipelineScheduler(pipeline_ids=[1, 2], num_actors=1, num_shards=1) | ||
| scheduler.schedule() | ||
|
|
||
| for _ in range(20): | ||
| result = scheduler.schedule() | ||
| assert result == {"pipeline_id": -1, "actor_id": -1, "shard_id": -1} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.