Skip to content

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

Google Research 7 min read Research hardMaster

Supercharging transformer residual connections

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.

Assumes: transformer architectureresidual connectionsattention mechanism

Related posts

  • Differential Transformer V2

    Hugging Face hardMaster

    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.

  • Multi-token Residual Prediction

    Modal hardMaster

    Multi-token Residual Prediction (MRP) adapts multi-token prediction to diffusion language models by training a small 3-layer transformer on a frozen backbone to predict the logit residual between adjacent denoising steps, not the full next-step distribution. The residual target is low-complexity, so accuracy holds across several steps: on SDAR-4B GSM8K it scores 57.2% at four steps, while naive full-distribution distillation falls to 1.9%. In the static regime MRP serves as a speculative drafter for lossless speedups of about 1.3–1.4× in SGLang, or commits tokens directly for up to about 1.9× at a small quality cost. In the dynamic regime it remasks over-eager low-threshold reveals and recovers up to roughly +22 accuracy points. The best module depth is 2–3 layers, and shallower modules suit speculative mode.

  • Apriel-H1: The Surprising Key to Distilling Efficient Reasoning Models

    Hugging Face hardMaster

    ServiceNow converted its 15B Apriel reasoning model into a Mamba/attention hybrid via distillation, reaching 2.1x throughput with small benchmark shifts (MATH500 up, GPQA and AIME24 slightly down) using 76.8B tokens. The key finding is that distilling on the teacher's high-quality SFT reasoning traces works, while pretraining data or mixed data degrades reasoning. Reverse KL beat forward KL. A staged procedure does the conversion: leave-one-out layer importance for the first 25 layers, then a dynamic MIL-Mamba-Replacement loss heuristic to progressively reach 30–40 Mamba layers, with the 40-layer variant reaching 3.4x throughput. Training uses the open-source Fast-LLM framework, inference runs on Transformers and vLLM, and the authors warn that hybrid deployment tooling is still immature.

  • DeepSeek-V4: a million-token context that agents can actually use

    Hugging Face hardMaster

    DeepSeek-V4 (Pro: 1.6T total/49B active; Flash: 284B/13B active) is a MoE model family whose 1M-token context is made practical by a hybrid attention design that interleaves Compressed Sparse Attention (4x KV compression plus an FP4 lightning indexer selecting top-k blocks) with Heavily Compressed Attention (128x compression with dense attention), plus FP8 KV storage. At 1M tokens V4-Pro needs 27% of V3.2's per-token FLOPs and 10% of its KV cache, about 2% of a bf16 GQA-8 cache. Agent-focused post-training preserves reasoning across user turns when tools are involved, adds an XML-based |DSML| tool-call schema to reduce escaping and type errors, and relies on DSec, a Rust sandbox platform for RL rollouts. Agent benchmarks land near frontier closed models (SWE Verified 80.6, MCPAtlas 73.6), and MRCR 8-needle retrieval holds 0.59 at 1M tokens.

  • Hugging Face Reads, Feb. 2021 - Long-range Transformers

    Hugging Face hardMaster

    Long-range attention methods attack the quadratic memory and time cost of self-attention in sequence length, and four papers illustrate the main families. Longformer combines dilated windowed and global attention to reach linear cost and serves as a drop-in replacement, so pretrained checkpoints can be adapted to long inputs. Compressive Transformer extends Transformer-XL with a compressed memory of past activations, using pooling or convolution, to model longer dependencies. Linformer exploits the low rank of attention matrices to project the sequence dimension and get linear complexity. Each paper comes with complexity analysis, main findings and open questions, such as TPU indexing costs, hyperparameter brittleness and long-target seq2seq tasks.

The quest for software engineering knowledge.

Look:
Layout: