# Prefill indexer logits (FP4, chunked) (`mqa_logits_prefill_chunk`) | ServingStudio Kernel Library

Score a prefill query chunk against its compressed index keys in FP4.

For each row and each key in its window the kernel forms the ReLU of every head's query-key dot product, weights it by the row's bf16 head weight and sums over heads into one bf16 logit. Row i of the chunk sees (context_len − num_queries + i + 1) // compress_ratio keys.

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

## Formula

- `P = Σ_i (context_len − num_queries + i + 1) // compress_ratio`
- `FLOPs = 2 · P · num_heads · head_dim`
- `bytes = num_queries · num_heads · (head_dim/2 + 4) + keys · (head_dim/2 + 4) + 2 · num_queries · num_heads + 2 · P`

## 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 are checked against fp32 math on the dequantized operands first.

## Caveats

- max_seqlen_k is the request's key count; DeepInfer passes runtime_max_model_len // ratio, which only sizes the uninitialized logits buffer.

## Arguments

| Argument | Type | Unit | Meaning |
| --- | --- | --- | --- |
| `num_queries` | number | tokens | Query rows scored in the call. |
| `context_len` | number | tokens | Context of the request, the rows included; the rows are its last tokens. |
| `compress_ratio` | number | tokens | Context tokens per compressed index key. |
| `num_heads` | number | heads | Indexer query heads. |
| `head_dim` | number | elements | Width of each query head and key. |
| `dtype` | dtype |  | Element type of index Q and K (FP4 E2M1 with UE8M0 scales per 32). |

## Metrics

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

## Backends

- `deepgemm_sm100`: DeepGEMM fp8_fp4_mqa_logits with FP4 Q/K, as DeepInfer's prefill indexer calls it. dtypes `mxfp4_e2m1`, SM targets `sm_100f`, GPUs B200-SXM-180GB, B300-SXM-288GB, GB200-Superchip. Source: https://github.com/deepseek-ai/DeepGEMM

## Measured rows

338 rows in all.

| GPU | Backend | Precision | Rows |
| --- | --- | --- | --- |
| NVIDIA B200 | `deepgemm_sm100` | `mxfp4_e2m1` | 338 |

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

---

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