Editor’s introduction
LinearSpec, a speculative decoding method, reads from the memory of hybrid vision-language models rather than maintaining its own key-value cache. It begins with the model’s top layers, using the existing Gated DeltaNet states and attention layer caches to generate drafts. The method requires a hybrid model with a full-attention layer at the top and was tested only on Qwen3.5 variants using A100 GPUs.
Introduction
Vision-language models (VLMs) increasingly read long inputs: documents and subtitled videos fill tens of thousands of tokens, and each new token requires a memory-bound pass over this context. Speculative decoding reduces the number of these passes. A small drafter proposes several tokens, and the target model verifies them in one forward pass and keeps the longest accepted prefix, so the target’s output is unchanged. Block drafters such as DFlash and DSpark propose a whole block in one pass and are among the fastest drafters on short prompts.
We call these states and caches the target’s memory and propose LinearSpec, which reads them in place (Figs. 1a and 2). It inherits the target’s top four layers, continues the GDN states and reads the layer-31 KV cache, with no draft KV cache or drafter prefill. An entry projection estimates the input of layer 28, a successor read and a context pointer fetch what followed earlier matches in context, and a sequential GDN head conditions each draft on earlier ones.
Prior drafters reuse either the target’s KV cache or its states (Tab. 1)
On hybrids of attention and recurrent layers such as Qwen3.5, prior work speeds up verification or drafts for other targets; an untrained self-drafter built from Qwen3.5-0.8B’s GDN layers has under 4% of its drafts accepted. GliDe cross-attends to the target’s KV cache, and LongSpec adds a 512-token self-attention window for long contexts. An EAGLE-style drafter that reads the target’s KV cache improves long-range retention but only marginally speeds up decoding. Gemma 4’s MTP drafters share the target’s KV cache in all their layers, but Gemma 4 has no recurrent state. H-Spec and DLite keep no draft KV cache but target dense text models: H-Spec reads the target’s KV cache in place and projects its Mamba state from target hidden states, and DLite rebuilds its draft state from the latest target hidden states each round. ReaDy feeds a hybrid target’s committed GDN states into its last layer through rank-8 queries, without advancing them, and keeps a draft KV cache. FLARE seeds block diffusion from the recurrent state but converts the target into a diffusion model. Self-speculative methods draft with the target’s lower layers or skip layers. Hidden Transfer and FIRP linearly map intermediate hidden states to future tokens and run them through the target’s upper layers; LinearSpec instead fine-tunes copies of these layers on the target’s memory.
Benchmarks
Long multimodal has 216 prompts at 128K tokens: document QA from MMLongBench (100) and GovReport reports (60), both as page images, and dialogue summaries of Video-MME long videos with subtitles (56). A separate set of multi-page documents, 32 at each of 8K, 32K, 64K and 128K, is used in the analyses, and further long-video sets are in Sec. D.1. Long text has 350 prompts in 7 families, 70 at each of 8K, 16K, 32K, 64K and 128K tokens; one family, synthetic retrieval, asks for a random string stated once far back. Some analyses use a fixed 105-prompt subset, 5 per family at 8K, 32K and 128K. Agents has 288 coding-agent, tool-calling and web-browsing prompts at 8K to 128K tokens, 216 of them at 32K or more. Short text has 150 math, code and chat turns for speed and AL in Tab. 2, and the short-prompt AL set has 1,263 prompts for AL in the analyses. Single images has four standard sets with 324 prompts (Sec. C.4).
Limitations
LinearSpec needs a hybrid target with a full-attention layer among its top layers; we test only Qwen3.5 (2B–9B) on A100 GPUs in SGLang and report decode speed at batch size 1. DSpark and DFlash+GDN head are faster on short text, and DSpark also on single images.
Training sets and packing
The text samples are split by length into a short set and a long set, which feed the short and long training phases (Sec. B.2). The short set contains the 1,160,869 samples of at most 8,192 tokens (1.80B tokens). The long set contains the 64,377 longer samples plus 116,441 replayed short samples (180,818 samples, 996M tokens). The long samples come from the long-context prompts and from long thinking, math and code responses. LongWriter-6k responses average about 2K tokens, so they mostly stay in the short set. The last 2% of each set is held out for validation. Short samples are packed into 8,192-token sequences (about 222K per epoch) and long samples into 40,960-token sequences. Packed samples keep their document boundaries. Each drafter attends only within the document of the anchor (the block start, Sec. B.3). GDN states and convolution histories reset at every document start, and the target’s hidden states are computed separately for each sample. The packing sampler has a fixed seed, so every drafter sees the same sequences in the same order.
Deduplication and contamination checks
Text prompts are deduplicated by exact match of their whitespace-normalized text. A prompt is dropped if any of its user turns is already in the mix or in an evaluation set. We also drop prompts that share a word 13-gram with a prompt of the short-text benchmarks (MT-Bench, GSM8K, MATH-500, HumanEval, MBPP, SPEED-Bench) or of our held-out evaluation splits. Two parts of the mix use a narrower filter. Prompts reused from an earlier version of the mix are deduplicated by id only. The 18,147 code samples and the function-level code prompts are checked against the benchmarks only.
An image is dropped if its exact pixel hash or its 256-bit perceptual difference hash (dHash; within 10 bits) matches an image of the full ChartQA test, ScienceQA-IMG test, MathVista testmini, LLaVA-Bench, TextVQA val or COCO Caption val splits. This drops 4,404 images. We also drop 375 prompts whose question equals an evaluation question, and keep one prompt per image. The image filter above does not cover the four single-image sets of Tab. 2. We therefore compare the multimodal-phase training images with every image of these sets and of HR-Bench, and with every page and sampled frame of the long-document and long-video sets except MLVU. Four MM-Vet images and one slide in one document-QA prompt match training images. The reported results include them; excluding them changes no reported lead by more than 0.5 points.
Training phases
Training on the target’s responses has three phases (Tab. 8): a short and a long phase on text, then a multimodal phase. All phases use AdamW (Tab. 9). Each step trains one packed sequence per trainer GPU, without gradient accumulation. The other GPUs of each 8-GPU host run the vLLM server. Each phase starts from the final checkpoint of the previous phase, with a fresh optimizer and its own warmup and cosine schedule. The target, the token embedding, the final norm and the LM head stay frozen. LinearSpec’s inherited layers start from the target’s weights and train at 0.1 times the peak learning rate, except the key and value path of layer 31, which stays frozen. All other drafter parameters train at the full rate. For the 75K-prompt ablations (Tab. 5), we take a fixed 9.2% hash slice of the 817,074-prompt base set (Sec. A.2), about 75K prompts. The slice has no thinking responses and none of the later additions. These runs drop responses that hit the 8,192-token cap. We train the 75K LinearSpec and DFlash with three training seeds and the intermediate ablation drafters of Tab. 5 with one. Where a 75K drafter goes through a multimodal phase (Secs. E.7 and F.7), that phase is the multimodal phase of Tab. 8 shortened to one epoch.
Qwen3.5-2B
The 2B target has 24 layers (full attention at layers 3, 7, …, 23), hidden size 2,048 and 2 KV heads per attention layer. LinearSpec inherits layers 20–23, and its entry projection reads the KV rows of attention layers 19 and 23. DFlash fuses the hidden states of layers 2, 5, 8, 11, 13, 16, 19 and 22. The 2B target regenerates the same prompts with the same settings. Its chat template defaults to non-thinking, so every request sets the thinking mode explicitly. LinearSpec, DFlash and DSpark follow the 4B recipe and anchors (Sec. B.3). The 2B short phase splits each sequence’s anchors across two GPUs, so its 24 trainer GPUs keep the 4B global batch of 12 sequences. On the 2B target, LinearSpec is faster than DSpark on the long sets of Tab. 2 except long text at 8K, although the Video-MME interval includes 0 (Tab. 11). After the multimodal phase, it is also significantly faster than DSpark at the longest length of three of the six further sets of Tab. 12 (Sec. C.4): by 19.0% on multi-page documents (128K), 34.5% on document QA (64K) and 18.3% on the Video-MME quote-summary set. On VDC and LVBench it is 0.7% and 2.8% slower. No task-score difference on the 2B target is significant: every 95% confidence interval (CI) on the text and multimodal sets includes 0, both for each drafter versus autoregressive decoding and for LinearSpec versus DSpark.
Qwen3.5-9B
The 9B target has the same layout as the 4B (32 layers, full attention at layers 3, 7, …, 31), with hidden size 4,096, 4 KV heads per attention layer and an untied embedding and LM head. LinearSpec inherits layers 28–31, and its entry projection reads the KV rows of attention layers 27 and 31 (1,055M trainable parameters). DFlash fuses the hidden states of layers 2, 6, …, 30 and keeps six draft layers at the target’s width (1,292M parameters), as in the released 9B DFlash. Both layer choices follow the 4B setup. Both drafters train on the 1.2M prompts, with responses regenerated by the 9B target. They use the 4B schedule, anchors and multimodal phase. On the 9B target we also trained DSpark with the same recipe (1,419M parameters). On 9B, Tab. 2 compares LinearSpec with DFlash only; 9B DSpark results are in Tabs. 11 and 16.
Implementation
All drafters in Tab. 2 (LinearSpec, DFlash and DSpark, each also in its multimodal version) run a fused draft path in SGLang. DFlash (released), DFlash (full attn.) and DFlash+GDN head run the same fused DFlash path. DFlash+GDN head adds LinearSpec’s head kernel, without the pointer but with the same 65,536-token fp8 table. Stock SGLang DSpark, EAGLE-3 and the MTP head run unmodified SGLang code and serve only as references. The fused DFlash path keeps the stock checkpoint format and DFlash worker but replaces the draft forward pass with our Triton kernels. These kernels fuse each norm with the preceding residual add and with the reduction of split-K matrix-multiply partials. The path also skips the stock draft runner’s per-round batch and attention-metadata setup. Capturing the draft step in a CUDA graph and folding its greedy head into the graph are stock SGLang features. The fused DSpark path runs DSpark’s head on the fused DFlash backbone in the same graph and picks each draft from 512 candidate tokens instead of the full vocabulary. LinearSpec’s head is one persistent kernel that runs the 15 sequential head steps (one per draft slot) in a single launch, with the fp8 logit-bias table of the 65,536 most frequent tokens split across the shared memory of all streaming multiprocessors (SMs). The 15 steps take 0.35 ms, compared with 0.80 ms for a persistent Triton loop and 3.90 ms for a PyTorch loop.
At batch size 1, the fused paths speed up the baselines and narrow LinearSpec’s lead. Fused DFlash decodes 14.1% faster than stock SGLang DFlash on short text at equal AL, and between 2% slower and 4% faster on long text. Fused DSpark decodes 23% faster than stock SGLang DSpark on short text and 18% faster on long text, with an AL within 2% of stock DSpark’s. On short text, LinearSpec is 1.2% faster than fused DFlash (Tab. 17 and Tab. 3); combined with the 14.1% above, this puts it about 15% ahead of stock SGLang DFlash.
End-to-end time on the long multimodal sets
Decode speed excludes prefill. On the 216 long multimodal prompts, the mean time to first token is 22 s for LinearSpec, DFlash and DSpark (LinearSpec and DFlash within 0.6%). This time covers the server’s image processing, the vision encoder and the target’s prefill. Decoding accounts for 9.7% of wall-clock time with LinearSpec, 10.9% with DFlash and 10.3% with DSpark, and for 20.5% with autoregressive decoding. In these runs, DFlash takes 14.8% more time decoding than LinearSpec. This differs from the 15.4% decode-speed gain of Tab. 2 because the two drafters’ output lengths differ slightly. DFlash’s drafter prefill adds 0.1–0.2 s per request. Over the 216 requests, total wall-clock time is 2.0% shorter with LinearSpec than with DFlash. By set, DFlash takes 0.8% longer on document QA, 2.3% on GovReport and 3.0% on Video-MME long with subtitles. In a separate paired run, autoregressive decoding takes 10.6% more total wall-clock time than LinearSpec. The end-to-end gain scales with the decode share, which grows with output length. Section E.11 varies the output length directly.
Multi-turn conversations with prefix caching
We run four five-turn conversations with SGLang’s prefix cache on, over whole MMLongBench-Doc documents given as page images (about 124K tokens each). From the second turn on, at least 99.7% of each prompt hits the cache, so the target skips the KV and GDN-state prefill of the document and processes only the new question. On turns 2–5, LinearSpec decodes 12.4% faster than DFlash with both drafters before the multimodal phase, and 15.3% faster with both after it. Over all turns, the gains are 11.7% and 15.9%. End-to-end time per conversation differs by less than 3% between the drafters, and time to first token makes up 93% of each cached turn. SGLang’s API is stateless: with each turn, the client resends the whole conversation, including the preprocessed page images (about 1.5 GB of pixel values per document), and the server loads and hashes them again before matching them in the cache. This extra work is the same for both drafters. A cached turn still needs about 6.8 s to the first token, compared with 24.3 s for the uncached first turn. About 90% of these 6.8 s pass before the forward pass starts, and the forward pass itself prefills the roughly 160 new tokens in about 0.6 s.
Serving with many requests
With 32 concurrent 32K-token text requests, LinearSpec admits 29 requests against DSpark’s 16. Requests whose KV cache does not fit wait in the queue; with more requests admitted, the mean time to first token falls from 41.5 s (DSpark) to 18.6 s. With 8 concurrent 128K multimodal requests, LinearSpec admits 6 against 4, and the mean time to first token falls from 82 s to 70 s. Total serving throughput rises by only 7.7% and 5.0% over DSpark. At full load the GPU is compute-bound, and the long prefills take the same time for both drafters.
The pool ratio follows from the per-token KV size. The target’s 8 attention layers store 32 KiB per token, and the draft layers of DFlash or DSpark add another 24 KiB. At the same memory capacity, this leaves LinearSpec about 1.75 times the tokens, minus its fixed drafter memory. SGLang stores all six draft layers of DFlash and DSpark at full length. If the pool kept the five windowed layers only over their last 4,096 positions, the pool-size gap at 32 concurrent requests would shrink from 72% to about 18% against DFlash, and from 73% to 19% against DSpark. Even then, for these 32K-token text requests, LinearSpec’s pool would hold about 18% more tokens, because the baselines still cache the unwindowed layer and the 4,096-position windows.


