vllm.model_executor.kernels.mhc.tilelang_kernels
¶
Functions:
-
hc_head_fuse_tilelang–Two-pass fused kernel for hc_head.
-
mhc_fused_post_pre_split_config–Pick
(tile_n, n_splits, n_thr)for the fused post + pre-norm GEMM. -
mhc_fused_post_pre_splits–Every split-k factor the fused post + pre-norm GEMM path can pick.
-
mhc_fused_tilelang–Fused mhc post-mapping + pre-norm GEMM FMA.
-
mhc_pre_big_fuse_tilelang–Fuse coefficient generation and residual collapse after the projection.
-
require_fused_post_pre_config–The config for a shape the caller has already committed to fusing.
hc_head_fuse_tilelang(residual, fn, hc_scale, hc_base, out, hidden_size, rms_eps, hc_eps, hc_mult=4, n_thr=128, h_blk=1024)
¶
Two-pass fused kernel for hc_head.
accumulate per-token squared sum and hc_mult dot-products
(projections onto fn rows) using cross-thread reducers.
Pass 2: apply sigmoid-gated weighted sum of residual channels to output.
Avoids materialising mixes / rsqrt / pre tensors to global memory.
Source code in vllm/model_executor/kernels/mhc/tilelang_kernels.py
1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 | |
mhc_fused_post_pre_split_config(num_tokens, hidden_size, hc_mult)
¶
Pick (tile_n, n_splits, n_thr) for the fused post + pre-norm GEMM.
Returns None when a separate post kernel followed by a split-k GEMM is the better choice, or when the hidden size does not divide evenly across the fused kernel's block. One source of truth for the dispatch decision, the compile key and the launch, which must agree.
Source code in vllm/model_executor/kernels/mhc/tilelang_kernels.py
mhc_fused_post_pre_splits(hidden_size, hc_mult)
¶
Every split-k factor the fused post + pre-norm GEMM path can pick.
Source code in vllm/model_executor/kernels/mhc/tilelang_kernels.py
mhc_fused_tilelang(comb_mix, residual_in, post_mix, x_in, weight_t, yp_out, rp_out, residual_out, hc, hidden, n_out, n_thr=256, h_blk=256, tile_n=1, split_k=1)
¶
Fused mhc post-mapping + pre-norm GEMM FMA.
Source code in vllm/model_executor/kernels/mhc/tilelang_kernels.py
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 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 | |
mhc_pre_big_fuse_tilelang(gemm_out_mul, gemm_out_sqrsum, hc_scale, hc_base, residual, post_mix, comb_mix, layer_input, pre_mix_in, pre_mix_out, aux_out, hidden_size, rms_eps, hc_pre_eps, hc_sinkhorn_eps, hc_post_mult_value, sinkhorn_repeat, n_splits=16, hc_mult=4, use_pre_mix_in=False, save_pre_mix=False, rms_numel=0, write_aux=False)
¶
Fuse coefficient generation and residual collapse after the projection.
With save_pre_mix, store the new pre-mix and collapse with pre_mix_in, or select stream zero when use_pre_mix_in is false.
Source code in vllm/model_executor/kernels/mhc/tilelang_kernels.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | |
require_fused_post_pre_config(num_tokens, hidden_size, hc_mult)
¶
The config for a shape the caller has already committed to fusing.