flashinfer.mla.convert_compressed_page_aligned_sparse_indices_to_hca_metadata¶
- flashinfer.mla.convert_compressed_page_aligned_sparse_indices_to_hca_metadata(sparse_indices: Tensor, sparse_topk_lens: Tensor, seq_lens: Tensor, swa_kv_cache: Tensor, compressed_kv_cache: Tensor, *, q_len: int, kv_layout: Literal['HND', 'NHD'] = 'HND') DSV4HCAMetadata¶
Convert combined sparse indices into reusable HCA metadata.
Active SWA entries remain arbitrary absolute token-row indices and may express ring-buffer rotation or wraparound. The compressed segment must be the canonical expansion
page_id * page_size + page_offset. For a dense causal query, this conversion requiresvisible_raw_len = seq_len - q_len + query_position + 1andsparse_topk_len = 128 + floor(visible_raw_len / 128).The conversion validates tensor values, allocates metadata, and synchronizes the device. It is not CUDA Graph capture safe and must not be repeated in a latency-sensitive decode loop. Run it during setup, then reuse the returned indices and compressed block table with
backend="cute-dsl".