vllm.compilation.passes.fusion.rocm_aiter_fusion
¶
Classes:
-
AddAiterRMSNormPadPattern–This pattern replaces an aiter_rmsnorm_with_add & a pad op
-
AiterFusedAddRMSFp8GroupQuantPattern–This pattern fuses aiter rms_norm_with_add & group fp8 quant custom ops
-
AiterFusedAddRMSNormDynamicQuantPattern–AITER RMSNorm Fused Add + Dynamic Quantization pattern.
-
AiterFusedAddRMSNormStaticQuantPattern–This pattern fuses fused_add_rms_norm & aiter static per-tensor fp8
-
AiterRMSFp8GroupQuantPattern–This pattern fuses aiter rms_norm & group fp8 quant custom
-
AiterRMSNormDynamicQuantPattern–AITER RMSNorm + Dynamic Quantization pattern.
-
AiterRMSNormGatedFp8GroupQuantPattern–Matches decomposed RMSNormGated + reshape + group FP8 quant and replaces
-
AiterRMSNormStaticQuantPattern–This pattern fuses rms_norm & aiter static per-tensor fp8 quant
-
AiterSiluMulFp8GroupQuantPattern–This pattern fuses aiter silu_and_mul & group fp8 quant custom
-
DoubleAiterRMSFp8GroupQuantPattern–Pattern matching
rms_normwhose output feeds two distinct -
DoubleAiterRMSFp8GroupQuantViewPattern–View-tolerant variant of
DoubleAiterRMSFp8GroupQuantPattern. -
MLADualRMSGroupQuantPattern–Fuse the MLA FP8 block-scale attention path -- q-latent RMSNorm + FP8
-
MLADualRMSNormFusionPass–Post-grad PatternMatcher pass that fuses paired q / kv RMS norms in
-
MLADualRMSNormPattern–Fuse paired q_a_layernorm + kv_a_layernorm in MLA attention into
-
MLADualRMSPerTokenQuantPattern–Fuse the MLA FP8 attention path -- q-latent RMSNorm + FP8 per-token quant
-
RocmAiterRMSNormQuantFusionPass–This pass fuses aiter rms_norm & vllm/aiter quant custom ops
-
RocmAiterSiluMulFp8GroupQuantFusionPass–This pass fuses a pre-defined set of custom ops into fused ops.
-
RocmAiterTritonAddRMSNormPadFusionPass–This pass replaces an AITER CK RMSNorm + residual add and a pad op
AddAiterRMSNormPadPattern
¶
This pattern replaces an aiter_rmsnorm_with_add & a pad op with a custom triton_add_rmsnorm_pad op from AITER.
Source code in vllm/compilation/passes/fusion/rocm_aiter_fusion.py
AiterFusedAddRMSFp8GroupQuantPattern
¶
Bases: AiterRMSNormQuantPattern
This pattern fuses aiter rms_norm_with_add & group fp8 quant custom ops into a aiter rms_norm_with_add_group_fp8_quant op.
Source code in vllm/compilation/passes/fusion/rocm_aiter_fusion.py
AiterFusedAddRMSNormDynamicQuantPattern
¶
Bases: AiterRMSNormQuantPattern
AITER RMSNorm Fused Add + Dynamic Quantization pattern.
Source code in vllm/compilation/passes/fusion/rocm_aiter_fusion.py
AiterFusedAddRMSNormStaticQuantPattern
¶
Bases: AiterRMSNormQuantPattern
This pattern fuses fused_add_rms_norm & aiter static per-tensor fp8 quant into an aiter fused_add_rms_fp8_per_tensor_static_quant op.
Source code in vllm/compilation/passes/fusion/rocm_aiter_fusion.py
AiterRMSFp8GroupQuantPattern
¶
Bases: AiterRMSNormQuantPattern
This pattern fuses aiter rms_norm & group fp8 quant custom ops into an aiter rms_norm_group_fp8_quant op.
Source code in vllm/compilation/passes/fusion/rocm_aiter_fusion.py
AiterRMSNormDynamicQuantPattern
¶
Bases: AiterRMSNormQuantPattern
AITER RMSNorm + Dynamic Quantization pattern.
Source code in vllm/compilation/passes/fusion/rocm_aiter_fusion.py
AiterRMSNormGatedFp8GroupQuantPattern
¶
Bases: AiterRMSNormQuantPattern
Matches decomposed RMSNormGated + reshape + group FP8 quant and replaces with rocm_aiter_fused_rms_gated_fp8_group_quant.
The norm operates per-head, on either (NH, D) or (N, H, D). The compiler folds the reshape chain so after norm the result goes through reshape->merge->quant. The pattern reshapes to (N, HD) before calling MatcherQuantFP8 so that _quantize_group_native sees the full hidden dim and computes the correct num_groups.
Source code in vllm/compilation/passes/fusion/rocm_aiter_fusion.py
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 | |
AiterRMSNormStaticQuantPattern
¶
Bases: AiterRMSNormQuantPattern
This pattern fuses rms_norm & aiter static per-tensor fp8 quant into an aiter fused_rms_fp8_per_tensor_static_quant op.
Source code in vllm/compilation/passes/fusion/rocm_aiter_fusion.py
AiterSiluMulFp8GroupQuantPattern
¶
Bases: VllmPatternReplacement
This pattern fuses aiter silu_and_mul & group fp8 quant custom ops into an aiter silu_and_mul_group_fp8_quant op.
Source code in vllm/compilation/passes/fusion/rocm_aiter_fusion.py
DoubleAiterRMSFp8GroupQuantPattern
¶
Bases: AiterRMSNormQuantPattern
Pattern matching rms_norm whose output feeds two distinct
rocm_aiter_group_fp8_quant consumers, replacing it with two
independent fused rms_norm_group_fp8_quant ops.
Repeating the rms_norm in the replacement is preferable to leaving the fused 16-bit rms output materialized for two unfused quant consumers, and matches what the previous manual graph surgery achieved by cloning the rms_norm node.
Source code in vllm/compilation/passes/fusion/rocm_aiter_fusion.py
DoubleAiterRMSFp8GroupQuantViewPattern
¶
Bases: AiterRMSNormQuantPattern
View-tolerant variant of DoubleAiterRMSFp8GroupQuantPattern.
Matches the same 1-to-2 fan-out, but with a view/reshape between
the rms_norm output and the two rocm_aiter_group_fp8_quant
consumers::
rms_norm -> view -> rocm_aiter_group_fp8_quant
\-> view -> rocm_aiter_group_fp8_quant
This shape arises in DeepSeek-V3.2's MLA indexer q_c norm, where the
FP8 linear path's 2D-flatten boilerplate
(Fp8BlockScaledMMLinearKernel.apply_weights) inserts a view between
the rms_norm output and each FP8 group quant op. The non-view sibling
pattern silently no-ops on this graph because the pattern matcher
requires the in-graph and in-pattern node shapes to align.
The trace_fn runs Inductor's view_to_reshape post-grad pass to
normalize view to reshape in both the pattern and the input
graph, widening the match without touching the no-view sibling.
Source code in vllm/compilation/passes/fusion/rocm_aiter_fusion.py
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 | |
MLADualRMSGroupQuantPattern
¶
Bases: VllmPatternReplacement[..., tuple[Tensor, Tensor, Tensor, Tensor]]
Fuse the MLA FP8 block-scale attention path -- q-latent RMSNorm + FP8
group quant plus kv-latent RMSNorm -- into AITER's
fused_qk_rmsnorm_group_quant.
With a block-scale FP8 q_b_proj (DeepSeek fp8), the earlier
RocmAiterRMSNormQuantFusionPass folds the q side into
rocm_aiter_rmsnorm_fp8_group_quant (the Triton rms+group-quant kernel)
and leaves the kv side a plain vllm_ir.rms_norm. This pattern matches
that asymmetric pair::
gemm -> split_with_sizes([q_dim, kv_dim])
+-- q_c -> rocm_aiter_rmsnorm_fp8_group_quant -> (q_fp8, q_scale)
+-- kv_lora -> split_with_sizes([kv_c_dim, k_pe_dim])
+-- kv_c -> vllm_ir.rms_norm -> kv_normed (bf16)
+-- k_pe
Source code in vllm/compilation/passes/fusion/rocm_aiter_fusion.py
1222 1223 1224 1225 1226 1227 1228 1229 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 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 | |
MLADualRMSNormFusionPass
¶
Bases: VllmFusionPatternMatcherPass
Post-grad PatternMatcher pass that fuses paired q / kv RMS norms in
MLA attention into fused_mla_dual_rms_norm backed by aiter's
fused_qk_rmsnorm HIP kernel.
The FP8 attention path is also handled via
:class:MLADualRMSPerTokenQuantPattern or :class:MLADualRMSGroupQuantPattern,
which fuse the q-latent RMSNorm + FP8 per-token/group quant together with
the kv-latent RMSNorm into fused_mla_dual_rms_norm_<per_token|group>_quant
backed by aiter's fused_qk_rmsnorm_<per_token|group>_quant HIP kernel.
Source code in vllm/compilation/passes/fusion/rocm_aiter_fusion.py
MLADualRMSNormPattern
¶
Bases: VllmPatternReplacement[..., tuple[Tensor, Tensor, Tensor]]
Fuse paired q_a_layernorm + kv_a_layernorm in MLA attention into
AITER's fused_qk_rmsnorm HIP kernel.
Target FX-graph pattern (unfused, vllm_ir stage)::
gemm -> split_with_sizes([q_dim, kv_dim])
+-- q_c -> vllm_ir.rms_norm(q_c, q_w, eps)
+-- kv_lora -> split_with_sizes([kv_c_dim, k_pe_dim])
+-- kv_c -> vllm_ir.rms_norm(kv_c, kv_w, eps)
+-- k_pe
The pattern covers the connected subgraph rooted at the first
split_with_sizes (which produces q_c and kv_lora),
through the two rms_norm calls, and the k_pe passthrough.
Source code in vllm/compilation/passes/fusion/rocm_aiter_fusion.py
1012 1013 1014 1015 1016 1017 1018 1019 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 | |
MLADualRMSPerTokenQuantPattern
¶
Bases: VllmPatternReplacement[..., tuple[Tensor, Tensor, Tensor, Tensor]]
Fuse the MLA FP8 attention path -- q-latent RMSNorm + FP8 per-token quant
plus kv-latent RMSNorm -- into AITER's fused_qk_rmsnorm_per_token_quant.
With a per-token FP8 q_b_proj (Quark / ModelOpt), the earlier
RocmAiterRMSNormQuantFusionPass folds the q side into
rocm_aiter_rmsnorm_fused_dynamic_quant and leaves the kv side a plain
vllm_ir.rms_norm. This pattern matches that asymmetric pair::
gemm -> split_with_sizes([q_dim, kv_dim])
+-- q_c -> rocm_aiter_rmsnorm_fused_dynamic_quant -> (q_fp8, q_scale)
+-- kv_lora -> split_with_sizes([kv_c_dim, k_pe_dim])
+-- kv_c -> vllm_ir.rms_norm -> kv_normed (bf16)
+-- k_pe
Source code in vllm/compilation/passes/fusion/rocm_aiter_fusion.py
1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 | |
RocmAiterRMSNormQuantFusionPass
¶
Bases: VllmPatternMatcherPass
This pass fuses aiter rms_norm & vllm/aiter quant custom ops into a fused rms_norm_quant op. It also supports fused_add_rms_norm.
Source code in vllm/compilation/passes/fusion/rocm_aiter_fusion.py
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 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 | |
RocmAiterSiluMulFp8GroupQuantFusionPass
¶
Bases: VllmFusionPatternMatcherPass
This pass fuses a pre-defined set of custom ops into fused ops. It uses the torch pattern matcher to find the patterns and replace them.
Because patterns can only be registered once, the pass is a singleton. This will be addressed in a future version of PyTorch: https://github.com/pytorch/pytorch/pull/139321#issuecomment-2452354980
Source code in vllm/compilation/passes/fusion/rocm_aiter_fusion.py
RocmAiterTritonAddRMSNormPadFusionPass
¶
Bases: VllmPatternMatcherPass
This pass replaces an AITER CK RMSNorm + residual add and a pad op with an triton_add_rmsnorm_pad op from AITER.