fix(legacy): order work after ready-index publication - #703
Conversation
| while (atomicCAS(ready_idx, base_wqe_idx, new_wqe_idx) != base_wqe_idx) | ||
| ; | ||
| // Keep subsequent post-send work ordered after publishing `ready_idx`. | ||
| memory_fence_cta(); |
There was a problem hiding this comment.
🔵 suggestion: Consider adding a brief note in the comment that this new fence pairs with the pre-CAS __threadfence() to bracket the ready-index publication (acquire/release semantics). This makes the ordering contract explicit for future readers and clarifies why a CTA-scope fence is used here versus the system-scope fence above.
🤖 v3
🤖 ds-review-bot Code Reviewv6The added CTA fence appropriately prevents subsequent post-send work from being reordered before ready-index publication. No actionable regressions were found. v4v3This PR adds a single Correctness assessment (verified):
The change is low-risk protocol-ordering hardening with no API, batching, CQ polling, or WQE-construction changes. It looks correct and ready to merge. Files reviewed: 1 |
Summary
Restore the post-publication ordering point used by NVSHMEM after
ibgda_submit_requestsadvancesready_idx.DeepEP already uses
__threadfence()before the CAS to order WQE payloadwrites before ready-index publication. This change adds the separate fence
after the successful CAS so subsequent post-send work remains ordered after
that publication.
The added
memory_fence_cta()emits the samefence.acq_rel.ctainstruction used by NVSHMEM's
IBGDA_MFENCE()at the corresponding point:https://github.com/NVIDIA/nvshmem/blob/v3.7.2-0/src/include/non_abi/device/pt-to-pt/ibgda_device.cuh#L1648-L1670
Scope
The functional change is one fence in the legacy IBGDA submission helper.
It does not change:
This PR is protocol-ordering hardening and does not claim that this omitted
fence alone explains every observed legacy progress failure.
Validation
sm_103with CUDA 13.0.88,NVSHMEM 3.7.2, NCCL 2.30.7, and PyTorch 2.11;
sm_103cubin;bash ./format.sh;git diff --check upstream/main...HEAD;memory_fence_cta()isfence.acq_rel.cta, matching NVSHMEM's ordering primitive.The change also merges cleanly with the current head of #677; the two
patches address independent parts of the submission path.