# Sparse index expansion (`sparse_index_expand`) | ServingStudio Kernel Library

Turn selected compressed groups into packed logical token ids plus a count.

One program per row and block of 256 output columns writes a \[num_rows, token_topk + ratio\] int32 buffer. Every measured row has its full selection; the time does not depend on the context (under 3% from 512 to 131072 tokens).

Category: Attention; group: Sparse GQA. Interactive page: https://servingstudio.cs.washington.edu/kernels.html?kind=sparse_index_expand. All kernel kinds: https://servingstudio.cs.washington.edu/kernels.md.

## Formula

- `GB/s = num_rows · (4·token_topk/ratio + 4·(token_topk + ratio) + 12) / time`

## How it is measured

GPU kernel time from CUPTI activity records, averaged over repeated launches in one capture. The L2 cache is flushed before each launch, so the numbers are cold-cache times. The one launch of the public call is counted.

## Caveats

- GB/s counts the selection read and the packed buffer written.

## Arguments

| Argument | Type | Unit | Meaning |
| --- | --- | --- | --- |
| `num_rows` | number | tokens | Query rows whose selections are expanded. |
| `token_topk` | number | tokens | Tokens selected from complete groups per row. |
| `compress_ratio` | number | tokens | Tokens per compressed group. |

## Metrics

- Time (`time_ms`, ms)
- Throughput (`tflops`, TFLOPS)
- Memory bandwidth (`memory_bandwidth_gbps`, GB/s)
- Energy (`energy_j`, J)

## Backends

- `vllm_triton`: The alignment vLLM fork's expand_qsa_block_indices (Triton). compute capability 7.5 or newer, GPUs A100-SXM4-40GB, A100-SXM4-80GB, A100-PCIe-40GB, A100-PCIe-80GB, H100-SXM5-80GB, H100-PCIe-80GB, H200-SXM-141GB, B200-SXM-180GB, B300-SXM-288GB, GB200-Superchip, H800-SXM5-80GB, H20-SXM-96GB, A40, L40, L40S, L4. Source: https://github.com/serendipity-zk/vllm/blob/892da0822f7e866cec8e519727f014c45a5ad792/vllm/models/qwen4_exp/nvidia/ops/qsa_indexer.py

## Measured rows

68 rows in all.

| GPU | Backend | Precision | Rows |
| --- | --- | --- | --- |
| NVIDIA B200 | `vllm_triton` |  | 68 |

## Used by these deployments

- [Qwen3.8 Flash Next NVFP4: vLLM, one GPU, MTP speculative decoding](https://servingstudio.cs.washington.edu/models/Qwen3.8-Flash-Next-NVFP4/qwen4_exp_vllm_nvfp4_gdn_qsa_moe_speculative.md) (`Qwen3.8-Flash-Next-NVFP4/qwen4_exp_vllm_nvfp4_gdn_qsa_moe_speculative`)

## API

- This kind: https://servingstudio.cs.washington.edu/api/public/v1/kernels/sparse_index_expand
- Measured rows: https://servingstudio.cs.washington.edu/api/public/v1/kernels/sparse_index_expand/rows (filter by any column, such as `?gpu=NVIDIA%20H200`; `format=csv` for CSV)
- Configs the public deployments ask of it: https://servingstudio.cs.washington.edu/api/public/v1/kernels/sparse_index_expand/configs

---

This page as Markdown: https://servingstudio.cs.washington.edu/kernels/sparse_index_expand.md. A guide to the whole site for AI agents: [llms.txt](https://servingstudio.cs.washington.edu/llms.txt).
