Skip to content

Add ResizableSemaphore for adaptive pipeline concurrency (#1389)#1389

Open
justinvjoseph wants to merge 1 commit into
facebookresearch:mainfrom
justinvjoseph:export-D99920401
Open

Add ResizableSemaphore for adaptive pipeline concurrency (#1389)#1389
justinvjoseph wants to merge 1 commit into
facebookresearch:mainfrom
justinvjoseph:export-D99920401

Conversation

@justinvjoseph
Copy link
Copy Markdown

@justinvjoseph justinvjoseph commented Apr 30, 2026

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

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 30, 2026
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented Apr 30, 2026

@justinvjoseph has exported this pull request. If you are a Meta employee, you can view the originating Diff in D99920401.

…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
@meta-codesync meta-codesync Bot changed the title Add ResizableSemaphore for adaptive pipeline concurrency Add ResizableSemaphore for adaptive pipeline concurrency (#1389) Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant