Repository navigation
[Experimental] Add NIC_NEAR_AID to place NIC RDMA WRITEs by AID - #371
amd-arozanov wants to merge 5 commits into
Conversation
On MI4XX (gfx1250) in SPX/NPS1 mode GPU memory alternates between the two AIDs every 16 KiB, so a NIC writing a contiguous buffer sends half of its data across the AID boundary. NIC_NEAR_AID makes that cost measurable: 1 writes only the 16 KiB blocks on the NIC-near AID, 2 only the blocks on the other AID, 0 keeps the contiguous layout. The GPU destination is allocated at twice its size and its AID phase is probed once per Transfer from CPU load latencies through an mmap of the destination DMA-BUF. Each piece is one RDMA WRITE, posted as chains of 32 with only the tail signaled and at most 8 chains in flight per queue pair, because longer unsignaled runs stall ionic. Validation copies the destination to the host and gathers the pieces back into logical order. Co-authored-by: Cursor <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Critical defects can hang execution on idle QPs or destination preparation failures across ranks, with additional unresolved near-AID validation and transfer-size checks.
5 open issues
Broadcast destination preparation failures before returning · New Count idle QPs as complete to prevent polling forever · New Use the near-AID WR size bound in NIC checks · New Use the sparse near-AID layout in interactive validation · New Clear the full near-AID destination between iterations · New
What changed in this PR
Adds experimental NIC_NEAR_AID support to TransferBench for measuring NIC RDMA write performance to near versus far AID memory blocks on MI4XX (gfx1250) in SPX/NPS1 mode. The default remains contiguous writes.
Changes:
- Exposes near/far placement through configuration and the
NIC_NEAR_AIDenvironment variable. - Adds destination-layout probing, expanded GPU allocations, chained 16 KiB writes, and layout-aware validation.
- Documents the option, prerequisites, and intended experiment.
| File | Description |
|---|---|
src/header/TransferBench.hpp |
Implements configuration checks, AID probing, transfer placement, completion tracking, and validation gathering. |
src/client/EnvVars.hpp |
Adds environment-variable parsing, help text, and configuration wiring. |
docs/reference/environment-variables.rst |
Documents placement modes and requirements. |
CHANGELOG.md |
Announces the experimental near/far AID feature. |
Review effort: Balanced
With 8 chains of 32 WRs in flight (248 unsignaled WRs per queue pair) an ionic queue pair occasionally stopped completing: one of about ten bidirectional 1 GB runs hung in ibv_poll_cq without an error CQE. With 4 chains, 40 bidirectional near and far runs with ALWAYS_VALIDATE=1 passed at the same bandwidth. The probe now times each read with std::chrono::steady_clock instead of rdtsc between lfences. The clflush stays: the DMA-BUF mapping is cached by the CPU, and without the flush every read hits the cache and no region shows an AID split. Co-authored-by: Cursor <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical issues can hang empty-QP transfers or strand ranks in collectives, while incomplete sparse-destination resets can let stale data mask missing writes.
6 open issues
Mark empty QPs complete to prevent near-AID hangs · New Count idle QPs as complete to prevent polling forever Broadcast destination preparation failures before returning Clear the full near-AID destination between iterations Use the sparse near-AID layout in interactive validation Use the near-AID WR size bound in NIC checks
Review effort: Balanced
The destination layout, the CPU probe of the AID phases, the build of the RDMA WRITE chains and the gather of the destination into logical order do not depend on TransferBench internals. They now live in src/header/NicNearAid.hpp, so TransferBench.hpp keeps only the option checks, the resource fields, the send window and the calls into the new header. Behavior is unchanged. Co-authored-by: Cursor <[email protected]>
NIC_NEAR_AID posts one RDMA WRITE per 16 KiB piece, but the max_msg_sz checks bounded the work request size by NIC_CHUNK_BYTES, which could reject a large transfer on a NIC with a small max_msg_sz. Both checks now use the piece size in this mode. The interactive PASS/FAIL display compared the DST contiguously and reported FAIL for a correct transfer; it now gathers the pieces into logical order, as ValidateAllTransfers does. With ALWAYS_VALIDATE > 0 the DST was cleared only up to the transfer size, so stale data in the rest of the doubled buffer could hide a missing write. The whole buffer is now cleared. Co-authored-by: Cursor <[email protected]>
The per-Transfer state now lives in one NicNearAid::State field, and the start of the send window and the handling of chain completions are NicNearAid::PostFirstChains and NicNearAid::OnChainDone, so ExecuteNicTransfer and RunNicExecutor only call into them. The checks that the NIC executor is on the SRC rank and the DST is GPU memory move to TransfersHaveErrors, so a bad Transfer is rejected before any resource is prepared, and NicWorkRequestBytes holds the work request size shared by both max_msg_sz checks. NicNearAid.hpp now describes the layout as a regular or inverted checkerboard of 16 KiB blocks, and the per-region phase is renamed to inverted to match. CHANGELOG and docs name the target as gfx1250. Co-authored-by: Cursor <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
AID selection depends on gfx1250 layout and CPU-latency assumptions that payload validation does not independently verify, requiring human assessment of hardware/topology correctness.
No open issues 🎉
4 resolved since last review
Review effort: Balanced


Experimental PR to test the near/far AID hypothesis on gfx1250 in SPX/NPS1 mode.
Motivation
This PR adds
NIC_NEAR_AID, which lets the NIC write to one AID only. In SPX/NPS1, GPU memory switches between the two AIDs every 16 KiB, so normally half of the data a NIC writes goes to the AID next to the NIC and half goes to the other AID. Writing to one AID shows how much the far half costs.Technical Details
Modes
NIC_NEAR_AID:0(default): normal contiguous writes, no change.1(near): write only to blocks on the AID next to the NIC.2(far): write only to blocks on the other AID. Used as a control.Memory layout
We measured the AID pattern beforehand. If you draw a 1 MiB region as an 8 x 8 grid of 16 KiB blocks, it looks like a checkerboard. Some regions use the inverted checkerboard:
N is a block on the AID next to the NIC, F is a block on the other AID.
Posting
NIC_MAX_SEND_WRmust be at least 256, because ionic also stalls when the WRs in flight fill more than half of the send queue.Validation
Validation and the interactive PASS/FAIL view now put the blocks back in order before comparing, because the data is no longer contiguous.
Code
The new logic is in a separate file,
src/header/NicNearAid.hpp, to keep it apart from the main code.TransferBench.hpponly has the option checks, the extra resources, the send loop, and the calls into the new file.Requirements
BYTE_OFFSET=0VALIDATE_ON_DEVICE=0Test Plan
Two gfx1250 nodes in SPX/NPS1 with AINIC (ionic) RoCE. Ranks set up over sockets (
TB_RANK,TB_NUM_RANKS=2,TB_MASTER_ADDR).NUM_ITERATIONS=20,ALWAYS_VALIDATE=1,NIC_NEAR_AID= 0, 1, 2.-2 (R0G0 R0I0.0 R1G0 4 1G) (R1G0 R1I0.0 R0G0 4 1G)-1 (R0G0 R0I0.0 R1G0 1 1G)USE_INTERACTIVE=1withALWAYS_VALIDATE=0Test Result
Both directions, Aggregate (CPU):