Architecture
~8 min readUpdated: December 2026

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

LinearSpec in-place Gated DeltaNet speculative decoding for 128K VLMs in Smoke Monkey

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.

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

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.

Key Architectural Takeaways
Quick Implementation Examplelinearspec-sglang-vlm-agent.ts
linearspec-sglang-vlm-agent.tstypescript
import { createAgent } from '@smoke-monkey/harness';
// Long-context multimodal document agent backed by SGLang + LinearSpec speculative decoding
const 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);
Video Guides

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 ArchitectureParamsReads Target KV?Uses Target GDN State?Separate Draft KV?Qwen3.5-4B Short Text SpdQwen3.5-4B 128K Doc Advantage
DFlash634MNoNoYes (VRAM overhead)3.79x (AL 6.42)Baseline
DSpark634MNoNoYes (VRAM overhead)4.13x (AL 7.14)+8% behind LinearSpec at 128K
LinearSpec617MRead in placeRead & advancedNone (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:

  1. Entry State Projection: For each accepted token, LinearSpec concatenates the target's top-layer keys/values and three GDN states into z_a and projects them into the drafter's four layers (three GDN layers plus one full-attention layer).
  2. 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.
  3. 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:

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

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