---
title: "Differential Transformer V2"
description: "Differential Transformer V2 reworks differential attention by doubling query heads while keeping key-value heads fixed, subtracting paired heads within the same GQA group using a per-token, per-head sigmoid-gated λ."
url: "https://swe.quest/articles/differential-transformer-v2-308ff82f46821bd8"
canonical: "https://huggingface.co/blog/microsoft/diff-attn-v2"
source: "Hugging Face"
published: "2026-01-20"
difficulty: "hard"
kind: "Research"
reading_minutes: 10
tags: ["llms","model-training","inference","machine-learning"]
---

# Differential Transformer V2

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2026-01-20, 10 min read, Research. Original: [https://huggingface.co/blog/microsoft/diff-attn-v2](https://huggingface.co/blog/microsoft/diff-attn-v2)

## Summary

Differential Transformer V2 reworks differential attention by doubling query heads while keeping key-value heads fixed, subtracting paired heads within the same GQA group using a per-token, per-head sigmoid-gated λ. This keeps decoding speed on par with a standard Transformer, needs no custom FlashAttention kernels, and drops V1's per-head RMSNorm, which amplified outputs up to ~90x at 8K context and caused gradient instability. A context-RMS analysis shows the gated subtraction lets output magnitude reach zero, helping eliminate attention sinks, with comparisons to off-by-one softmax, gpt-oss sinks and gated attention. Early production-scale pretraining, including a 30A3 MoE, shows 0.02–0.03 lower loss at 1T tokens, fewer loss and gradient spikes at high learning rates, and smaller activation outliers. Ablations confirm that pairing heads across GQA groups, removing λ, or dropping the sigmoid all hurt results.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [Machine learning](https://swe.quest/tags/machine-learning.md) (AI & ML)

## Prerequisites

- Transformer self-attention
- grouped-query attention
- FlashAttention
- LLM pretraining stability ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))

## Keywords

Differential Transformer, DIFF V2, FlashAttention, GQA, attention sinks, RMSNorm, gpt-oss, YOCO

## Related posts

- [Supercharging transformer residual connections](https://swe.quest/articles/supercharging-transformer-residual-connections-cfa196a28b957618.md): Google Research · 2026-11-23 · Hard · 7 min read · LLMs, Model training, Machine learning
  DeepCrossAttention (DCA) replaces the fixed point-wise summation of transformer residual connections with learned, per-token routing over all preceding layer outputs.
- [Tricks from OpenAI gpt-oss YOU 🫵 can use with transformers](https://swe.quest/articles/tricks-from-openai-gpt-oss-you-can-use-with-transformers-aad70bf42c0bd3ff.md): Hugging Face · 2025-09-11 · Hard · 15 min read · Inference & serving, LLMs, Python, Performance engineering
  Hugging Face upgraded transformers to support OpenAI's gpt-oss models, and most of the new features carry over to other models.
- [You could have designed state of the art positional encoding](https://swe.quest/articles/you-could-have-designed-state-of-the-art-positional-encoding-af87c15753b60969.md): Hugging Face · 2024-11-25 · Hard · 15 min read · LLMs, Machine learning
  Rotary Positional Encoding (RoPE) can be derived step by step from simple ideas.
- [Introducing RWKV - An RNN with the advantages of a transformer](https://swe.quest/articles/introducing-rwkv-an-rnn-with-the-advantages-of-a-transformer-61894d925597865d.md): Hugging Face · 2023-05-15 · Easy · 10 min read · LLMs, Machine learning, Inference & serving
  RWKV is an attention-free language model architecture, derived from Apple's Attention Free Transformer, that trains in parallel like a GPT-style transformer but runs inference as an RNN.
- [TurboQuant: Redefining AI efficiency with extreme compression](https://swe.quest/articles/turboquant-redefining-ai-efficiency-with-extreme-compression-d5471afe1cc3ed09.md): Google Research · 2026-03-24 · Hard · 7 min read · Inference & serving, Vector search, LLMs, Algorithms
  TurboQuant is a data-oblivious vector quantization algorithm that removes the per-block quantization-constant overhead of traditional methods by combining PolarQuant (random rotation plus recursive polar-coordinate transforms with a fixed angle grid) and a 1-bit Quantized Johnson-Lindenstrauss residual stage that removes bias in inner-product estimates.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
