Architecture
~9 min readUpdated: December 2026

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

PickPack Pack and Pick Single-Pass Sparse FlashAttention Architecture

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.

Technical Review: Smoke Monkey Core Architecture Team
Tested on Node.js 18+ & BunTypeScript 5.x
Quick Answer & Executive Definition

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.

Key Architectural Takeaways
Quick Implementation Examplepickpack-long-context-agent.ts
pickpack-long-context-agent.tstypescript
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 codebases
const 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);
Video Guides

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 RecipeBenchmark @ LengthReleased ScorePickPack ScoreSpeedup
Qwen2.5-7B-Instruct (32K)YaRN x4Needles @ 256K61.372.3 (+11.0)1.12x
Qwen2.5-7B-1M (256K)DCANeedles @ 1M75.783.3 (+7.6)1.17x
Qwen3.5-9B (256K)YaRN x4LOFT @ 1M28.237.2 (+9.0)1.09x
Qwen3.5-27B (256K)YaRN x4LOFT @ 1M43.449.8 (+6.4)1.20x
Qwen3.8-27B (256K)YaRN x4QAMPARI @ 1M22.029.0 (+7.0)1.19x
Qwen3.5-9B (256K)YaRN x16QAMPARI @ 4M22.434.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:

  1. 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_JL actually rises from 59.4% to 62.5% (and overall Needles reaches 75.0% vs 58.3%).
  2. 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.
  3. Pack_JL and Pack_TR Recipes: Pack_JL preserves exact local distances i - j < w and groups distant blocks by factor G, while Pack_TR adds 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.

bash
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 1048576
Google Search Questions & Answers

Frequently 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 guides

Build with Smoke Monkey Harness

Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.

npm install smoke-monkey-harness