# FP32 row split with LayerNorm (`fp32_row_split_layer_norm`) | ServingStudio Kernel Library

Round spans of an fp32 GEMM output row to bf16 and LayerNorm one span, in one launch.

When several projections of the same activation are computed as one GEMM over concatenated weights with an fp32 output (so a column group that needs fp32 keeps it), one epilogue launch turns each row back into what the separate projections produced: the leading bf16_lead_cols columns and the bf16_trail_cols columns after the LayerNorm span are rounded to bf16 into their own buffers, the norm_cols columns between them are rounded to bf16 and LayerNormed with an fp32 weight and bias into bf16, and the fp32_tail_cols last columns are not touched (callers read them in place). Rounding before the norm matches a bf16 GEMM output feeding an fp32 LayerNorm. Inputs are seeded random fp32 rows.

Category: Normalization; group: LayerNorm. Interactive page: https://servingstudio.cs.washington.edu/kernels.html?kind=fp32_row_split_layer_norm. All kernel kinds: https://servingstudio.cs.washington.edu/kernels.md.

## Formula

- `lead = bf16(y[:, :L]); trail = bf16(y[:, L+N:L+N+T])`
- `normed = bf16(LayerNorm(float(bf16(y[:, L:L+N])), weight, bias, eps))`
- `GB/s = [6·num_tokens·(L + N + T) + 8·N] / time`

## 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. One launch per call; three warm-up calls run first. Before timing, the output is checked against a Torch reference: the two bf16 spans bit-identical, the LayerNorm span within 1 bf16 ulp (or 1e-6 where it cancels to near zero), and the fp32 row unmodified.

## Caveats

- The triton backend has its row geometry compiled in (2048, 128, 128, 32 columns) and refuses any other.

## Arguments

| Argument | Type | Unit | Meaning |
| --- | --- | --- | --- |
| `num_tokens` | number | tokens | Rows of the fp32 input, one per token. |
| `bf16_lead_cols` | number | elements | Leading columns of each row, rounded to bf16 into their own buffer. |
| `norm_cols` | number | elements | Next columns, LayerNormed (fp32 math on their bf16-rounded values) into bf16. |
| `bf16_trail_cols` | number | elements | Columns after the LayerNorm span, rounded to bf16 into their own buffer. |
| `fp32_tail_cols` | number | elements | Last columns of each row, left in place as the fp32 output. |

## Metrics

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

## Backends

- `triton`: A repo-vendored Triton kernel, one program per row: the whole row in registers, the LayerNorm reduction with tl.sum. any CUDA GPU.

## Measured rows

68 rows in all.

| GPU | Backend | Precision | Rows |
| --- | --- | --- | --- |
| NVIDIA B200 | `triton` |  | 68 |

## Used by these deployments

- [GLM-5.3-Flash NVFP4: ServingStudio design: DP attention, KDA TP groups, fused EP MoE, DFlash speculative decoding](https://servingstudio.cs.washington.edu/models/GLM-5.3-Flash-NVFP4/glm53_flash_nvfp4_dp_attn_kda_tp_fused_ep_moe_dflash2.md) (`GLM-5.3-Flash-NVFP4/glm53_flash_nvfp4_dp_attn_kda_tp_fused_ep_moe_dflash2`)

## API

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

---

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