Understanding BigBird's Block Sparse Attention
BigBird replaces BERT's quadratic full attention with block sparse attention, which combines sliding-window, global and random attention to approximate full attention at linear cost. That makes sequences up to 4096 tokens practical. Graph intuition shows how global and random connections shorten information paths between tokens, so fewer layers are needed to propagate context. The implementation groups tokens into blocks and uses shifted key copies and gathered random blocks, so the sparse pattern becomes dense matrix multiplications that run efficiently on GPUs and TPUs. The walkthrough maps the 🤗Transformers code, block by block, to the query segments it computes.
Related posts
- Ulysses Sequence Parallelism: Training with Million-Token Contexts
Hugging Face hardMasterUlysses Sequence Parallelism, part of Snowflake's Arctic Long Sequence Training protocol, enables training on contexts of hundreds of thousands to millions of tokens. Each GPU holds a shard of the sequence, and all-to-all collectives regroup the data so each GPU computes attention over every position for a subset of heads. That costs O(n·d/P) communication per GPU, versus O(n·d) over P−1 serial hops for Ring Attention. Ulysses is now integrated into Hugging Face Accelerate (ParallelismConfig with a DeepSpeed backend), the Transformers Trainer and TRL's SFTTrainer, which handle dataloader sharding, shifted labels and token-weighted loss aggregation automatically. Practical guidance covers padding to a multiple of sp_size, the num_heads ≥ sp_size constraint, choosing FlashAttention versions, ZeRO-3 offload, expandable_segments, Liger-Kernel, and balancing SP against DP across GPU counts.
- Optimizing your LLM in production
Hugging Face mediumAdeptServing billion-parameter LLMs efficiently comes down to three levers: lower precision, Flash Attention, and inference-friendly architectures such as ALiBi, rotary embeddings, Multi-Query Attention and Grouped-Query Attention. Weights need roughly 2 GB of VRAM per billion parameters in bfloat16, and measurements on OctoCoder (~15B parameters) show peak memory dropping from about 29 GB in bfloat16 to 15 GB with 8-bit and 9.5 GB with 4-bit bitsandbytes quantization, with little output change but slightly slower inference. Flash Attention addresses self-attention's quadratic memory growth with sequence length by restructuring the computation to make better use of GPU memory. Code examples in Hugging Face Transformers accompany each technique.
- Making FlashAttention-4 faster for inference
Modal hardMaster
Modal engineers extended the FlashAttention-4 kernel for decode-heavy LLM inference on Blackwell GPUs through two kinds of change: new parallelism strategies, such as split-KV parallelism across the key/value dimension, and support for irregular memory access via cp.async in place of TMA bulk loads. FP8 inputs gave up to 1.16x throughput over bf16, likely limited by the softmax, which still runs at higher precision. Arbitrary KV page sizes help prefix sharing, reduce fragmentation and suit speculative decoding, and a transposed warp-level address-generation scheme made them up to 2.4x faster. Split-KV raised small-query memory throughput by up to 4.37x, keeping SMs busy that the original query-parallel design left idle.
- Sequential Attention: Making AI models leaner and faster without sacrificing accuracy
Google Research hardMasterSequential Attention is a greedy subset-selection algorithm that runs inside a single training run. It uses softmax attention scores over unselected candidates (features, embedding chunks, weight blocks) to add the most informative one at each step, and recomputes scores so the ranking reflects marginal gain and avoids redundant picks. For feature selection it matches or beats baselines on proteomics, image and activity-recognition benchmarks, and on linear regression it is provably equivalent to Orthogonal Matching Pursuit. SequentialAttention++ combines differentiable pruning with combinatorial search to produce block-sparse weights that run efficiently on GPUs and TPUs, with compression gains on ImageNet. Planned uses include recommender embedding optimization and structured LLM pruning.
- Welcome Beam: a 501B open model you can own, customize, and scale
Hugging Face hardMasterBeam is a 501B-parameter mixture-of-experts model from Reflection with 23B active parameters per token, a 1M-token context window, and an Apache 2.0 license, aimed at coding and agentic workloads. It interleaves 43 sliding-window RoPE layers with 9 global layers that use no positional encoding and scalable-softmax query scaling, which cuts KV-cache growth to 36 KiB per token (about 36 GiB at 1M context versus 208 GiB if every layer were global). Its 256-expert router follows DeepSeek-V3's group-limited scheme without a shared expert, and its residual stream uses depth-dependent weights that keep the stream at a constant scale. Practical guidance covers BF16, FP8 and NVFP4 checkpoints, hardware sizing (NVFP4 at ~280 GB on four B200s is recommended), transformers expert-parallel loading, and vLLM/SGLang serving with DFlash2 speculative decoding.