# Sampler top-k (DeepSelect, fp32 values) (`deep_select_logits_topk`) | ServingStudio Kernel Library

Keep the top_k largest fp32 scores of each row with their int32 indices.

One CTA per row selects the top_k largest of the row's num_columns fp32 scores and writes their values and int32 indices, in descending order when sorted, else in selection order. DeepInfer's sampler restricts sampling to the force_topk largest logits this way (sorted=False) and picks the requested top logprobs from them (sorted=True). Scores are seeded standard-normal.

Category: Other. Interactive page: https://servingstudio.cs.washington.edu/kernels.html?kind=deep_select_logits_topk. All kernel kinds: https://servingstudio.cs.washington.edu/kernels.md.

## Formula

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

## 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' selected values are checked against torch.topk first.

## Caveats

- Rows are contiguous; DeepInfer's Markov steps pass every fifth row of the draft logits (a strided view), measured within 2% of contiguous rows.

## Arguments

| Argument | Type | Unit | Meaning |
| --- | --- | --- | --- |
| `num_rows` | number | rows | Logit rows selected from, one per sampled position. |
| `num_columns` | number | elements | Scores in each row (vocabulary or force_topk width). |
| `top_k` | number | elements | Values and indices kept per row. |
| `sorted` | label |  | Whether the kept values come back in descending order. |
| `dtype` | dtype |  | Element type of the scores and returned values (fp32). |

## 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 fp32 rows returning values and int32 indices. dtypes `fp32`, SM targets `sm_100f`, GPUs B200-SXM-180GB, B300-SXM-288GB, GB200-Superchip. Source: https://github.com/deepseek-ai/DeepSelect

## Measured rows

150 rows in all.

| GPU | Backend | Precision | Rows |
| --- | --- | --- | --- |
| NVIDIA B200 | `deep_select` | `fp32` | 150 |

## Used by these deployments

- [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_logits_topk
- Measured rows: https://servingstudio.cs.washington.edu/api/public/v1/kernels/deep_select_logits_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_logits_topk/configs

---

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