Add AdaptiveScheduler with priority-based dispatch for pipeline sync ops#1390
Open
justinvjoseph wants to merge 2 commits into
Open
Add AdaptiveScheduler with priority-based dispatch for pipeline sync ops#1390justinvjoseph wants to merge 2 commits into
justinvjoseph wants to merge 2 commits into
Conversation
Contributor
|
@justinvjoseph has exported this pull request. If you are a Meta employee, you can view the originating Diff in D99935461. |
…earch#1389) Summary: Add `ResizableSemaphore` — an asyncio-compatible semaphore whose max permit count can be adjusted at runtime. This is the foundational primitive for dynamic concurrency control in SPDL pipelines. Key features: - `resize(new_max)` adjusts permits at runtime; resize-up wakes blocked waiters immediately, resize-down drains gracefully (no preemption) - `acquire()`/`release()` semantics match `asyncio.Semaphore` - `max_value` and `active` properties for observability - Thread-safe within asyncio's single-threaded model - Comprehensive error handling for invalid values This is Diff 1 of a 5-diff series implementing a unified adaptive scheduler for SPDL pipelines (T262755626). Differential Revision: D99920401
Summary: Introduces an opt-in priority scheduler that replaces the ThreadPoolExecutor's FIFO dispatch with a PriorityQueue. Deeper pipeline stages (closer to sink) are dispatched first, reducing pipeline bubble time and WIP. Key changes: - New `_scheduler.py` with `AdaptiveScheduler` class - `_PipeArgs` gains `nice` and `_depth` fields for priority control - `convert_to_async()` routes through scheduler when provided - `_build_node()` registers stages and intercepts sync ops - `build_pipeline()` gains `use_scheduler=True` flag - `PipelineBuilder.pipe()` gains `nice` parameter When `use_scheduler=False` (default), behavior is identical to today. Differential Revision: D99935461
3eab967 to
2752733
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary:
Introduces an opt-in priority scheduler that replaces the ThreadPoolExecutor's
FIFO dispatch with a PriorityQueue. Deeper pipeline stages (closer to sink)
are dispatched first, reducing pipeline bubble time and WIP.
Key changes:
_scheduler.pywithAdaptiveSchedulerclass_PipeArgsgainsniceand_depthfields for priority controlconvert_to_async()routes through scheduler when provided_build_node()registers stages and intercepts sync opsbuild_pipeline()gainsuse_scheduler=TrueflagPipelineBuilder.pipe()gainsniceparameterWhen
use_scheduler=False(default), behavior is identical to today.Differential Revision: D99935461