Repository navigation
[None][fix] Acquire at cluster scope on three DSMEM mailbox waits (router GEMM, Qwen4 hc decode, MuseSpark boundary) #22717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ | |
| from cutlass._mlir.dialects import llvm | ||
| from cutlass.cute.runtime import make_ptr | ||
| from cutlass.cutlass_dsl import T, dsl_user_op | ||
| from cutlass.experimental import primitives as prims | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With this import, the module needs a CuTe DSL release that has |
||
| except ImportError: | ||
| _HAS_CUTE_DSL = False | ||
| else: | ||
|
|
@@ -58,6 +59,23 @@ def _float_bits(value, *, loc=None, ip=None): | |
| ) | ||
| return Int32(bits) | ||
|
|
||
| @cute.jit | ||
| def _mbar_wait_cluster_acquire(mbar_ptr: cute.Pointer, phase: Int32): | ||
| """Wait for ``phase`` of this CTA's mbarrier at ``mbar_ptr``, acquiring at cluster scope. | ||
|
|
||
| ``cute.arch.mbarrier_wait`` acquires at CTA scope. The peers' ``st.async ... | ||
| mbarrier::complete_tx`` (``store_async_dsmem``) that completes this barrier releases at | ||
| cluster scope, and only a cluster-scope acquire orders their payload before the reads that | ||
| follow the wait: a relaxed cluster-scope try_wait loop and an acquire fence restricted to | ||
| shared::cluster (the ISA's acquire pattern for it; unlike ``.acquire.cluster`` on the wait | ||
| it adds no L1 invalidate). | ||
| """ | ||
| while not prims.mbarrier_try_wait_parity( | ||
| mbar_ptr, phase, scope=prims.MBarrierScope.CLUSTER, order=prims.MemOrder.RELAXED | ||
| ): | ||
| pass | ||
| prims.fence_sync_restrict(prims.MemOrder.ACQUIRE) | ||
|
|
||
| class _ClusterBoundaryKernel: | ||
| def __init__( | ||
| self, | ||
|
|
@@ -123,7 +141,8 @@ def reduce( | |
| bars.iterator + phase, | ||
| lane, | ||
| ) | ||
| cute.arch.mbarrier_wait(bars.iterator + phase, 0) | ||
| # The peers' st.async complete-tx releases at cluster scope. | ||
| _mbar_wait_cluster_acquire(bars.iterator + phase, 0) | ||
| else: | ||
| if lane == 0: | ||
| partials[(phase * self.slots + warp) * 4] = value | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this helper is now duplicated in three files. A shared helper next to the other CuTe DSL utilities would keep the memory-ordering logic in one place and make it easy to reuse for the remaining sites listed in #21843.