# Shifted mHC pre (unfused) (`mhc_shifted_pre`) | ServingStudio Kernel Library

Collapse the mHC streams with the carried pre mix and compute this sub-layer's gates and Sinkhorn comb.

DeepInfer's unfused shifted pre: the layer input is the streams weighted by the pre mix the previous sub-layer computed; the TF32 prenorm GEMM, the RMS scale, the sigmoid gates and the 20-step Sinkhorn then produce the mixes the next sub-layer and the post use. Five launches, all timed.

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

## Formula

- `layer_input = Σₕ prev_preₕ · streamₕ`
- `mixes = RMS-scaled (flatten(streams) @ fnᵀ) · scale + base; gates and Sinkhorn comb`

## 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. Every launch of the sequence is counted. Outputs are checked against an fp32 Torch transcription before timing.

## Caveats

- GB/s counts the streams read twice, fn, and the layer input and mixes written once.

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

## Metrics

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

## Backends

- `tile_kernels`: DeepInfer's mhc_ops shifted pre: TileKernels apply-mix, split-mixes, Sinkhorn; DeepGEMM tf32_hc_prenorm_gemm. dtypes `bf16`, SM targets `sm_100f`, GPUs B200-SXM-180GB, B300-SXM-288GB, GB200-Superchip. Source: https://github.com/deepseek-ai/TileKernels

## Measured rows

71 rows in all.

| GPU | Backend | Precision | Rows |
| --- | --- | --- | --- |
| NVIDIA B200 | `tile_kernels` | `bf16` | 71 |

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

---

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