Commit 8922df9
authored
[TritonGPU] Add a separate pass for optimizing partition num warps (triton-lang#6323)
PartitionLoops no longer changes the number of warps of the partitions
-- they are always left at the default number. A separate pass runs
after the important DCE to analyze the IR and determine the number of
warps needed. As before, if there are no tensor computations in the
partition, the number of warps is set to 1.
However, the pass will now also look at tensor computations and shrink
the number of warps. It does this by doing a very rough estimate of the
register usage of the partition and comparing it against the pool of
available registers given the number of warps. If it can reduce the
number of warps, the algorithm iterates to fixed point. This is
important, e.g., for TMA gather or scatter ops that can still use tensor
ops, but generally small 1D tensors.
This still assumes uniform register allocation per warp. In the future,
we can make the pass much more sophisticated by allowing nonuniform
register allocation with setmaxnreg.
The PR implements a pretty major hack to relayout IR by wiping them out
and rerunning `convert-triton-to-tritongpu` which sadly breaks layering
of TTGIR vs TTIR.1 parent 708b5f1 commit 8922df9
File tree
17 files changed
+576
-96
lines changed- include/triton
- Conversion/TritonToTritonGPU
- Dialect/TritonGPU/Transforms
- lib
- Conversion
- TritonGPUToLLVM
- TritonToTritonGPU
- Dialect/TritonGPU/Transforms
- WarpSpecialization
- test
- Conversion
- TritonGPU
17 files changed
+576
-96
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
158 | 168 | | |
159 | 169 | | |
160 | 170 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
140 | 139 | | |
141 | 140 | | |
142 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | 15 | | |
Lines changed: 14 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | | - | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
58 | | - | |
59 | | - | |
60 | | - | |
| 60 | + | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
68 | | - | |
| 69 | + | |
69 | 70 | | |
70 | | - | |
71 | | - | |
72 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
78 | | - | |
79 | | - | |
| 80 | + | |
| 81 | + | |
80 | 82 | | |
81 | 83 | | |
82 | 84 | | |
| |||
98 | 100 | | |
99 | 101 | | |
100 | 102 | | |
101 | | - | |
| 103 | + | |
| 104 | + | |
102 | 105 | | |
103 | 106 | | |
104 | 107 | | |
| |||
Lines changed: 43 additions & 49 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
431 | 432 | | |
432 | 433 | | |
433 | 434 | | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
457 | 448 | | |
458 | | - | |
459 | | - | |
460 | | - | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
461 | 452 | | |
462 | 453 | | |
463 | | - | |
| 454 | + | |
464 | 455 | | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
478 | 466 | | |
479 | 467 | | |
480 | 468 | | |
| |||
619 | 607 | | |
620 | 608 | | |
621 | 609 | | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
626 | 617 | | |
627 | 618 | | |
628 | 619 | | |
| |||
840 | 831 | | |
841 | 832 | | |
842 | 833 | | |
843 | | - | |
| 834 | + | |
| 835 | + | |
844 | 836 | | |
845 | 837 | | |
846 | 838 | | |
847 | 839 | | |
| 840 | + | |
848 | 841 | | |
849 | 842 | | |
850 | 843 | | |
| |||
859 | 852 | | |
860 | 853 | | |
861 | 854 | | |
862 | | - | |
| 855 | + | |
863 | 856 | | |
864 | 857 | | |
865 | 858 | | |
| |||
898 | 891 | | |
899 | 892 | | |
900 | 893 | | |
901 | | - | |
902 | | - | |
903 | | - | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
904 | 898 | | |
905 | 899 | | |
906 | 900 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| 51 | + | |
50 | 52 | | |
51 | 53 | | |
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
54 | 59 | | |
0 commit comments