Commit 9b2e58f
committed
[CK Tile] Fix FMHA LSE calculation and potential division by zero
This commit addresses numerical stability issues in the BlockFmhaPipelineQRKSVS pipeline when bias has -inf masking values:
1. Explicitly handle the case where the accumulated exponential sum (l) is zero. In this case, the LSE is now correctly set to negative infinity, preventing log(0) errors.
2. Extend the zero-check protection in the normalization step to cover the ELEMENTWISE_BIAS case, preventing potential division by zero.1 parent 004784e commit 9b2e58f
File tree
1 file changed
+21
-9
lines changed- include/ck_tile/ops/fmha/pipeline
1 file changed
+21
-9
lines changedLines changed: 21 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
655 | 655 | | |
656 | 656 | | |
657 | 657 | | |
658 | | - | |
659 | | - | |
660 | | - | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
661 | 661 | | |
662 | | - | |
| 662 | + | |
663 | 663 | | |
664 | 664 | | |
665 | 665 | | |
666 | | - | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
667 | 669 | | |
668 | 670 | | |
669 | 671 | | |
670 | 672 | | |
671 | 673 | | |
672 | | - | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
673 | 682 | | |
674 | | - | |
675 | 683 | | |
676 | | - | |
| 684 | + | |
677 | 685 | | |
| 686 | + | |
678 | 687 | | |
679 | 688 | | |
680 | 689 | | |
| |||
686 | 695 | | |
687 | 696 | | |
688 | 697 | | |
689 | | - | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
690 | 702 | | |
691 | 703 | | |
692 | 704 | | |
| |||
0 commit comments