PickPack: Scaling LLM Context to 4M Tokens With Sparse Attention

PickPack (arXiv:2612.01902, UC Berkeley & IIT Bombay) extends LLM context windows up to 16x beyond training length—reaching 4 million tokens on Qwen3.5-9B—by fusing relative-position remapping (Pack) with BLASST pre-softmax sparse tile skipping (Pick) inside one Hopper FlashAttention pass.
PickPack: Scaling LLM Context to 4M Tokens With Sparse Attention: PickPack (arXiv:2612.01902, UC Berkeley & IIT Bombay) extends LLM context windows up to 16x beyond training length—reaching 4 million tokens on Qwen3.5-9B—by fusing relative-position remapping (Pack) with BLASST pre-softmax sparse tile skipping (Pick) inside one Hopper FlashAttention pass. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.
- Scales to 4M Tokens (16x Window): Extends Qwen3.5-9B (256K trained window) to 4,000,000 tokens with +11.6 points higher QAMPARI coverage than YaRN (34.0 vs 22.4).
- Outperforms Shipped Qwen Recipes: Beats default YaRN x4 and DCA on Qwen2.5-7B-1M, Qwen3.5-4B/9B/27B, and Qwen3.8-27B by 1.0–11.0 points at 128K–1M.
- Faster Than Dense Attention: At 50% BLASST tile sparsity, PickPack runs 1.09x–1.22x faster per query on H100/H200 GPUs than dense YaRN/DCA.
- Beats InfLLM & ReAttention: Surpasses prior selection-and-remapping baselines on Llama-3-8B-Instruct at 32K–64K by 24.66 points on RULER-4.
import { createAgent } from '@smoke-monkey/harness';import { execFile } from 'node:child_process';import { promisify } from 'node:util';const execFileAsync = promisify(execFile);// Long-horizon repository analysis agent targeting 1M+ token codebasesconst agent = createAgent({agentId: 'pickpack-repo-auditor',provider: 'openai',model: 'gpt-4o',workspacePath: process.cwd(),permissions: {read_file: 'allow',write_file: 'allow',run_command: 'ask',},});async function runPickPackBenchmark(modelName: string, targetContext: number) {const { stdout } = await execFileAsync('python3', ['-c','print("Configuring Pick_BL o Pack_JL + LogN scaling for ' + modelName + ' at L=' + targetContext + '")',]);return stdout.trim();}async function main() {const cfg = await runPickPackBenchmark('Qwen/Qwen3.8-27B', 1_048_576);const res = await agent.run(`Verify multi-file retrieval strategy under ${cfg} with 50% BLASST pre-softmax tile sparsity.`);console.log(res.summary);}main().catch(console.error);
Watch: Related Video Guides
DeepSeek Sparse Attention Explained: 80% Cheaper Long-Context AI
Qwen Sparse Attention: How Qwen4-Max Reads a Million Tokens
How PickPack Solves Out-of-Distribution Attention and Quadratic Cost
PickPack (github.com/skylight-org/PickPack) is a training-free context extension method that composes two operators inside one FlashAttention pass: Pack, which maps every query–key pair onto an in-distribution relative position inside the trained window W, and Pick, which uses BLASST pre-softmax logits to skip low-mass key-value tiles on Hopper GPUs.
Long-running coding and multi-agent systems accumulate hundreds of thousands of tool outputs and repository files beyond a model's 32K–256K training window. Dense YaRN scaling stretches rotary frequencies but still suffers from attention dilution and O(L^2) prefill bottlenecks. By filtering out noisy out-of-window keys before softmax normalization, PickPack improves accuracy over Pack alone on 7 of 8 Qwen3 configurations while running up to 1.22x faster.
| Model (Trained Window) | Baseline Recipe | Benchmark @ Length | Released Score | PickPack Score | Speedup |
|---|---|---|---|---|---|
| Qwen2.5-7B-Instruct (32K) | YaRN x4 | Needles @ 256K | 61.3 | 72.3 (+11.0) | 1.12x |
| Qwen2.5-7B-1M (256K) | DCA | Needles @ 1M | 75.7 | 83.3 (+7.6) | 1.17x |
| Qwen3.5-9B (256K) | YaRN x4 | LOFT @ 1M | 28.2 | 37.2 (+9.0) | 1.09x |
| Qwen3.5-27B (256K) | YaRN x4 | LOFT @ 1M | 43.4 | 49.8 (+6.4) | 1.20x |
| Qwen3.8-27B (256K) | YaRN x4 | QAMPARI @ 1M | 22.0 | 29.0 (+7.0) | 1.19x |
| Qwen3.5-9B (256K) | YaRN x16 | QAMPARI @ 4M | 22.4 | 34.0 (+11.6) | 1.22x |
4M-Token Scaling Behavior and Hybrid Linear-Softmax Compatibility
Extending Qwen3.5-9B (256K native window) from 1M to 2M and 4M tokens exposes why dense YaRN degrades sharply on multi-needle retrieval:
- Multi-Query & Multi-Value Divergence: Between 1M and 2M tokens on Qwen3.5-9B, YaRN's MQ+MV retrieval collapses from 56.3% to 37.5%, while
Pick_BL o Pack_JLactually rises from 59.4% to 62.5% (and overall Needles reaches 75.0% vs 58.3%). - Works on Hybrid Attention Layers: Qwen3.5 models interleave linear-attention and softmax-attention layers. Applying PickPack to the softmax layers delivers +6.4 to +9.0 point LOFT gains at 1M tokens without retraining.
- Pack_JL and Pack_TR Recipes:
Pack_JLpreserves exact local distancesi - j < wand groups distant blocks by factorG, whilePack_TRadds a three-region low-discrepancy placement map.
Single-Pass Hopper FlashAttention Integration
Because Pick evaluates BLASST thresholds inside the FlashAttention tile loop, it avoids a second quadratic score pass and requires only threshold calibration for ~50% sparsity.
Cloning and Running PickPack on Hopper GPUs
Clone the official skylight-org/PickPack repository on an H100 or H200 node with CUDA 12+ and FlashAttention/BLASST kernels compiled.
git clone https://github.com/skylight-org/PickPack.git
cd PickPack
pip install -e .
# Calibrate BLASST Pick threshold for 50% sparsity and evaluate RULER/LOFT
python -m pickpack.eval \
--model Qwen/Qwen3.8-27B \
--pack-recipe jl \
--sparsity 0.5 \
--logn-scale \
--max-length 1048576Frequently Asked Questions
Q:Does PickPack require fine-tuning or LoRA training to reach 4M tokens?
No. PickPack is completely training-free and operates at inference time by remapping relative positions (Pack) and skipping low-mass KV tiles (Pick) inside FlashAttention.
Q:How does PickPack compare to YaRN and DCA on Qwen3.8-27B?
At 1 million tokens on QAMPARI, PickPack raises Qwen3.8-27B accuracy from 22.0 (shipped YaRN x4) to 29.0 (+7.0 points) while running 1.19x faster per query.
Q:Why does sparsity improve accuracy in context extension rather than hurting it?
When extending past a model’s trained window, millions of irrelevant tokens introduce attention noise that shifts softmax mass out of distribution. Skipping ~50% of low-logit KV tiles suppresses that extension error.
Q:What GPU architecture does the PickPack kernel target?
The paper implements PickPack on top of the BLASST FlashAttention kernel built for NVIDIA Hopper GPUs (H100 and H200).
Related Alternatives & Comparisons
Related Architecture Guides
View all guidesBest Open Source Coding Agents in 2026: Free, Local & Fully Hackable Harnesses
MCP Server Security Best Practices: Hardening Model Context Protocol Agents in 2026
Open Source Coding Agent Harness: Build a Forkable, Local AI Engineering Runtime
Build with Smoke Monkey Harness
Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.