# Engram gate (`engram_gate`) | ServingStudio Kernel Library

Gates the projected Engram value into every hyper-connection stream, in place.

For each token and stream the kernel computes the RMS norms of the stream and of its projected key, a weighted dot product of the two, a clamped signed-sqrt gate from it, and adds gate times the shared value row to the stream. Inputs: streams \[num_tokens, hc_mult, hidden_size\] and keys plus value \[num_tokens, hc_mult + 1, hidden_size\], both bf16; the streams are updated in place.

Category: Other. Interactive page: https://servingstudio.cs.washington.edu/kernels.html?kind=engram_gate. All kernel kinds: https://servingstudio.cs.washington.edu/kernels.md.

## Formula

- `bytes = 2 · num_tokens · hidden_size · (2 · hc_mult + hc_mult + 1)`

## 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 | Tokens on this GPU. |
| `hc_mult` | number | streams | Hyper-connection streams per token. |
| `hidden_size` | number | elements | Width of each stream. |
| `dtype` | dtype |  | Element type of the streams and the projected key/value rows (bf16). |

## Metrics

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

## Backends

- `tile_kernels`: tile_kernels.engram.engram_gate_fwd as DeepInfer calls it: in place, save_for_backward=False, no image-token mask. dtypes `bf16`, any CUDA GPU. Source: https://github.com/deepseek-ai/TileKernels

## Measured rows

138 rows in all.

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

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

---

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