Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Hugging Face 10 min read Research hardMaster

Differential Transformer V2

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.

Assumes: Transformer self-attentiongrouped-query attentionFlashAttentionLLM pretraining stability

Related posts

  • Supercharging transformer residual connections

    Google Research hardMaster

    DeepCrossAttention (DCA) replaces the fixed point-wise summation of transformer residual connections with learned, per-token routing over all preceding layer outputs. It does this through dynamic layer-mixing weights and depth-wise cross-attention with split Q/K/V, which prevents early-layer features from being diluted. On LM1B and C4, DCA matched standard transformers in up to 5x fewer training steps and hit sub-14 LM1B perplexity with 30 layers instead of 42, while adding under 0.2% parameters. It can also be retrofitted onto pre-trained models, and the post places it alongside related techniques such as attention residuals, hyper-connections and manifold-constrained hyper-connections.

  • Tricks from OpenAI gpt-oss YOU 🫵 can use with transformers

    Hugging Face hardMaster

    Hugging Face upgraded transformers to support OpenAI's gpt-oss models, and most of the new features carry over to other models. These include pre-built kernels downloaded from the Hub (Liger RMSNorm, MegaBlocks MoE, Flash Attention 3 with attention sinks), native MXFP4 4-bit quantization via Triton kernels, tensor and expert parallelism, dynamic sliding window caching, continuous batching with paged attention, and faster loading. MXFP4 stores E2M1 values in 32-element blocks with shared scales. That lets gpt-oss-20B run in about 16 GB of VRAM and 120B in about 80 GB, versus roughly 4× the memory in the bf16 fallback. Benchmarks show the custom and MXFP4 kernels pay off mainly at larger batch sizes.

  • You could have designed state of the art positional encoding

    Hugging Face hardMaster

    Rotary Positional Encoding (RoPE) can be derived step by step from simple ideas. The derivation starts from the permutation-equivariance of self-attention, demonstrated with Llama 3.2 1B embeddings, and lists five desirable properties for a positional scheme. It then iterates from integer to binary to sinusoidal encodings, showing that sinusoidal encoding already encodes relative offsets as a rotation matrix. The final step moves to a multiplicative rotation of queries and keys inside the QK^T dot product, which preserves vector norms and yields RoPE as used in modern transformers.

  • Introducing RWKV - An RNN with the advantages of a transformer

    Hugging Face easyNovice

    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. Each step needs only matrix-vector operations, memory stays constant as context grows, and ctx8192 models run as fast as ctx1024 ones with the same RAM. RWKV-4 checkpoints from ~170M to 14B parameters were trained on the Pile, alongside Raven chat fine-tunes. The architecture is now integrated into Hugging Face transformers, with pipeline and generate examples and a script for converting raw RWKV weights to HF format.

  • TurboQuant: Redefining AI efficiency with extreme compression

    Google Research hardMaster

    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. On long-context benchmarks with Gemma, Mistral and Llama-3.1-8B, it quantizes the KV cache to 3 bits with no training and no measured accuracy loss, cutting KV memory by at least 6x. 4-bit TurboQuant computes attention logits up to 8x faster than 32-bit keys on H100s. For vector search it beats PQ and RabbiQ on 1@k recall on GloVe without large codebooks or dataset-specific tuning, and the methods come with proofs of near-optimal distortion.

The quest for software engineering knowledge.

Look:
Layout: