Intra-warp Out-of-Order Scheduling Behavior on Hopper & Blackwell

Hello everyone,

I am investigating whether modern NVIDIA GPUs implement warp‑level out‑of‑order instruction scheduling, focusing on Hopper (SM90) and Blackwell (SM100).

The core instruction flow within each loop iteration is:
memcpy_async(TMA_issue) → barrier.wait → lds(in‑flight, load TMA‑fetched shared‑memory data to per‑thread registers) → add(depends on full lds completion) → syncthreads → next‑loop TMA

For the purpose of validating this hardware question, the kernel explicitly loads all shared‑memory data into per‑thread registers first, then performs add arithmetic using those register values. All content inside shared memory is transferred from global memory by prior TMA memcpy_async operations. If any add instruction gets issued, it implies all preceding lds have completed and all data is already present in registers.

Critical note: The subsequent TMA writes into the same shared‑memory slot whose content is currently being read by outstanding lds. If this TMA instruction gets issued, its underlying async‑proxy TMA will overwrite the shared‑memory contents that in‑flight lds is consuming.

Core question:
When lds is still in‑flight (not completed, data not yet in registers), its dependent add is held back and has not been issued yet. The following TMA memcpy_async has no register data dependency on lds / add. Can the warp scheduler inside a single warp skip this un‑issued dependency‑blocked add, and directly issue this later independent TMA UBLKCP.S.G instruction?

Below is pseudocode and the inner‑loop instruction sequence of my kernel.
Grid_Dim=1
Block_DIm=32

// phase‑1 (kernel prologue)
thread0: memcpy_async(TMA, global→shared slot0, bar[0]) // shared memory populated by TMA transfer
// main‑loop stage = 1 ~ 7
for stage in [1,2,3,4,5,6,7]:
    prev_slot = (stage‑1) & 1
    cur_slot  = stage & 1
    thread0: memcpy_async(TMA, global→shared cur_slot, bar[cur_slot]) // TMA fills cur_slot with global data
    barrier.arrive(prev_slot)
    barrier.wait(prev_slot)        // Wait for async‑proxy TMA write completion on prev_slot
    // all threads execute
    // Load EVERY element from shared‑memory slot (data brought by earlier TMA) into private per‑thread registers
    lds  sm_slot[prev_slot] → reg_vec[i]
  
    // add only executes after ALL lds finish and populate reg_vec
    add  partial_sum, reg_vec[i]
 
    __syncthreads()                // CTA synchronization barrier
    //fence_proxy_async(shared)
    // Next‑iteration TMA will overwrite prev_slot shared memory (originally filled by TMA), no register dependency on lds/add
end‑for

// drain phase for stage=7, data resides in last_slot
...

SASS:

	Function : _Z11test_kernelPjS_jjj
.headerflags	@"EF_CUDA_ACCELERATORS EF_CUDA_SM100 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM100)"
        // ...
        // init: barrier init + init fence, then first __syncthreads
        /*0370*/                   BAR.SYNC.DEFER_BLOCKING 0x0 ;                         /* 0x0000000000007b1d */
                                                                                         /* 0x004fea0000010000 */
        // ...

        // tma load: phase-1 prefetch stage0 -> slot0 (issued by pseudo-random issuer thread)
        /*0460*/                   UBLKCP.S.G [UR8], [UR4], UR10 ;                       /* 0x00000008040073ba */
                                                                                         /* 0x0001d8000800020a */
        // mbarrier expect: arrive bar[0] so the TMA completion flips the phase
        /*04b0*/                   SYNCS.ARRIVE.TRANS64.RED.A0TR RZ, [UR9], R2 ;         /* 0x00000002ffff79a7 */
                                                                                         /* 0x0001e60008300409 */
        // begin loop
        /*05f0*/                   BSSY.RECONVERGENT B0, 0x7c0 ;                         /* 0x000001c000007945 */
                                                                                         /* 0x000fe60003800200 */

        // ... (loop prologue: slot base / per-thread slice address)

        // tma load ping-pong: prefetch next stage into cur_slot (issuer thread only)
        /*0750*/                   UBLKCP.S.G [UR10], [UR4], UR16 ;                      /* 0x0000000a040073ba */
                                                                                         /* 0x0001d80008000210 */

        // mbarrier expect: arrive bar[cur_slot] for the in-flight TMA
        /*07a0*/                   SYNCS.ARRIVE.TRANS64.RED.A0TR RZ, [UR11], R68 ;       /* 0x00000044ffff79a7 */
                                                                                         /* 0x0001e6000830040b */

        // arrive prev_slot (token) + start timer, then wait: prev_slot TMA write is done
        /*0800*/                   SYNCS.ARRIVE.TRANS64.A1T0 R80, [UR5], RZ ;            /* 0x000000ffff5079a7 */
                                                                                         /* 0x000e620008100005 */
        /*0810*/                   CS2R R68, SR_GLOBALTIMERLO ;                          /* 0x0000000000447805 */
                                                                                         /* 0x001fe20000015200 */
        // mbarrier wait
        /*0820*/                   SYNCS.PHASECHK.TRANS64.TRYWAIT P0, [UR5], R81 ;       /* 0x00000051ff0075a7 */
                                                                                         /* 0x002e240008001105 */
        // ... (spin-wait until phase complete)

        // LDS: consume the ping-pong slot into registers
        /*0a80*/              @!P2 LDS.128 R4, [R68] ;                                   /* 0x000000004404a984 */
                                                                                         /* 0x0000680000000c00 */
        /*0a90*/              @!P2 LDS.128 R8, [R68+0x10] ;                              /* 0x000010004408a984 */
                                                                                         /* 0x0000a20000000c00 */
        // ...    LDS

        // add: accumulate the loaded vectors
        /*0cc0*/              @!P2 IADD3 R68, PT, PT, R5, R4, R2 ;                       /* 0x000000040544a210 */
                                                                                         /* 0x00bfc80007ffe002 */
        /*0cd0*/              @!P2 IADD3 R68, PT, PT, R7, R68, R6 ;                      /* 0x000000440744a210 */
                                                                                         /* 0x000fc80007ffe006 */
        // ...  IADD3

        // proxy fence (loop fence): order async-proxy TMA writes before __syncthreads
        // WITHOUT this the next TMA could overwrite the slot still being consumed (WAR)
        /*0fd0*/                   MEMBAR.ALL.CTA ;                                      /* 0x0000000000007992 */
                                                                                         /* 0x0001ec0000008000 */
        /*0fe0*/                   FENCE.VIEW.ASYNC.S ;                                  /* 0x00000000000073c6 */
                                                                                         /* 0x001e220000000000 */

        // __syncthreads: barrier before next TMA may overwrite this slot (WAR guard)
        /*1010*/                   BAR.SYNC.DEFER_BLOCKING 0x0 ;                         /* 0x0000000000007b1d */
                                                                                         /* 0x001ff00000010000 */

        // loop back
        /*1020*/                   BRA.U UP0, 0x5d0 ;                                    /* 0xfffffff500687547 */

Background

If the warp scheduler supports out‑of‑order issue within a warp, fence_proxy_async would be required for correctness. Conversely, strict in‑order issue would make this fence unnecessary.

I removed the fence_proxy_async from the code referenced in the PR ( Fix race condition in RHT amax kernels by ksivaman · Pull Request #2695 · NVIDIA/TransformerEngine)and ran tests on H100 and B200. No shared‑memory corruption caused by subsequent TMA overwriting in‑flight lds read data was observed.

Thank you very much.

  1. You can see the warp instructions being executed (= the computation system) and the memory system (including caches) providing the data as two different parts in the GPU.
    The memory system also needs hints and sync instructions to correctly handle cached and in-flight transactions even if the warps execute their instructions strictly in-order.

  2. In addition most memory instructions are asynchronous. Warps only block, if the registers receiving a memory read is used (e.g. for the partial sum). Warps write-back, when writing to memory, the write transaction is on the way and the warp continues execution.

I have not gone through your concrete example, but just quickly tried to answer your key argument about in-order warp scheduling.

Thanks a lot for your insightful explanation!
My original question description was imprecise, so I have revised it to narrow down the scope.
Right now I am specifically asking about warp‑level instruction issue behavior:
Given the SASS program order: multiple lds → dependent add → subsequent independent TMA memcpy_async.
When those lds are still in‑flight and their dependent add is held back from issue due to register dependency, can the warp scheduler skip this un‑issued add and issue the later register‑independent TMA within the same warp?

My practical test on H100/B200 by removing fence_proxy_async did not reproduce the shared‑memory overwrite corruption described in PR‑2695, and I am trying to figure out whether this observation comes from in‑order instruction‑issue constraints inside the warp.

Appreciate your time for this.

Could the compiler reorder the cp.async.bulk instruction that comes after __syncthreads() to before it during compilation?

No, it can’t. If you’re concerned about a single, converged warp then the instruction sequence

LDS (set write scoreboard SBx)
FADD (wait for scoreboard SBx)
UBLKCP

will issue the UBLKCP strictly after the LDS has completed, and of course the later UBLKCP can no longer influence the earlier completed reads.

Where it gets tricky is divergent control flow and multiple warps, though a __syncthreads()/BAR.SYNC before the async copy will take care of that.
(A slight caveat here is that __syncthreads() often translates to BAR.SYNC.DEFER_BLOCKING, however I believe UBLKCP is among the instructions that trigger the deferred wait.)

So afaict fence_proxy_async is not strictly necessary here.

Even in the case of plain

LDS
UBLKCP

it is very unlikely that the latency of LDS returning data to registers (typically in the 25-60 cycles range, but could be a lot worse if you have lots of queued shared memory accesses with 32-way bank conflicts…) is higher than the latency of UBLKCP writing its first byte to shared memory, as the latter needs to access L2 cache with hundreds of cycles of latency.

Below is SASS Code:

Function : _Z11test_kernelPjS_jjj
.headerflags	@"EF_CUDA_ACCELERATORS EF_CUDA_SM100 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM100)"
        // ...
        // init: barrier init + init fence, then first __syncthreads
        /*0370*/                   BAR.SYNC.DEFER_BLOCKING 0x0 ;                         /* 0x0000000000007b1d */
                                                                                         /* 0x004fea0000010000 */
        // ...

        // tma load: phase-1 prefetch stage0 -> slot0 (issued by pseudo-random issuer thread)
        /*0460*/                   UBLKCP.S.G [UR8], [UR4], UR10 ;                       /* 0x00000008040073ba */
                                                                                         /* 0x0001d8000800020a */
        // mbarrier expect: arrive bar[0] so the TMA completion flips the phase
        /*04b0*/                   SYNCS.ARRIVE.TRANS64.RED.A0TR RZ, [UR9], R2 ;         /* 0x00000002ffff79a7 */
                                                                                         /* 0x0001e60008300409 */
        // begin loop
        /*05f0*/                   BSSY.RECONVERGENT B0, 0x7c0 ;                         /* 0x000001c000007945 */
                                                                                         /* 0x000fe60003800200 */

        // ... (loop prologue: slot base / per-thread slice address)

        // tma load ping-pong: prefetch next stage into cur_slot (issuer thread only)
        /*0750*/                   UBLKCP.S.G [UR10], [UR4], UR16 ;                      /* 0x0000000a040073ba */
                                                                                         /* 0x0001d80008000210 */

        // mbarrier expect: arrive bar[cur_slot] for the in-flight TMA
        /*07a0*/                   SYNCS.ARRIVE.TRANS64.RED.A0TR RZ, [UR11], R68 ;       /* 0x00000044ffff79a7 */
                                                                                         /* 0x0001e6000830040b */

        // arrive prev_slot (token) + start timer, then wait: prev_slot TMA write is done
        /*0800*/                   SYNCS.ARRIVE.TRANS64.A1T0 R80, [UR5], RZ ;            /* 0x000000ffff5079a7 */
                                                                                         /* 0x000e620008100005 */
        /*0810*/                   CS2R R68, SR_GLOBALTIMERLO ;                          /* 0x0000000000447805 */
                                                                                         /* 0x001fe20000015200 */
        // mbarrier wait
        /*0820*/                   SYNCS.PHASECHK.TRANS64.TRYWAIT P0, [UR5], R81 ;       /* 0x00000051ff0075a7 */
                                                                                         /* 0x002e240008001105 */
        // ... (spin-wait until phase complete)

        // LDS: consume the ping-pong slot into registers
        /*0a80*/              @!P2 LDS.128 R4, [R68] ;                                   /* 0x000000004404a984 */
                                                                                         /* 0x0000680000000c00 */
        /*0a90*/              @!P2 LDS.128 R8, [R68+0x10] ;                              /* 0x000010004408a984 */
                                                                                         /* 0x0000a20000000c00 */
        // ...    LDS

        // add: accumulate the loaded vectors
        /*0cc0*/              @!P2 IADD3 R68, PT, PT, R5, R4, R2 ;                       /* 0x000000040544a210 */
                                                                                         /* 0x00bfc80007ffe002 */
        /*0cd0*/              @!P2 IADD3 R68, PT, PT, R7, R68, R6 ;                      /* 0x000000440744a210 */
                                                                                         /* 0x000fc80007ffe006 */
        // ...  IADD3

        // proxy fence (loop fence): order async-proxy TMA writes before __syncthreads
        // WITHOUT this the next TMA could overwrite the slot still being consumed (WAR)
        /*0fd0*/                   MEMBAR.ALL.CTA ;                                      /* 0x0000000000007992 */
                                                                                         /* 0x0001ec0000008000 */
        /*0fe0*/                   FENCE.VIEW.ASYNC.S ;                                  /* 0x00000000000073c6 */
                                                                                         /* 0x001e220000000000 */

        // __syncthreads: barrier before next TMA may overwrite this slot (WAR guard)
        /*1010*/                   BAR.SYNC.DEFER_BLOCKING 0x0 ;                         /* 0x0000000000007b1d */
                                                                                         /* 0x001ff00000010000 */

        // loop back
        /*1020*/                   BRA.U UP0, 0x5d0 ;                                    /* 0xfffffff500687547 */

Thank you for your thoughtful analysis. I would like to comment specifically on this latency‑based reasoning:

it is very unlikely that the latency of LDS returning data to registers (typically in the 25‑60 cycles range, but could be a lot worse if you have lots of queued shared memory accesses with 32‑way bank conflicts…) is higher than the latency of UBLKCP writing its first byte to shared memory, as the latter needs to access L2 cache with hundreds of cycles of latency.

In my H100 (sm_90) micro‑benchmark I observe the opposite practical race condition, even without heavy bank‑conflict stress.
My converged‑warp loop SASS sequence is:

// pre‑loop: UBLKCP.S.G (initial TMA load to shared memory)
loop:
    SYNCS.PHASECHK.TRANS64.TRYWAIT
    LDS  // ld.shared consuming shared‑memory populated by prior UBLKCP
    BAR.SYNC.DEFER_BLOCKING //__syncthreads()
    UBLKCP.S.G  // new TMA, writes into the same shared‑memory buffer slot
    IADD3
    BRA.U  //loop

No fence.proxy_async is present. All warp lanes are converged, no branch divergence.

Crucially, this observed data‑race does NOT violate the strictly in‑order instruction‑issue rule within a single warp:

  • Instructions are issued to SM pipeline in program order: LDS issues first, then UBLKCP.S.G, then IADD3. Hardware does not reorder these SASS instructions at issue time.

One remaining open concern:
all reasoning above assumes strictly in‑order intra‑warp hardware instruction issue.
Academic papers GhOST and SoCGPU propose intra‑warp instruction‑level out‑of‑order scheduling to improve ILP. While those are research concepts, given the ILP pressure for Hopper and Blackwell architectures, I remain cautious whether limited intra‑warp OoO issue could exist in current or future silicon. If intra‑warp hardware reordering existed, it would further enlarge this hazard window.

When profiling this with NCU, does the UBLKCP line show barrier stalls? I wonder if BAR.SYNC.DEFER_BLOCKING isn’t enough.