NVIDIA / NVIDIA/cutlass

[QST]How to Handle Synchronization with Different Thread Counts for Producer and Consumer in CUTLASS?

Open
#1,998 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

? - Needs Triage inactive-30d inactive-90d question
Dominant language
C++
Stars
10.5k
Forks
2.1k
Avg merge
3d 11h
Merged PRs (30d)
7

Description

In scenarios where both producer and consumer threads exist, how can we achieve synchronization using CUTLASS's barrier.sync/arrive? I understand that in barrier.arrive(a, b), a represents the number of threads required to arrive, and b is the barrier_ID. However, the number of producer and consumer threads is often different.

In FlashAttention3, I saw this example:
https://github.com/Dao-AILab/flash-attention/blob/0dfb28174333d9eefb7c1dd4292690a8458d1e89/hopper/mainloop_fwd_sm90_tma_gmma_ws.hpp#L651

Here, the a parameter includes the consumer thread count (256) plus the active threads in the producer (32). However, I don't understand why it is written this way.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the CUTLASS barrier.sync/arrive semantics and the referenced mainloop_fwd_sm90_tma_gmma_ws.hpp example at line 651. Trace how the producer and consumer participation counts are determined, then document why the barrier uses 256 plus 32 and how differing thread counts should synchronize.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
hpc
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.