Repository navigation
Commit d839939
Port gfx950 B3: early_stop (skip final radix pass, num_rows<=1)
Kernel (topk_per_row_decode_tiered.py):
- add early_stop param + _es kernel-name tag (cache separation)
- add early-stop write helpers (process_loaded_early_vec /
early_write_vec_block / early_write_all): take the boundary bucket whole
via prefix_for_key(key, prev_start_bit) <= kth_bits (HIP-mb
previous_bits <= kth_value_bits), same 4x-staged unroll as the normal
last-pass write
- persistent loop: when early_stop, run passes[0..n-2], and if the
boundary bucket is taken whole (local_len == local_k) skip the final
radix pass and write directly; else run it. The early flag is computed
from the merged histogram so it is identical across a row's blocks ->
the final row_barrier is entered/skipped by all blocks together (no
deadlock).
Dispatch (topk_per_row_decode.py):
- es_on = _env_int(FLYDSL_TOPK_TIERED_ES, 1 if gfx950 else 0)
- early_stop = bool(es_on) and num_rows <= 1 (gated: pays off only in the
single-sequence long tier; neutral/loss at rows>=2)
Verified gfx950: correctness 768/768 vs torch.topk (ES on/off x regime
A+B x rows{1,4,16,32} x L{8k,65k,120k,256k} x k{256..2048} x
random/ties/10LSBits, poison over-scan checked). Perf (rocprofv3 min):
rows=1 -14..17% (L120k k2048 29.76->25.68us), rows=4 (gated off) 0
regression.
Co-authored-by: Cursor <[email protected]>1 parent 6f7042a commit d839939
2 files changed
Lines changed: 98 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
| |||
220 | 221 | | |
221 | 222 | | |
222 | 223 | | |
| 224 | + | |
223 | 225 | | |
224 | 226 | | |
225 | 227 | | |
| |||
737 | 739 | | |
738 | 740 | | |
739 | 741 | | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
740 | 805 | | |
741 | 806 | | |
742 | 807 | | |
| |||
1160 | 1225 | | |
1161 | 1226 | | |
1162 | 1227 | | |
| 1228 | + | |
1163 | 1229 | | |
1164 | | - | |
1165 | | - | |
1166 | | - | |
1167 | | - | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
1168 | 1255 | | |
1169 | 1256 | | |
1170 | 1257 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
229 | 235 | | |
230 | 236 | | |
231 | 237 | | |
| |||
237 | 243 | | |
238 | 244 | | |
239 | 245 | | |
| 246 | + | |
240 | 247 | | |
241 | 248 | | |
242 | 249 | | |
| |||
0 commit comments