vllm.models.qwen4_exp.amd.ops.qsa_prepare
¶
Fused QSA prepare kernel for the AMD Qwen4Exp path.
Started as a copy of the NVIDIA kernel (nvidia/ops/qsa_prepare.py) and is
kept separate so either vendor can change its own copy without re-validating
the other. The state source select is two masked loads rather than a pointer
select, which ROCm Triton rejects.
Functions:
-
qsa_prepare–Normalize Q, compress K, then update the circular raw state.
-
supports_fused_pre_indexer–Report whether this indexer's shapes match the fused kernel's assumptions.
_norm_rope(x, pos_t, pos_h, pos_w, cos_sin_ptr, cos_sin_stride, norm_weight_ptr, eps, IS_MROPE, MROPE_H, MROPE_W)
¶
Apply Gemma RMSNorm and selected-axis NeoX RoPE to register rows.
Source code in vllm/models/qwen4_exp/amd/ops/qsa_prepare.py
_store_rotated(dst, y, o1, o2, scale)
¶
Store a normalized head whose first 2 * len(o1) dims are rotated.
Source code in vllm/models/qwen4_exp/amd/ops/qsa_prepare.py
_to_dst_dtype(x, dst, scale)
¶
Round to BF16 like the unfused path, then scale for an FP8 destination.
Source code in vllm/models/qwen4_exp/amd/ops/qsa_prepare.py
qsa_prepare(q, k, positions, cos_sin_cache, q_norm_weight, k_norm_weight, eps, q_out, state_cache, state_slots, state_block_table, query_start_loc, logical_positions, compressed_cache, compressed_slots, k_work_metadata, *, compress_ratio, mrope_section, rope_pos_offset, main_qkv, main_q_norm_weight, main_k_norm_weight, main_eps, main_kv_cache, main_slot_mapping, main_k_scale, main_v_scale, main_gate_out=None)
¶
Normalize Q, compress K, then update the circular raw state.
Also prepares the main attention (QK-norm/RoPE, gate copy, K/V cache write)
and returns its Q and gate. main_gate_out lets the gate land in a
caller-owned buffer, e.g. one that outlives an opaque custom op.
Source code in vllm/models/qwen4_exp/amd/ops/qsa_prepare.py
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 662 663 664 665 666 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 | |
supports_fused_pre_indexer(rotary_emb, head_dim, num_kv_heads, compress_ratio)
¶
Report whether this indexer's shapes match the fused kernel's assumptions.
The kernel hard-codes the rotary layout and the single-KV-head group compression it was written for; everything it rejects has a working unfused path.