vllm.v1.hisparse.runtime
¶
HiSparse resident, host, and hot-cache data plane.
Classes:
-
HiSparseCacheHandle–Attention-facing handle for resident KV and sparse offload state.
-
HiSparseHostPool–Keep the single host backing and its exact registration range.
-
HiSparseIndexGroup–GPU index-resolution state shared by one leader and its followers.
-
HiSparsePrefillStagingPlan– -
HiSparseRuntime–Per-cache host/hot data plane and GPU replacement state.
-
HiSparseSlotInvalidator–Drop hot copies of rewritten host slots for many index groups at once.
Functions:
-
allocate_hisparse_host_pools–Allocate one host mmap shared by local TP ranks.
-
allocate_pinned_host_pool–Allocate and deterministically register an exact-size host KV region.
-
build_hisparse_prefill_staging_plan–Build an asynchronous layer-independent host-cache staging remap.
-
check_hisparse_host_memory–Reject a physical host-pool allocation that cannot fit in RAM.
-
get_hisparse_host_pool–Return the engine's host pool, which outlives the profiling KV cache.
-
hisparse_prefill_staging_remap–Renumber blocks without a data-dependent CUDA output allocation.
-
initialize_hisparse_runtime_buffers–Allocate the request state shared by every HiSparse runtime.
-
is_hisparse_group_prefetch_batch–Prefetch historical KV for a pure decode batch, including verification.
-
release_pinned_state–Synchronize and release registered host KV pools.
-
update_hisparse_residency–Apply scheduled requests' residency changes.
-
use_shared_hisparse_host_pool–Whether replicated MLA host KV can share one local mmap.
HiSparseCacheHandle
¶
Attention-facing handle for resident KV and sparse offload state.
Methods:
-
unbind_cache–Detach KV storage and per-binding metadata, retaining the index group.
Source code in vllm/v1/hisparse/runtime.py
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 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 | |
unbind_cache()
¶
HiSparseHostPool
¶
Keep the single host backing and its exact registration range.
Source code in vllm/v1/hisparse/runtime.py
HiSparseIndexGroup
¶
GPU index-resolution state shared by one leader and its followers.
Source code in vllm/v1/hisparse/runtime.py
HiSparsePrefillStagingPlan
dataclass
¶
Methods:
-
ensure_gpu_sources–Resolve which staged rows can be served from the resident cache.
Source code in vllm/v1/hisparse/runtime.py
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 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 | |
ensure_gpu_sources(resident_state_rows, state_indices, resident_block_size)
¶
Resolve which staged rows can be served from the resident cache.
resident_state_rows is a resident group's persistent table by
request state row and state_indices holds each staged request's
state row. Computed once per plan and resident group (every layer in
the group shares the table); non-null resident pages become
miss_mask=0 rows gathered device-to-device by gather_prefill_cache.
Source code in vllm/v1/hisparse/runtime.py
HiSparseRuntime
¶
Per-cache host/hot data plane and GPU replacement state.
Methods:
-
bind_hot_cache–Bind this runtime's strided view into the shared GPU HMA slab.
-
gather_prefill_cache–Gather this runtime's host cache using a shared staging plan.
-
invalidate_sorted_slots–Drop hot copies using shared, preprocessed invalidation inputs.
-
reset_hot_state–Drop all hot-buffer bookkeeping (hits become misses).
-
swap_in–Resolve once per group and ensure this layer's rows are available.
-
unbind_cache–Restore the unbound state without unregistering the host pool.
Source code in vllm/v1/hisparse/runtime.py
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 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 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 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 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 | |
_resolve_residency(*, resident=None, req_id_per_token, num_valid_rows, block_table, topk_indices, block_size, return_valid_counts=False, shared_rows, attention_indices_out=None, valid_counts_out=None)
¶
Resolve logical top-k positions and compact rows requiring swaps.
Source code in vllm/v1/hisparse/runtime.py
bind_hot_cache(raw_tensor, *, byte_offset, block_stride, num_blocks, block_size, block_table)
¶
Bind this runtime's strided view into the shared GPU HMA slab.
Source code in vllm/v1/hisparse/runtime.py
gather_prefill_cache(kv_cache, plan, resident_cache=None)
¶
Gather this runtime's host cache using a shared staging plan.
Source code in vllm/v1/hisparse/runtime.py
invalidate_sorted_slots(sorted_slots, state_indices)
¶
Drop hot copies using shared, preprocessed invalidation inputs.
Source code in vllm/v1/hisparse/runtime.py
reset_hot_state()
¶
Drop all hot-buffer bookkeeping (hits become misses).
Source code in vllm/v1/hisparse/runtime.py
swap_in(*, resident, req_id_per_token, block_table, logical_topk_indices, block_size, num_valid_rows, return_valid_counts=False, attention_indices_out=None, valid_counts_out=None)
¶
Resolve once per group and ensure this layer's rows are available.
Source code in vllm/v1/hisparse/runtime.py
HiSparseSlotInvalidator
¶
Drop hot copies of rewritten host slots for many index groups at once.
Source code in vllm/v1/hisparse/runtime.py
_SharedTopKState
¶
CUDA-graph-safe residency result shared by index-sharing layers.
Source code in vllm/v1/hisparse/runtime.py
_check_residency_shared_memory(device, config)
¶
Reject a config whose residency resolver exceeds per-block shared memory.
Source code in vllm/v1/hisparse/runtime.py
allocate_hisparse_host_pools(vllm_config, tensor_sizes, num_blocks, host_block_stride)
¶
Allocate one host mmap shared by local TP ranks.
Source code in vllm/v1/hisparse/runtime.py
allocate_pinned_host_pool(size)
¶
Allocate and deterministically register an exact-size host KV region.
Source code in vllm/v1/hisparse/runtime.py
build_hisparse_prefill_staging_plan(block_table, seq_lens, block_size, staging_block_capacity)
¶
Build an asynchronous layer-independent host-cache staging remap.
Source code in vllm/v1/hisparse/runtime.py
check_hisparse_host_memory(pool_bytes)
¶
Reject a physical host-pool allocation that cannot fit in RAM.
Source code in vllm/v1/hisparse/runtime.py
get_hisparse_host_pool(vllm_config, kv_cache_config)
¶
Return the engine's host pool, which outlives the profiling KV cache.
Source code in vllm/v1/hisparse/runtime.py
hisparse_prefill_staging_remap(block_table, block_size)
¶
Renumber blocks without a data-dependent CUDA output allocation.
Source code in vllm/v1/hisparse/runtime.py
initialize_hisparse_runtime_buffers(cache_handles, *, max_num_reqs)
¶
Allocate the request state shared by every HiSparse runtime.
Source code in vllm/v1/hisparse/runtime.py
is_hisparse_group_prefetch_batch(attn_metadata, max_rows)
¶
Prefetch historical KV for a pure decode batch, including verification.
Source code in vllm/v1/hisparse/runtime.py
release_pinned_state(pinned_host_pools, shared_host_region=None)
¶
Synchronize and release registered host KV pools.
Source code in vllm/v1/hisparse/runtime.py
update_hisparse_residency(residency, updates, request_ids, request_state_indices)
¶
Apply scheduled requests' residency changes.
residency is [resident groups, state rows, pages]: the GPU block of
each page, or block 0 when the page is read from the host.
Source code in vllm/v1/hisparse/runtime.py
use_shared_hisparse_host_pool(vllm_config)
¶
Whether replicated MLA host KV can share one local mmap.