DynaSpec: Context-aware Dynamic Speculative Sampling for Large-Vocabulary Language Models
Zhang, Ullah, Schultheis et al.
Speculative decoding (a.k.a. speculative sampling) has become a standard way to accelerate LLM inference: a small drafter proposes multiple tokens and a large target model verifies them once per speculation length. Recently, scaling of the LLM vocabulary has pushed the number of tokens to grow substantially. While verification over the full vocabulary leaves the target model largely unaffected, the O(|V|d) parameters in the drafter's output head become a latency bottleneck, slowing the entire pipeline. Contemporary methods (e.g., FR-Spec, VocabTrim) restrict the drafter's vocabulary to a fixed subset of the target model's vocabulary, ranked in descending order of token frequency. Although this reduces draft-time compute, it is brittle, since: (i) frequency lists are corpus-dependent and require retuning to generalize, and (ii) static shortlists suppress rare or domain-specific tokens, lowering the expected number of tokens per verification step. We propose DynaSpec, a context-dependent dynamic shortlisting mechanism that is robust, speeds up drafting, and generalizes across diverse tasks. Concretely, we introduce lightweight, coarse-grained meta-classifiers that route contexts to a small number of token clusters; the union of the top-k selected clusters forms the drafter's shortlist, while verification retains the full vocabulary and exactness. The meta-classifier finishes its computation earlier than the drafter's hidden state generation by exploiting parallel execution of draft encoding and meta shortlisting on separate streams. On standard speculative-decoding benchmarks, we observe consistent gains in mean accepted length over fixed-shortlist baselines, while context-dependent selection enables smaller shortlists without degrading acceptance.
추측 디코딩(Speculative decoding)은 대규모 언어 모델 추론을 가속화하는 표준 방법이 되었습니다: 소형 초안 모델이 여러 토큰을 제안하고, 대형 목표 모델이 추측 길이만큼 한 번에 검증합니다. LLM 어휘 크기가 증가함에 따라 토큰 수가 급격히 증가합니다. 완전한 어휘에 대한 검증은 목표 모델에 미치는 영향이 적지만, 초안 모델 출력 헤드의 O(|V|d) 매개변수가 지연 병목이 되어 전체 파이프라인을 느리게 합니다. 기존 방법(FR-Spec, VocabTrim)은 초안 모델 어휘를 목표 모델 어휘의 고정 부분집합으로 제한하며, 토큰 빈도의 내림차순으로 정렬합니다. 이는 초안 시간 계산을 줄이지만 취약성이 있습니다: (i) 빈도 목록은 말뭉치에 의존하며 일반화를 위해 재조정이 필요합니다; (ii) 정적 단축 목록은 희귀하거나 도메인 특정 토큰을 억제하여 검증 단계당 예상 토큰 수를 감소시킵니다. 본 논문은 DynaSpec을 제안합니다. 이는 견고하고, 초안을 가속화하며, 다양한 작업에서 잘 일반화되는 문맥 인식 동적 단축 목록 메커니즘입니다.
대규모 언어 모델의 발전에 따라 어휘 크기가 급격히 증가합니다: Llama-2의 32k 토큰에서 Llama-3의 128k, DeepSeek-V3의 129k, Qwen-2.5의 152k, 심지어 Gemma-3의 262k 토큰으로 증가합니다. 추측 디코딩에서 대형 목표 모델은 완전한 어휘의 계산 부담을 견딜 수 있지만, 소형 초안 모델의 출력층 O(|V|d) 매개변수가 심각한 지연 병목이 됩니다.
논문은 추측 디코딩, 대규모 어휘 LLM, 극단 분류 등 관련 분야의 중요한 연구를 인용하여 방법 설계에 견고한 이론적 기초를 제공합니다. 주요 참고문헌에는 EAGLE 시리즈, FR-Spec, 그리고 극단 분류의 LightXML 및 CascadeXML 등의 연구가 포함됩니다.