vllm.compilation.passes.fusion.rocm_aiter_fusion ¶
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
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 (NH, D) tensors. The compiler folds the reshape chain so after norm the result goes through reshape->merge->quant. The pattern reshapes from (NH, D) to (N, H*D) 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
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 | |
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
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 451 452 | |
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.
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
831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 | |
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
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 | |
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.