# Indexer top-k (DeepSelect, bf16) (`deep_select_topk`) | ServingStudio Kernel Library

Keep the indices of the top_k largest scores of each row's valid prefix.

One CTA per row selects the top_k largest of the row's first row_len bf16 scores and writes their int32 indices in ascending order (-1 past a short row). Scores are seeded standard-normal in rows padded to 1024 bytes.

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

## Formula

- `bytes = num_rows · (2 · row_len + 4 · top_k + 8)`

## 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. Four rows' selections are checked against torch.topk first.

## Caveats

- Every row is row_len long; DeepInfer's rows differ slightly within a call (causal windows), which the integration prices at the mean length.
- Measured with the per-row output offsets of the dense call site; the block-score and candidate call sites pass none.

## Arguments

| Argument | Type | Unit | Meaning |
| --- | --- | --- | --- |
| `num_rows` | number | rows | Score rows selected from. |
| `row_len` | number | elements | Valid scores in each row (the row's end). |
| `top_k` | number | elements | Indices kept per row. |
| `dtype` | dtype |  | Element type of the scores (bf16). |

## Metrics

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

## Backends

- `deep_select`: DeepSelect topk on bf16 rows with per-row end, sorted indices, no values. dtypes `bf16`, SM targets `sm_100f`, GPUs B200-SXM-180GB, B300-SXM-288GB, GB200-Superchip. Source: https://github.com/deepseek-ai/DeepSelect

## Measured rows

504 rows in all.

| GPU | Backend | Precision | Rows |
| --- | --- | --- | --- |
| NVIDIA B200 | `deep_select` | `bf16` | 504 |

## Used by these deployments

- [DeepSeek V4.1 Flash 1017: vLLM or DeepInfer, DP attention, EP MoE](https://servingstudio.cs.washington.edu/models/DeepSeek-V4.1-Flash-1017/deepseek_v41_vllm_dp_attn_ep_moe.md) (`DeepSeek-V4.1-Flash-1017/deepseek_v41_vllm_dp_attn_ep_moe`)
- [DeepSeek V4.1 Flash 1017: vLLM, DP attention, EP MoE, DSpark speculative decoding](https://servingstudio.cs.washington.edu/models/DeepSeek-V4.1-Flash-1017/deepseek_v41_vllm_dp_attn_ep_moe_dspark.md) (`DeepSeek-V4.1-Flash-1017/deepseek_v41_vllm_dp_attn_ep_moe_dspark`)

## API

- This kind: https://servingstudio.cs.washington.edu/api/public/v1/kernels/deep_select_topk
- Measured rows: https://servingstudio.cs.washington.edu/api/public/v1/kernels/deep_select_topk/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/deep_select_topk/configs

---

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