vllm.models.qwen4_exp.common.qsa_cache ¶
Paged side-cache ownership and metadata for Qwen4Exp QSA.
Each QSA layer keeps a fixed circular buffer of raw index keys (the compressor state) and one compressed key. MRoPE models pack exact three-axis positions beside the raw keys; text models derive group positions from logical positions. The compressor state uses one block per request, while the compressed owner uses MLAAttentionSpec.tokens_per_state so its block table follows the main KV-cache lifecycle. Their physical tensor storage is shared by the generic cache-layout planner.
Classes:
-
QSACompressedKeyCache–Normed, group-first-RoPE key at one row per complete group.
-
QSAForwardMetadata–Common per-forward metadata for one QSA side cache.
-
QSAKeyStateCache–Raw BF16 key, optionally followed by exact int64 MRoPE positions.
-
QSAMetadataBuilder–Build QSA metadata from vLLM's cache-group-specific common metadata.
-
QSAStateBackend–Key-only dummy backend for out-of-band QSA side-cache operations.
Functions:
-
canonical_qsa_rope_positions–Return exact per-token positions as
[tokens, 1, 3]int64 rows. -
circular_qsa_slot_mapping–Map each request to its fixed physical block as a circular token ring.
-
compressed_qsa_slot_mapping–Build boundary-only slots for an
MLAAttentionSpecQSA cache.
QSACompressedKeyCache ¶
Bases: _QSAStateCache
Normed, group-first-RoPE key at one row per complete group.
Source code in vllm/models/qwen4_exp/common/qsa_cache.py
QSAForwardMetadata dataclass ¶
Bases: AttentionMetadata
Common per-forward metadata for one QSA side cache.
Source code in vllm/models/qwen4_exp/common/qsa_cache.py
QSAKeyStateCache ¶
Bases: _QSAStateCache
Raw BF16 key, optionally followed by exact int64 MRoPE positions.
Source code in vllm/models/qwen4_exp/common/qsa_cache.py
QSAMetadataBuilder ¶
Bases: AttentionMetadataBuilder[QSAForwardMetadata]
Build QSA metadata from vLLM's cache-group-specific common metadata.
Source code in vllm/models/qwen4_exp/common/qsa_cache.py
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 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
QSAStateBackend ¶
Bases: AttentionBackend
Key-only dummy backend for out-of-band QSA side-cache operations.
Source code in vllm/models/qwen4_exp/common/qsa_cache.py
_QSAStateCache ¶
Bases: Module, AttentionLayerBase
Methods:
-
bind_kv_cache–Adapt the unified [B, H, N, C] view to QSA's [B, N, H, C].
Source code in vllm/models/qwen4_exp/common/qsa_cache.py
bind_kv_cache(kv_cache) ¶
Adapt the unified [B, H, N, C] view to QSA's [B, N, H, C].
Source code in vllm/models/qwen4_exp/common/qsa_cache.py
build_qsa_metadata_triton(common_attn_metadata, token_to_req_buffer, logical_positions_buffer, visible_blocks_buffer, slot_mapping_buffer, *, storage_block_size, compress_ratio, circular_buffer_size=0, k_work_metadata_buffer=None, request_capacity=None) ¶
Build QSA side-cache and optional pre-indexer work metadata.
Source code in vllm/models/qwen4_exp/common/qsa_cache.py
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 453 454 455 456 457 458 459 460 461 462 463 464 | |
canonical_qsa_rope_positions(positions) ¶
Return exact per-token positions as [tokens, 1, 3] int64 rows.
Source code in vllm/models/qwen4_exp/common/qsa_cache.py
circular_qsa_slot_mapping(block_table, token_to_req, logical_positions, compressor_state_size, query_start_loc=None, out=None) ¶
Map each request to its fixed physical block as a circular token ring.
Source code in vllm/models/qwen4_exp/common/qsa_cache.py
compressed_qsa_slot_mapping(block_table, token_to_req, logical_positions, storage_block_size, compress_ratio, out=None) ¶
Build boundary-only slots for an MLAAttentionSpec QSA cache.