CTA-scope CQ acquire fence for prims: -4.6% small-message sendrecv latency - #4019
Closed
goelayu wants to merge 1 commit into
Closed
CTA-scope CQ acquire fence for prims: -4.6% small-message sendrecv latency#4019goelayu wants to merge 1 commit into
goelayu wants to merge 1 commit into
Conversation
Contributor
|
@goelayu has exported this pull request. If you are a Meta employee, you can view the originating Diff in D118532592. |
goelayu
force-pushed
the
export-D118532592
branch
from
September 3, 2026 22:05
1963bfe to
7ea383c
Compare
…tency
Summary:
On Blackwell, the acquire fence DOCA runs after observing a completion lowers
to `CCTL.IVALL` -- a whole-L1 invalidate -- when its scope is SYS, and to a
`NOP` when it is CTA. prims fires the SYS form on every retired completion,
discarding the entire L1 each time.
prims hits that fence on **two** paths, not one: after observing a completion,
and again inside `reserve_wq_slots` -> `wait_until_slot_available`, which polls
the same CQ on every posting operation once the SQ has wrapped. The posting
path turns out to be the larger of the two (-3.1% of the -4.6%).
This adds an `acquire_scope` template parameter to
`doca_gpu_dev_verbs_poll_one_cq_at`, `doca_gpu_dev_verbs_poll_cq_at`,
`doca_gpu_dev_verbs_wait`, `doca_gpu_dev_verbs_wait_until_slot_available` and
`doca_gpu_dev_verbs_reserve_wq_slots`, defaulting to `SYNC_SCOPE_SYS`. prims
passes `SYNC_SCOPE_CTA` via `kCqAcquireScope`. **Every other caller is
unchanged.**
Note `reserve_wq_slots` also accepts `GPU_CODE_OPT_SKIP_AVAILABILITY_CHECK`,
which would skip the poll outright. Deliberately not used: that check exists to
stop us overrunning the SQ, and removing a safety check is a different risk
class from narrowing a fence scope. Scoping gets the same saving.
WHY NOT UPSTREAM'S MACRO -- upstream solves this with
`DOCA_GPUNETIO_VERBS_EXP_NIC_FENCE_ACQUIRE_CTA`, defined to 1 in GPUNetIO
v3.0.0+, closed SDK 3.4.0112 and NCCL 4.1.0. Adopting it here would be a
silent stale-data bug in `stable` ncclx:
- `ncclx/v2_30/def_build.bzl:224,514` depend on `:doca_gpunetio_dl`, which
propagates `-DDOCA_VERBS_USE_META_THIRD_PARTY=1`.
- That macro makes `gin_gdaki.h:28` include *this* vendored tree rather than
ncclx's own bundled DOCA copy.
- v2_30 GIN issues `doca_gpu_dev_verbs_get` (RDMA READ) at `gin_gdaki.h:266`
and waits via `poll_one_cq_at`/`doca_gpu_dev_verbs_wait` (`:305,308`), NOT
`get_wait` -- so upstream's compensating `get_wait` fence never fires for
it, and the caller then reads the READ destination with ordinary loads.
A template parameter with a SYS default cannot be mis-scoped: any call site
that does not opt in keeps the strong fence, even inside a TU that also uses
prims. An earlier revision of this diff used the macro and was exactly the bug
described above; it was caught in review before submission.
Reviewed By: zhiyongww, snarayankh
Differential Revision: D118532592
goelayu
force-pushed
the
export-D118532592
branch
from
September 3, 2026 22:49
7ea383c to
57ab2c9
Compare
Contributor
|
This pull request has been merged in 408e097. |
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:
On Blackwell, the acquire fence DOCA runs after observing a completion lowers
to
CCTL.IVALL-- a whole-L1 invalidate -- when its scope is SYS, and to aNOPwhen it is CTA. prims fires the SYS form on every retired completion,discarding the entire L1 each time.
prims hits that fence on two paths, not one: after observing a completion,
and again inside
reserve_wq_slots->wait_until_slot_available, which pollsthe same CQ on every posting operation once the SQ has wrapped. The posting
path turns out to be the larger of the two (-3.1% of the -4.6%).
This adds an
acquire_scopetemplate parameter todoca_gpu_dev_verbs_poll_one_cq_at,doca_gpu_dev_verbs_poll_cq_at,doca_gpu_dev_verbs_wait,doca_gpu_dev_verbs_wait_until_slot_availableanddoca_gpu_dev_verbs_reserve_wq_slots, defaulting toSYNC_SCOPE_SYS. primspasses
SYNC_SCOPE_CTAviakCqAcquireScope. Every other caller isunchanged.
Note
reserve_wq_slotsalso acceptsGPU_CODE_OPT_SKIP_AVAILABILITY_CHECK,which would skip the poll outright. Deliberately not used: that check exists to
stop us overrunning the SQ, and removing a safety check is a different risk
class from narrowing a fence scope. Scoping gets the same saving.
WHY NOT UPSTREAM'S MACRO -- upstream solves this with
DOCA_GPUNETIO_VERBS_EXP_NIC_FENCE_ACQUIRE_CTA, defined to 1 in GPUNetIOv3.0.0+, closed SDK 3.4.0112 and NCCL 4.1.0. Adopting it here would be a
silent stale-data bug in
stablencclx:ncclx/v2_30/def_build.bzl:224,514depend on:doca_gpunetio_dl, whichpropagates
-DDOCA_VERBS_USE_META_THIRD_PARTY=1.gin_gdaki.h:28include this vendored tree rather thanncclx's own bundled DOCA copy.
doca_gpu_dev_verbs_get(RDMA READ) atgin_gdaki.h:266and waits via
poll_one_cq_at/doca_gpu_dev_verbs_wait(:305,308), NOTget_wait-- so upstream's compensatingget_waitfence never fires forit, and the caller then reads the READ destination with ordinary loads.
A template parameter with a SYS default cannot be mis-scoped: any call site
that does not opt in keeps the strong fence, even inside a TU that also uses
prims. An earlier revision of this diff used the macro and was exactly the bug
described above; it was caught in review before submission.
Reviewed By: zhiyongww, snarayankh
Differential Revision: D118532592