Skip to content

vllm.v1.hisparse.binding

Worker-side wiring of HiSparse caches to attention layers.

Functions:

_largest_exact_kernel_block_size(block_size, backends, specs)

Largest exact kernel page all backends accept, as a multiple of block_size.

_tensor_placements(kv_cache_config)

Each cache's tensor placement and byte offset.

allocate_hisparse_kv_caches(kv_cache_config, device, layout, kernel_block_sizes, host_pool, allocate=None)

Allocate the host pool separately from the shared device backing.

bind_hisparse_kv_caches(*, forward_context, kv_cache_config, kv_caches, block_tables, host_pool)

Bind existing cache storage and block tables; return the bound handles.

fit_mamba_blocks_to_attention(vllm_config, layer_configs, layers)

Shrink prefix-caching Mamba blocks that would grow the scheduler block.

Mamba blocks start at cache_config.block_size, which resized attention specs may no longer use. Rebuilds the Mamba specs at the largest size up to it that divides the attention blocks' lcm.

get_kv_sharing_readers(forward_context)

Cross-layer KV-sharing layers by target: they own no cache, so HiSparse binds them to their target's resident, hot and host buffers.

init_hisparse_kv_cache(kv_cache_config, device, kernel_block_sizes, vllm_config, forward_context, block_tables, allocate=None)

Allocate and bind HiSparse caches within the caller's allocation context.

rebind_hisparse_device_caches(*, forward_context, kv_cache_config, kv_caches)

Rebind the resident and hot views over resized raw device storage.

kv_caches holds each resident and hot cache's raw storage, as allocation returns it; as in bind_hisparse_kv_caches, resident entries become their views and hot entries are dropped.

resolve_hisparse_specs(vllm_config, layer_configs, attn_layers)

Resolve sparse source and indexer block sizes, derive resident and hot caches, and fit prefix-caching Mamba blocks to the resulting attention blocks.

unbind_hisparse_caches(forward_context)

Detach HiSparse cache bindings without unregistering the host pool.