# Partial-output sum, mHC post-block, pre-block and RMSNorm (`mhc_fused_sum_post_pre_rms_norm`) | ServingStudio Kernel Library

Sum a block's partial outputs, mix the result into the mHC residual streams, then compute the next block's mixing weights and normalized input, in one call.

The boundary after an expert-parallel MoE layer when the combine leaves each rank's partial sums in the token owner's memory: the owner adds the num_partials bf16 partial outputs (fp32 accumulate, one bf16 rounding), adds the shared expert's output when shared_addend is set (a second bf16 rounding, as an unfused residual add does), and then does what mhc_fused_post_pre_rms_norm does with that block output: the mHC post mix into the residual streams, the next pre's mixes and the RMS-normalized input. With num_partials = 1 and no addend it is mhc_fused_post_pre_rms_norm.

Category: Normalization; group: Hyper-connections. Interactive page: https://servingstudio.cs.washington.edu/kernels.html?kind=mhc_fused_sum_post_pre_rms_norm. All kernel kinds: https://servingstudio.cs.washington.edu/kernels.md.

## Formula

- `x = bf16(bf16(Σₚ partialₚ) + shared)`
- `streamⱼ ← Σᵢ combᵢⱼ · streamᵢ + postⱼ · x`
- `then the mhc_pre_rms_norm computation on the updated streams`

## 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. Three warm-up calls run first, and every launch of the call is counted. The outputs are checked against the unfused PyTorch path (sum, add, vLLM's Torch post and pre, RMSNorm) before timing.

## Caveats

- The partial outputs are local tensors; a combine that leaves them in peer memory (MNNVL) reads them over NVLink instead, which this does not measure.
- The runner uses ε = 1e-6; another ε runs the same launches.
- GB/s counts one pass over the call's tensors, each partial and the addend once; vllm_tilelang also counts its add (two reads, one write) and its own re-reads of the updated streams. TFLOPS is not computed.

## Arguments

| Argument | Type | Unit | Meaning |
| --- | --- | --- | --- |
| `num_tokens` | number | tokens | Token rows processed by the MHC block. |
| `hidden_size` | number | elements | Features in each residual stream. |
| `hc_mult` | number | streams | Parallel residual streams per token. |
| `hidden_dtype` | dtype |  | Element type of the residual streams and the partial outputs. |
| `num_partials` | number | tensors | Partial block outputs summed into the block output (one bf16 rounding). |
| `shared_addend` | label |  | Whether one more block-output tensor is added after the sum (a shared expert). |

## Metrics

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

## Backends

- `cuda_one_launch`: The cuda_one_launch kernel of mhc_fused_post_pre_rms_norm reading num_partials partial outputs (and the addend) in its post phase. dtypes `bf16`, SM targets `sm_100f`, GPUs B200-SXM-180GB, B300-SXM-288GB, GB200-Superchip.
- `vllm_tilelang`: vLLM's path: the shared expert's output added to the reduced routed output (one bf16 tensor add, when shared_addend is set), then the mhc_fused_post_pre_rms_norm vllm_tilelang call. Only num_partials = 1: vLLM's combine hands over the routed output already reduced. dtypes `bf16`, any CUDA GPU.
- `vllm_tilelang_post_addend`: vLLM's path with the shared expert's add read by the post kernel: above 32 tokens a copy of vLLM's mhc_post_tilelang that takes both block outputs (x = bf16(shared + routed) in-register), then vLLM's prenorm GEMM and pre big-fuse unchanged; at 32 tokens or fewer vLLM's add and fused call unchanged. Only num_partials = 1 with shared_addend. Outputs bit-exact with vllm_tilelang. dtypes `bf16`, any CUDA GPU.

## Measured rows

136 rows in all.

| GPU | Backend | Precision | Rows |
| --- | --- | --- | --- |
| NVIDIA B200 | `cuda_one_launch` | `bf16` | 68 |
| NVIDIA B200 | `vllm_tilelang_post_addend` | `bf16` | 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/mhc_fused_sum_post_pre_rms_norm
- Measured rows: https://servingstudio.cs.washington.edu/api/public/v1/kernels/mhc_fused_sum_post_pre_rms_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/mhc_fused_sum_post_pre_rms_norm/configs

---

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