[Bug]: Helix all-to-all receive path: restored payload words reach the outgoing bulk copy without a proxy fence
System Info
Source analysis of cpp/tensorrt_llm/kernels/ (helixAllToAll.cu, ll128Proto.cuh, cudaAsyncOps.cuh) at main b031dbe; these files are unchanged since a1f562a. Hopper or later (bulk async copies); no runtime environment involved.
Who can help?
No response
Information
- [ ] The official example scripts
- [ ] My own modified scripts
Tasks
- [ ] An officially supported task in the
examplesfolder (such as GLUE/SQuAD, ...) - [ ] My own task or dataset (give details below)
Reproduction
Found by checking a slice from the restore to the bulk store (a one-warp kernel that calls the shipped protoUnpack) against the PTX memory model with our own PTX-level checker; not reproduced on hardware.
On the receive path of the Helix all-to-all (helixAllToAll.cu):
- after the incoming copy completes (
smemBarWait, line 534),LL128Proto::protoUnpack(539–540) has the lanes withhalfLaneId < 15restore the payload word displaced by each 128-byte block's flag, with an ordinary shared-memory store (ll128Proto.cuh:140); s2gAllFields(543) then has lane 0 issuecp.async.bulk.global.shared::cta(cudaAsyncOps.cuh:166) to copy the fields out, and this bulk copy reads those bytes.
No proxy fence lies between the restoring stores and the bulk copy's read. The __syncwarp() at ll128Proto.cuh:144 is a warp barrier, and the cp_async_bulk_wait_group_read at 545 follows the issue.
Expected behavior
The bulk copy reads the restored payload words. PTX requires a proxy fence for that. PTX ISA 9.4 §8.6: "A proxy fence is required to synchronize memory operations across different proxies." §9.7.10.28.2: bulk copies are performed in the async proxy, and "Accessing the same memory location across multiple proxies needs a cross-proxy fence." The completion of the incoming copy makes its data visible to the generic proxy; it does not publish later generic stores to the async proxy.
actual behavior
Without the fence, PTX allows the outgoing bulk copy to read a block's flag word instead of its restored payload word, so the received field would carry a stale value at that position, with no error. Field 0 is always bulk-copied, so block 0's restored word is read whenever field 0 has at least 128 bytes; field 1 is affected only with USE_BULK_FIELD1 (variable field 1 allowed and 16-byte aligned). Lane 0's own restore is also unordered with its own bulk read, so this is not only a cross-lane issue. We have not observed a failure on hardware.
additional notes
Suggested fix: every restoring lane, including the issuing lane, executes fence.proxy.async.shared::cta after its restore and before the bulk copy. It can go just before the __syncwarp() at ll128Proto.cuh:144 (a shared header), or in helixAllToAll.cu right after the protoUnpack call (line 540), executed by all lanes and followed by a __syncwarp(), so that lane 0's copy is ordered after every lane's fence. With a fence in every lane, the same slice passes the check.
A related site not covered by that check: the next entry's incoming bulk load into the same shared bytes also follows these generic stores without a proxy fence.
Fixed by #20221, which adds fence_view_async_shared() and a __syncwarp() after protoUnpack in helixAllToAll.cu, as suggested above. Thanks for the fix and the test. Closing.