Skip to content

Incorporate PollSleepPolicy into CompletionQueueActor (#4736) - #4736

Open
samlurye wants to merge 4 commits into
meta-pytorch:mainfrom
samlurye:export-D117269425
Open

Incorporate PollSleepPolicy into CompletionQueueActor (#4736)#4736
samlurye wants to merge 4 commits into
meta-pytorch:mainfrom
samlurye:export-D117269425

Conversation

@samlurye

@samlurye samlurye commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary:

Move PollSleepPolicy into CompletionQueueActor. This is the same logic that QueuePairActor uses to determine how long to wait before the next poll.

Reviewed By: zdevito

Differential Revision: D117269425

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 24, 2026
@meta-codesync

meta-codesync Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

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

@meta-codesync meta-codesync Bot changed the title Incorporate PollSleepPolicy into CompletionQueueActor Incorporate PollSleepPolicy into CompletionQueueActor (#4736) Aug 25, 2026
samlurye added a commit to samlurye/monarch-1 that referenced this pull request Aug 25, 2026
)

Summary:

Move `PollSleepPolicy` into `CompletionQueueActor`. This is the same logic that `QueuePairActor` uses to determine how long to wait before the next poll.

Differential Revision: D117269425
samlurye added a commit to samlurye/monarch-1 that referenced this pull request Aug 25, 2026
)

Summary:

Move `PollSleepPolicy` into `CompletionQueueActor`. This is the same logic that `QueuePairActor` uses to determine how long to wait before the next poll.

Differential Revision: D117269425
samlurye added a commit to samlurye/monarch-1 that referenced this pull request Aug 26, 2026
)

Summary:

Move `PollSleepPolicy` into `CompletionQueueActor`. This is the same logic that `QueuePairActor` uses to determine how long to wait before the next poll.

Reviewed By: zdevito

Differential Revision: D117269425
samlurye added a commit to samlurye/monarch-1 that referenced this pull request Aug 26, 2026
)

Summary:

Move `PollSleepPolicy` into `CompletionQueueActor`. This is the same logic that `QueuePairActor` uses to determine how long to wait before the next poll.

Reviewed By: zdevito

Differential Revision: D117269425
samlurye added a commit to samlurye/monarch-1 that referenced this pull request Aug 26, 2026
)

Summary:
Pull Request resolved: meta-pytorch#4736

Move `PollSleepPolicy` into `CompletionQueueActor`. This is the same logic that `QueuePairActor` uses to determine how long to wait before the next poll.

Reviewed By: zdevito

Differential Revision: D117269425
Summary:

Introduce the `IbvCompletionQueue` trait, which will wrap real hardware-backed completion queue. The upcoming `CompletionQueueActor` will be generic over `IbvCompletionQueue`, allowing the batched polling logic to be tested without real hardware.

Reviewed By: zdevito

Differential Revision: D116689368
Summary:

Add `CompletionQueueActor`: one poller for many CQs, holding a route from each queue pair's completions back to that queue pair.

Each CQ actor starts empty. When a new QP starts up, the manager actor will (eventually, not yet implemented) assign a CQ and, independently, a CQ actor to that QP according to some user configured policy. This design allows us to try different concurrency models (e.g., one CQ actor polls every CQ in the process vs. one CQ actor for every NIC polls every CQ for that specific NIC).

When the QP is ready to start posting, it sends an `Attach` message to the assigned CQ actor with: the CQ to poll; an atomic counter indicating how many WRs that QP has posted so far; and a port for sending batches of completions back to the QP.

The CQ actor does not poll unless there is work to be done. QPs wake it by sending `Posted` notifications when they have posted new WRs. Between yields, the CQ actor loop polls every CQ that it tracks, requesting 64 CQEs at a time from each CQ. When it consumes CQEs, it routes them back to the relevant QP so that it can update its credit tracking and send replies to the original caller.

QP detaching logic and other failure handling is left for future commits. Nothing uses this code yet.

Reviewed By: zdevito

Differential Revision: D116806594
…-pytorch#4719)

Summary:

When a QP actor stops, the safest approach is to wait for all pending WRs to drain before actually destroying it. In order to not introduce an async dependency into a QP's teardown, we instead hand the underlying resources and CQ lease to the CQ actor via `Detach` when the QP actor drops. The CQ actor keeps the QP's resources and lease alive until all pending WRs have drained. This is important for correctness: we do not want the dead
QP's qp_num to be reassigned until we are sure it will produce no more CQEs; similarly, we cannot safely drop its CQ lease until we are sure it will produce no more CQEs. It is also useful for reasoning about behavior: different RDMA providers treat pending WRs and their CQEs differently when the associated QP is destroyed. Keeping the QP alive until all CQEs have drained means we can have one uniform implementation.

Reviewed By: zdevito

Differential Revision: D116853973
)

Summary:

Move `PollSleepPolicy` into `CompletionQueueActor`. This is the same logic that `QueuePairActor` uses to determine how long to wait before the next poll.

Reviewed By: zdevito

Differential Revision: D117269425
samlurye added a commit to samlurye/monarch-1 that referenced this pull request Aug 26, 2026
)

Summary:

Move `PollSleepPolicy` into `CompletionQueueActor`. This is the same logic that `QueuePairActor` uses to determine how long to wait before the next poll.

Reviewed By: zdevito

Differential Revision: D117269425
@samlurye
samlurye force-pushed the export-D117269425 branch 2 times, most recently from 09f4ddc to c9480ae Compare August 26, 2026 22:49
samlurye added a commit to samlurye/monarch-1 that referenced this pull request Aug 26, 2026
)

Summary:

Move `PollSleepPolicy` into `CompletionQueueActor`. This is the same logic that `QueuePairActor` uses to determine how long to wait before the next poll.

Reviewed By: zdevito

Differential Revision: D117269425
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. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant