Skip to content

Add fence.proxy.async.shared::cta between mbarrier wait and TMA load. - #642

Merged
sphish merged 2 commits into
deepseek-ai:mainfrom
RayWang96:fix_fence
May 26, 2026
Merged

sphish merged 2 commits into
deepseek-ai:mainfrom
RayWang96:fix_fence

Conversation

@RayWang96

Copy link
Copy Markdown
Contributor

This fixes the issue mentioned in #621. Compared with the fix in #632, this version uses a CTA-scope fence, which resolves the problem while preserving performance.

The data race here comes from LDS and TMA loads, so we only need fence.proxy.async.shared::cta; to prevent the TMA load from being issued before LDS has completed.

Thanks to elvircrn's script, I've tried my fix on NVL72, the result is correct and the performance is as good as the original implementation.

@elvircrn

Copy link
Copy Markdown

Might be cleaner to use:

__device__ __forceinline__ void tma_store_fence() {
    asm volatile("fence.proxy.async.shared::cta;");
}

from utils.cuh.

@elvircrn

Copy link
Copy Markdown

Curious, does the issue revealed by my script go away with fence.proxy.async.shared::cta?

@sphish

sphish commented May 25, 2026

Copy link
Copy Markdown
Collaborator

@elvircrn Thank you for reporting this bug.

Investigating further revealed that the local rank polls the generic proxy but then uses TMA to load data. Without fence.proxy.async, TMA can see stale data.

For this issue you mentioned, the current approach does not strictly conform to the CUDA memory model, but based on some experiments we have done and our assumptions about the TMA implementation, we believe the current approach is safe on the existing architecture.

@RayWang96

Copy link
Copy Markdown
Contributor Author

Might be cleaner to use:

__device__ __forceinline__ void tma_store_fence() {
    asm volatile("fence.proxy.async.shared::cta;");
}

from utils.cuh.

Here, using fence is unrelated to the TMA store, so for clarity, I will use the same naming as in CUTLASS: void fence_view_async_shared()

@RayWang96

Copy link
Copy Markdown
Contributor Author

Curious, does the issue revealed by my script go away with fence.proxy.async.shared::cta?

Yes, I tried your script, and after the fix there are no issues:

T=256: correct=1024/1024
T=1024: correct=1024/1024

@sphish
sphish merged commit d4f41e4 into deepseek-ai:main May 26, 2026
MengYu10151 pushed a commit to MengYu10151/DeepEP that referenced this pull request Jul 6, 2026
Merge 8 upstream commits including:
- fence.proxy.async.shared::cta for TMA load (deepseek-ai#642)
- Fix single-node intra EP init (deepseek-ai#630)
- Fix internode dispatch args (deepseek-ai#641)
- Symmetric memory refactor with CPU buffer support
- NCCL SO name resolution fix for pip wheels (deepseek-ai#627)
- Various other updates (deepseek-ai#637, deepseek-ai#674)

Conflicts resolved:
- buffer.hpp: merged cpu_comm/cpu_buffer params with has_nvlink param
- nccl.cu: merged symmetric alloc refactor with has_nvlink and debug prints
- elastic.py: merged NCCL comm handle refactor with NVLink detection logic
- setup.py: adopted upstream dynamic NCCL lib name resolution

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants