Commit 7c6f38d
committed
perf(path_c bwd): precompute shared LMAT[L,L] — kill ~65K exp2 recomputes/threadgroup in dinp
MEASURED run #1 (gb10 sm_121, prod): B2 dropped 2484 -> 334.6 ms/call (7.4x),
chain 447.8 ms < 456.1 numpy, ALL 8 grads pass incl dD=2.48e-5 (was 1.40e-3).
GO secured. But B2's dinp block (the verbatim Y_diag transpose) recomputes
lmat=exp2((dacs[l]-dacs[s])*p) in its innermost (sp/32-wave x nn/64 x l-reduction)
nest ~= 65K exp2/threadgroup — now the dominant remaining serial term, plus
dC_diag and dseg each recompute the same exp2.
Optimization (CUDA prim ONLY; Metal prim byte-identical): build the lower-tri
decay LMAT[l,s]=exp2((dacs[l]-dacs[s])*p) (s<=l, else 0) ONCE over L*L threads
(4096 exp2) into a shared tile, then read it from shared in dC_diag (l.630),
dinp (l.666) and dseg (l.696). Drops exp2 count ~16x in dinp alone. +16KB shared
(LMAT) -> ~64.5KB total, within the sm_121 per-block budget. Math IDENTICAL
(LMAT carries the exact same value; all 3 consumers index only the lower-tri
region where it is defined). RULE #1: still the ONE CUDA path.1 parent 83d953e commit 7c6f38d
1 file changed
Lines changed: 19 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
511 | 511 | | |
512 | 512 | | |
513 | 513 | | |
| 514 | + | |
514 | 515 | | |
515 | 516 | | |
516 | 517 | | |
517 | 518 | | |
518 | 519 | | |
519 | 520 | | |
520 | 521 | | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
521 | 537 | | |
522 | 538 | | |
523 | 539 | | |
| |||
611 | 627 | | |
612 | 628 | | |
613 | 629 | | |
614 | | - | |
| 630 | + | |
615 | 631 | | |
616 | 632 | | |
617 | 633 | | |
| |||
647 | 663 | | |
648 | 664 | | |
649 | 665 | | |
650 | | - | |
| 666 | + | |
651 | 667 | | |
652 | 668 | | |
653 | 669 | | |
| |||
677 | 693 | | |
678 | 694 | | |
679 | 695 | | |
680 | | - | |
| 696 | + | |
681 | 697 | | |
682 | 698 | | |
683 | 699 | | |
| |||
0 commit comments