Commit 0db3e88
committed
fix(path_c bwd): dseg block — T.Parallel(L*L) instead of lane-strided T.serial (CUDA scope bug)
The B2 cuda prim FAILED to compile on gb10 sm_121: 'cb_v' undefined (line 134)
+ 'dseg' undefined (line 139). Root cause: the dseg segsum-VJP loop used the
lane-strided 'for ls0 in T.serial(0, L*L, threads)' idiom with a masked
'if lsi<L*L: if ll>ss:' body that (a) reads cb from global and (b) atomic_adds
into SHARED dAcs_acc. TileLang's shared-mem barrier-insertion pass put
__syncthreads() between the cb load, the dseg compute, and the atomic scatter,
re-emitting the if-guard around each fragment WITHOUT hoisting the local
declarations — so cb_v (declared in fragment 1) and dseg (declared in fragment 2)
were out of scope at their uses in later fragments.
Fix: map the L*L (ll,ss) grid over T.Parallel(L*L) — the SAME un-fragmented
thread-parallel idiom the dC apply block (which also atomic_adds into dAcs_acc)
and the DYX build already use and which compiled cleanly. dseg lands in a
thread-local; the +/- scatter keeps the ll>ss mask (dseg=0 off the strict
lower-tri -> no-op atomic adds). Math IDENTICAL to the Metal prim / the prior
lane-strided form. Metal prim untouched. RULE #1: still the ONE CUDA path.1 parent 7995ea6 commit 0db3e88
1 file changed
Lines changed: 21 additions & 20 deletions
Lines changed: 21 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
661 | 661 | | |
662 | 662 | | |
663 | 663 | | |
664 | | - | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | | - | |
673 | | - | |
674 | | - | |
675 | | - | |
676 | | - | |
677 | | - | |
678 | | - | |
679 | | - | |
680 | | - | |
681 | | - | |
682 | | - | |
683 | | - | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
684 | 685 | | |
685 | 686 | | |
686 | 687 | | |
| |||
0 commit comments