Architecture
~8 min readUpdated: December 2026

Spancast: Native Speculative Decoding for Coding Agents

Spancast native draft architecture for coding speculative decoding in Smoke Monkey

Spancast (arXiv:2612.05048) is a 98.6M-parameter non-Transformer speculative draft architecture built for coding agents. Combining Grouped State Channel recurrence, Null-Key Attention, and constant-depth Masked Parallel Tree Decoding, Spancast hits 8.30 accepted tokens per step on Falcon3-7B and 10.14 on Coding Core across 17 zero-shot target models.

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

Spancast: Native Speculative Decoding for Coding Agents: Spancast (arXiv:2612.05048) is a 98.6M-parameter non-Transformer speculative draft architecture built for coding agents. Combining Grouped State Channel recurrence, Null-Key Attention, and constant-depth Masked Parallel Tree Decoding, Spancast hits 8.30 accepted tokens per step on Falcon3-7B and 10.14 on Coding Core across 17 zero-shot target models. 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 Examplespancast-coding-agent.ts
spancast-coding-agent.tstypescript
import { createAgent } from '@smoke-monkey/harness';
// High-throughput coding agent backed by speculative tree verification
const agent = createAgent({
agentId: 'spancast-fast-coder',
provider: 'openai-compatible',
baseUrl: 'http://127.0.0.1:30000/v1',
model: 'Qwen/Qwen3-8B',
workspacePath: process.cwd(),
permissions: {
read_file: 'allow',
write_file: 'allow',
run_command: 'ask',
},
});
async function main() {
const result = await agent.run(
'Generate a TypeScript AST visitor for extracting MCP tool parameter schemas and verify with tsc --noEmit.'
);
console.log('Spancast Coding Output:', result.summary);
}
main().catch(console.error);
Video Guides

Watch: Related Video Guides

AI Lab: Open-source inference with vLLM + SGLang | Optimizing KV cache with Crusoe Managed Inference

Serve Your Own LLM: vLLM & SGLang, End-to-End

What Is Spancast and Why Do Standard Drafters Underperform on Code?

Spancast (arXiv:2612.05048) is a 98.6M-parameter target-agnostic speculative draft architecture engineered for executable code generation. Replacing stateless Transformer FFNs with a unit-norm Grouped State Channel (GSC) and Null-Key Attention, Spancast pairs with Masked Parallel Tree Decoding to draft long multi-branch code spans in constant step depth.

Executable code consists of deterministic syntactic scaffolding and repeated identifiers interrupted by sharp semantic branch points. Autoregressive drafters incur latency linear in span length, retrieval methods (SuffixTree, REST, Prompt Lookup) stall when identifiers vary slightly, and feature-coupled drafters like EAGLE-3 break whenever you upgrade the target model. In controlled 100M-parameter comparisons, Spancast achieves a longer expected accepted chain (7.04) and tree length (8.70) than Transformer (8.30), Mamba-2 (8.36), and RWKV-7 (8.56) backbones.

Target Model (Zero-Shot Transfer)Autoregressive τ (ITL)SuffixTree τ (ITL)Prompt Lookup τ (ITL)Spancast (B=16) τ (ITL)
SmolLM3-3B1.00 (3.36 ms/tok)3.40 (1.92 ms/tok)2.15 (2.47 ms/tok)8.17 (1.08 ms/tok)
Phi-4-mini1.00 (3.80 ms/tok)3.24 (2.48 ms/tok)2.04 (2.93 ms/tok)7.81 (1.30 ms/tok)
Falcon3-7B1.00 (5.79 ms/tok)3.15 (3.08 ms/tok)1.91 (4.32 ms/tok)8.30 (1.50 ms/tok)
OLMo-2-7B1.00 (6.03 ms/tok)2.72 (3.51 ms/tok)1.77 (4.66 ms/tok)6.79 (1.80 ms/tok)
17-Model Coding Core Mean1.00——10.14 (1.82 ms/tok)

Tuning Branch Width (B=16) and Verifying Speculative Speedups in SGLang/vLLM

Masked Parallel Tree Decoding eliminates sequential rollout by running a parallel span prediction followed by a causal path-scoring pass and two-level masked branch completion. Raising branch width from B=4 (τ=6.91, 2.97 ms/tok) to B=16 (τ=7.80, 2.64 ms/tok) monotonically improves both acceptance length and wall-clock latency across 3B–32B models:

bash
# Benchmark speculative acceptance length and ITL in SGLang on coding prompts
python3 -m sglang.launch_server \
  --model-path Qwen/Qwen3-8B \
  --speculative-algorithm EAGLE3 \
  --speculative-num-steps 5 \
  --speculative-num-draft-tokens 16 \
  --port 30000

# Measure mean inter-token latency (ITL) on HumanEval+ / LiveCode streams
python3 -c '
import time, requests
t0 = time.perf_counter()
r = requests.post("http://127.0.0.1:30000/v1/completions", json={
  "model": "Qwen/Qwen3-8B",
  "prompt": "def merge_intervals(intervals: list[list[int]]) -> list[list[int]]:
",
  "max_tokens": 256,
  "temperature": 0.0
}).json()
dt = (time.perf_counter() - t0) * 1000
toks = r["usage"]["completion_tokens"]
print(f"Tokens={toks}, Total={dt:.1f}ms, ITL={dt/max(1,toks):.2f} ms/tok")
'

Do Not Stop at Flat Parallel Spans

In Spancast ablations, Stage-0 flat spans alone drop acceptance length from 7.80 down to 4.45 (4.34 ms/tok ITL). Always enable Stage-1 causal path scoring and B=16 masked branching for coding workloads.

Google Search Questions & Answers

Frequently Asked Questions

Q:How does Spancast work zero-shot across 17 different target models?

Unlike feature-coupled drafters such as EAGLE-3 that read internal target hidden states, Spancast operates purely at the token/span level with Grouped State Channel and Null-Key Attention, enabling zero-shot transfer across 15 model families.

Q:What is Null-Key Attention in Spancast?

Null-Key Attention inserts a learnable zero-value key with continuous phase shifts so attention heads can cleanly skip irrelevant prefix tokens on unseen tokens while retaining exact identifier copying.

Q:How fast is Spancast on coding benchmarks?

Across 17 target models, Spancast averages 10.14 accepted tokens per step at 1.82 ms/tok on Coding Core benchmarks and reaches 1.08 ms/tok on SmolLM3-3B.

Q:Why does Spancast outperform retrieval-based speculative decoding on code?

Retrieval baselines like SuffixTree and REST can only copy exact prior substrings, whereas Spancast predicts generalized structural spans and branches around novel variable names.

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