Inferensys

Glossary

Candidate Sequence

A candidate sequence is the ordered list of tokens generated by a draft model for verification by a target model in speculative decoding.
ML engineer working on model compression and quantization, laptop showing performance benchmarks, technical workspace.
SPECULATIVE DECODING

What is a Candidate Sequence?

In speculative decoding, a candidate sequence is the core speculative output that enables parallel verification.

A candidate sequence is the ordered list of tokens generated by a smaller, faster draft model for parallel verification by a larger, more accurate target model in speculative decoding. This sequence, typically of a fixed length called the speculative factor (gamma), is the fundamental unit of speculation. Its quality, measured by the acceptance rate, directly determines the speedup factor achieved by avoiding the target model's slower autoregressive generation for those tokens.

The target model performs a single verification forward pass on the entire candidate sequence, scoring each token against its own probability distribution. Accepted tokens are appended to the output, while a rejection triggers a rollback mechanism and autoregressive correction. Optimizing the candidate sequence—through draft model distillation, confidence thresholding, or dynamic draft selection—is critical for maximizing throughput while minimizing the latency-accuracy tradeoff inherent to this inference acceleration technique.

SPECULATIVE DECODING

Key Characteristics of a Candidate Sequence

In speculative decoding, a candidate sequence is the ordered list of tokens proposed by a draft model. Its properties directly determine the efficiency and success of the verification step performed by the target model.

01

Fixed-Length Proposal

A candidate sequence is generated with a predetermined length, known as the speculative factor (γ). This is a key hyperparameter, typically ranging from 3 to 10 tokens. The draft model generates exactly γ tokens in a single, fast autoregressive pass. This fixed length allows the target model's verification forward pass to be perfectly batched, enabling parallel scoring of all γ candidates against the model's own predictions.

02

Conditional Probability Chain

The sequence is generated autoregressively by the draft model, meaning each token is predicted based on the original context and all previously generated candidate tokens. Formally, for a context x, the candidate sequence (y1, y2, ..., yγ) is sampled from the draft model's distribution: P_draft(y1 | x) * P_draft(y2 | x, y1) * ... * P_draft(yγ | x, y1, ..., yγ-1). This chain rule of probability is fundamental to its structure.

03

Verification via Parallel Scoring

The core purpose of the candidate sequence is to be verified in parallel by the target model. Instead of running γ separate forward passes, the target model performs one batched forward pass. It takes the context x and the entire candidate sequence as input, using a tree attention or similar mechanism to efficiently compute the target model's probability for each candidate token in its correct position: P_target(yi | x, y1, ..., yi-1) for all i from 1 to γ.

04

All-or-None Prefix Acceptance

Verification is not token-by-token independent. The target model accepts a prefix of the candidate sequence. It compares its own probability P_target(yi | ...) to the draft's probability P_draft(yi | ...) for each position i, starting from the first token. Acceptance continues sequentially until the first token where P_target(yi) is less than or equal to P_draft(yi). All tokens before this point are accepted; the first mismatched token and all following are rejected. This leads to the rollback mechanism.

05

Computational Leverage

The sequence creates computational leverage. The cost of generating γ tokens with the small draft model plus the cost of one parallel verification pass with the large target model must be less than the cost of generating γ tokens autoregressively with the large target model alone. This is the fundamental equation for speedup: Cost(draft γ tokens) + Cost(verify γ tokens) < γ * Cost(target 1 token). The candidate sequence is the vehicle for this batched computation.

06

Quality-Speed Tradeoff Artifact

The sequence embodies the latency-accuracy tradeoff of speculative decoding. A longer sequence (higher γ) offers greater potential speedup but risks a lower acceptance rate, as the draft model's predictions diverge further from the target's over longer horizons. The sequence's content is a direct product of the draft model's capability; a poorly aligned draft model generates low-quality candidates that are frequently rejected, negating the speedup benefit. Techniques like draft model distillation aim to improve candidate sequence quality.

INFERENCE OPTIMIZATION

Candidate Sequence vs. Standard Autoregressive Generation

A comparison of the speculative decoding workflow, which uses a candidate sequence, against the traditional token-by-token generation method.

Feature / MetricStandard Autoregressive GenerationCandidate Sequence (Speculative Decoding)

Core Mechanism

Generates one token per sequential forward pass.

Drafts a multi-token candidate sequence, then verifies all tokens in one parallel forward pass.

Model Invocation Pattern

Strictly sequential; N tokens require N serial calls to the target model.

Two-phase: 1) Draft model runs autoregressively, 2) Target model verifies batch in parallel.

Theoretical Speedup

1x (baseline).

Up to 2-3x, dependent on acceptance rate and hardware parallelism.

Primary Bottleneck

Memory bandwidth (KV cache reads) and sequential latency.

Draft model latency and verification cost of the batched forward pass.

Output Fidelity

Exactly follows the target model's autoregressive distribution.

Identical to target model when all tokens accepted; may diverge slightly on rejection due to rollback.

GPU Utilization

Often low due to serial execution, especially for small batch sizes.

Higher, due to parallel verification of the candidate sequence, improving compute saturation.

Memory Access Pattern

Predictable, sequential reads/writes to the KV cache.

Irregular; requires speculative KV cache management and potential rollback state discards.

Optimal Use Case

Low-latency, single-stream generation where correctness is paramount.

High-throughput batch inference or latency-sensitive applications with a suitable draft model.

SPECULATIVE DECODING

Frequently Asked Questions

A candidate sequence is the core data structure in speculative decoding. These questions address its role, generation, and impact on inference performance.

A candidate sequence is the ordered list of future tokens proposed by a smaller, faster draft model for parallel verification by a larger, more accurate target model.

It is the central mechanism that enables speculative decoding's speedup. Instead of the target model generating one token at a time autoregressively, the draft model rapidly generates a short sequence of k tokens (e.g., 3-5). This sequence is then presented to the target model in a single, batched verification forward pass. The target model scores each proposed token against its own probability distribution, accepting correct tokens and rejecting the first incorrect one. The acceptance rate of these candidate tokens directly determines the overall speedup factor of the inference process.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.