# Fused sampler (DeepInfer) (`fused_sample`) | ServingStudio Kernel Library

Filter, normalize and sample each logit row, with optional rejection sampling.

One CTA per row scales the row by its temperature, finds the top-p and top-k thresholds by radix selection, writes the filtered log-softmax and draws a seeded sample; with rejection sampling it also accepts or replaces the row's draft token against the draft distribution. A first launch computes each row's log-sum-exp. Logits are seeded standard-normal; temperature 1, top_p 0.95 and top_k 50 when the filter is active.

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

## Formula

- `bytes = num_rows · num_columns · (4 + 4 + 4 · reject_sampling)`

## 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. Both launches of the call are counted.

## Caveats

- Every row uses the same filter settings; a batch mixing filtered and unfiltered rows is not measured.
- Synthetic logits at temperature 1: DeepInfer's decode capture (temperature 0.3, top_p 0.95) ran the verify call (384 rows) 1.34x and the Markov call (64 rows) 1.06x as long as these rows; the cause is not verified.

## Arguments

| Argument | Type | Unit | Meaning |
| --- | --- | --- | --- |
| `num_rows` | number | rows | Logit rows sampled, one per sampled position. |
| `num_columns` | number | elements | Logits in each row (force_topk width or vocabulary). |
| `reject_sampling` | label |  | Whether the call verifies draft tokens by rejection sampling. |
| `top_p_filter` | label |  | Whether the rows' top-p filter is active (top_p \< 1). |
| `top_k_filter` | label |  | Whether the rows' top-k filter is active (top_k \> 0). |
| `dtype` | dtype |  | Element type of the logits and logprobs (fp32). |

## Metrics

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

## Backends

- `tilelang`: DeepInfer tilelang_ops fused_sample with SamplingKernelInputs. dtypes `fp32`, any CUDA GPU.

## Measured rows

200 rows in all.

| GPU | Backend | Precision | Rows |
| --- | --- | --- | --- |
| NVIDIA B200 | `tilelang` | `fp32` | 200 |

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

---

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