# Fused norm, RoPE and cast (`fused_norm_rope_cast`) | ServingStudio Kernel Library

RMSNorm, RoPE and an FP8/FP4 cast of attention rows in one launch, optionally stored to a paged cache.

Per token and head: optional RMSNorm over head_dim, interleaved RoPE on the last rope_dim elements, then a per-group MXFP8/NVFP4/MXFP4 cast. The result is cast back to bf16, returned as values plus scales, or written through a slot map into DeepInfer's token-interleaved main cache or block-sectioned index cache.

Category: Attention; group: Compressed sparse MLA. Interactive page: https://servingstudio.cs.washington.edu/kernels.html?kind=fused_norm_rope_cast. All kernel kinds: https://servingstudio.cs.washington.edu/kernels.md.

## Formula

- `bytes = 2·T·H·D read + the output the destination writes`

## 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.

## Arguments

| Argument | Type | Unit | Meaning |
| --- | --- | --- | --- |
| `num_tokens` | number | tokens | Rows (tokens) transformed. |
| `num_heads` | number | heads | Heads per token. |
| `head_dim` | number | elements | Elements per head. |
| `rope_dim` | number | elements | Trailing elements of each head that get RoPE. |
| `norm` | label |  | Whether each head is RMS-normalized first. |
| `cast_format` | label |  | Cast: mxfp8 (E4M3, 32 per UE8M0 scale), nvfp4 (E2M1, 16 per E4M3 scale) or mxfp4 (E2M1, 32 per UE8M0 scale). |
| `output` | label |  | Destination: cast_back (bf16 round trip), quantized (values and scales), cache (paged store) or cache_and_norm (paged store plus the post-norm bf16 rows). |
| `block_size` | number | tokens | Tokens per cache page for the cache outputs; 0 otherwise. |
| `dtype` | dtype |  | Input element type (bf16). |

## Metrics

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

## Backends

- `tilelang`: DeepInfer's TileLang fused_norm_rope_hadamard_cast_store_kvcache, checked bit-exact by DeepInfer's own correctness test on the same case. dtypes `bf16`, compute capability 9.0 or newer, GPUs H100-SXM5-80GB, H100-PCIe-80GB, H200-SXM-141GB, B200-SXM-180GB, B300-SXM-288GB, GB200-Superchip, H800-SXM5-80GB, H20-SXM-96GB.

## Measured rows

483 rows in all.

| GPU | Backend | Precision | Rows |
| --- | --- | --- | --- |
| NVIDIA B200 | `tilelang` | `bf16` | 483 |

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

---

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