LinearSpec: Zero-KV-Overhead Speculative Decoding for 128K Hybrid VLMs

LinearSpec (arXiv:2612.02985) is a 617M-parameter speculative drafter for hybrid Vision-Language Models (VLMs) like Qwen3.5-2B/4B/9B that eliminates the separate draft KV cache and draft prefill. By initializing its four layers directly from the target VLM’s three top Gated DeltaNet (GDN) states and final attention KV cache inside SGLang, LinearSpec decodes 128K-token page-image documents 17% faster than DFlash and 9% faster than DSpark.
LinearSpec: Zero-KV-Overhead Speculative Decoding for 128K Hybrid VLMs: LinearSpec (arXiv:2612.02985) is a 617M-parameter speculative drafter for hybrid Vision-Language Models (VLMs) like Qwen3.5-2B/4B/9B that eliminates the separate draft KV cache and draft prefill. By initializing its four layers directly from the target VLM’s three top Gated DeltaNet (GDN) states and final attention KV cache inside SGLang, LinearSpec decodes 128K-token page-image documents 17% faster than DFlash and 9% faster than DSpark. 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.
- Zero Draft KV Cache or Prefill: Reads the target VLM’s existing GDN states and last full-attention KV cache in place, freeing GPU VRAM for higher request concurrency.
- +17% Faster Than DFlash at 128K Page Docs: Outperforms DFlash by 16.9% on long text and 15.4-17% on 128K multimodal documents, and beats released DFlash by 26.5-39.1% on long/agentic tasks.
- 4.49x Autoregressive Speedup on Qwen3.5-9B: Matches or exceeds DFlash on short prompts (4.49x vs 4.41x on short text; 2.31x vs 2.25x on single images) before pulling ahead at long context.
- Sequential GDN Draft Head: Avoids DFlash’s parallel block-drafting accuracy collapse by conditioning each draft token sequentially through a lightweight GDN head.
import { createAgent } from '@smoke-monkey/harness';// Long-context multimodal document agent backed by SGLang + LinearSpec speculative decodingconst agent = createAgent({agentId: 'linearspec-128k-doc-agent',provider: 'openai-compatible',baseUrl: 'http://127.0.0.1:30000/v1',model: 'Qwen/Qwen3.5-4B',workspacePath: process.cwd(),permissions: {read_file: 'allow',write_file: 'ask',run_command: 'ask',},});async function main() {const result = await agent.run('Extract financial tables and chart trends across the 128K-token PDF page images in ./docs/annual-report.');console.log('128K VLM Analysis:', result.summary);}main().catch(console.error);
Watch: Related Video Guides
Faster LLMs: Accelerate Inference with Speculative Decoding
LLMs | Efficient LLM Decoding-II | Lec15.2
What Is LinearSpec and Why Do Block Drafters Stall at 128K?
LinearSpec (Wang, Zhang, & Li, arXiv:2612.02985) is a speculative decoding drafter designed for hybrid linear-and-full-attention Vision-Language Models such as Qwen3.5-2B, Qwen3.5-4B, and Qwen3.5-9B. Block drafters like DFlash and DSpark must maintain their own separate KV cache over the prompt, consuming extra VRAM and prefill latency while suffering acceptance-length decay on 128K multimodal documents.
LinearSpec (617M parameters vs 634M for DFlash) eliminates the draft KV cache entirely by reading the target model's top three Gated DeltaNet (GDN) states and final full-attention KV cache directly in place inside SGLang.
| Drafter Architecture | Params | Reads Target KV? | Uses Target GDN State? | Separate Draft KV? | Qwen3.5-4B Short Text Spd | Qwen3.5-4B 128K Doc Advantage |
|---|---|---|---|---|---|---|
| DFlash | 634M | No | No | Yes (VRAM overhead) | 3.79x (AL 6.42) | Baseline |
| DSpark | 634M | No | No | Yes (VRAM overhead) | 4.13x (AL 7.14) | +8% behind LinearSpec at 128K |
| LinearSpec | 617M | Read in place | Read & advanced | None (0 bytes) | 3.81x (AL 6.54) | +15.4% to +17% vs DFlash; +9% vs DSpark |
How In-Place GDN Drafting Scales Concurrent 128K Agent Sessions
Hybrid VLMs store long-horizon memory in constant-size GDN recurrent matrices S_t alongside only a few full-attention KV layers. LinearSpec exploits both representations without duplicating either:
- Entry State Projection: For each accepted token, LinearSpec concatenates the target's top-layer keys/values and three GDN states into
z_aand projects them into the drafter's four layers (three GDN layers plus one full-attention layer). - Strongest Gains on Long Agentic & Document Traces: On Qwen3.5-4B agent trajectories (>=32K tokens, 216 tasks), LinearSpec achieves +20.0% faster decode (+20.3% higher acceptance length) than DFlash trained on identical data, and +39.1% faster decode than the released DFlash checkpoint.
- Zero Draft KV Memory Overhead: Dropping the draft KV cache lets serving operators pack more concurrent 128K requests into the same H100/H200 GPU memory pool, avoiding KV eviction thrashing on multi-document agent workflows.
Know Where LinearSpec Excels vs Subtitle-Free Video
LinearSpec delivers +9% to +17% decode speedups on 128K text, PDF page-image documents, tables, charts, and >=32K agentic tool traces, while gains are smaller on dense subtitle-free video streams where consecutive frame tokens remain harder to predict.
Reproducible SGLang Hybrid VLM Serving and Speculative Benchmark
Launch Qwen/Qwen3.5-4B in SGLang with speculative decoding enabled and compare 128K multimodal document latency and KV pool utilization:
# 1. Install SGLang with Qwen3.5 hybrid Gated DeltaNet support
pip install "sglang[all]"
# 2. Launch Qwen3.5-4B target server with speculative decoding enabled
python3 -m sglang.launch_server \
--model-path Qwen/Qwen3.5-4B \
--context-length 131072 \
--mem-fraction-static 0.85 \
--port 30000
# 3. Profile decode throughput (tok/s) and acceptance length (AL) on 128K page-image prompts
python3 -m sglang.bench_serving \
--backend sglang \
--host 127.0.0.1 --port 30000 \
--dataset-name random \
--random-input-len 128000 --random-output-len 512Frequently Asked Questions
Q:Does LinearSpec change the target VLM’s output distribution?
No. Speculative decoding verifies every drafted token against the target Qwen3.5 VLM in parallel, preserving exact output fidelity while accelerating generation.
Q:How much GPU memory does LinearSpec save compared to DFlash and DSpark?
LinearSpec eliminates the draft model’s entire prompt KV cache (0 draft KV bytes) and skips draft prefill by reading the target model’s GDN states and last attention KV cache in place.
Q:How much faster is LinearSpec on 128K-token documents and agent traces?
On Qwen3.5-4B in SGLang, LinearSpec decodes 128K-token page-image documents 17% faster than DFlash and 9% faster than DSpark, and runs 20.0% faster than DFlash on >=32K agentic traces.
Q:Which Qwen3.5 model sizes does LinearSpec support?
The paper validates LinearSpec across Qwen3.5-2B, Qwen3.5-4B, and Qwen3.5-9B, showing consistent speculative speedups on both short and long contexts.
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.