Accelerate LLM inference 1.5-2x using a universal draft model that adapts to user data in real-time, handling different target models and tokenizers via online n-gram cache and hybrid distillation.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
A direct command skips the review prompt. Inspect the source before running it.
Accelerate LLM inference 1.5-2x using a universal draft model that adapts to user data in real-time, handling different target models and tokenizers via online n-gram cache and hybrid distillation.
OmniDraft: Universal and Adaptive Speculative Decoding
Speculative decoding accelerates LLM inference by using a small draft model to generate multiple tokens, which are verified by the target model in parallel. However, deploying this approach on-device faces challenges: (1) draft models trained for one target model may not work with another, and (2) user-specific data causes distribution shift over time. OmniDraft addresses both through a single universal draft model (Llama-68M) that works with any target model via cross-vocabulary token mapping, and online knowledge distillation that continuously adapts the drafter to user data without explicit retraining.
The key innovations are an online n-gram cache that translates between different tokenizer vocabularies, and a hybrid loss combining token-level and distribution-level distillation that updates the drafter as it processes user data. This enables 1.5-2x speedup across reasoning, coding, and text generation tasks on consumer hardware.
Core Concept
OmniDraft operates on two principles: (1) vocabulary-aware adaptation through n-gram caches that learn token mappings between drafters and targets, and (2) online learning that improves the drafter continuously as it encounters user data. Rather than training separate drafters for each target model or retraining when deployment contexts change, a single universal drafter becomes increasingly specialized to its deployment context through lightweight online updates.
The n-gram cache maintains learned mappings showing which draft tokens typically correspond to which target tokens, enabling effective translation even with completely different vocabularies. Online distillation ensures the drafter learns patterns specific to the user's domain without catastrophic forgetting of general knowledge.
Architecture Overview
The system comprises several interconnected components:
Universal Draft Model: Lightweight Llama-68M serving as single drafter for multiple targets
N-gram Cache: Learned bijection between draft and target token sequences, enabling vocabulary translation
"""
Learn mappings between draft and target model vocabularies.
Maintains an n-gram cache storing which target token sequences
typically follow draft token sequences, enabling cross-vocabulary adaptation.
"""
self, draft_sequence: List[int], target_token: int
"""
Record mapping from draft token sequence to target token.
Updates n-gram statistics: "when we see these draft tokens,
the target often outputs this token next."
"""
# Use last n-1 draft tokens + current draft token as key
if
len
self
tuple
self
1
else
tuple
self
1
self
1
# Evict old entries if cache exceeds size
if
len
self
self
self
def
get_mapping
self, draft_sequence: List[int],
top_k: int = 5
List
Tuple
int
float
"""
Get predicted target tokens given draft sequence.
Returns list of (token_id, probability) pairs ranked by likelihood.
"""
if
len
self
tuple
self
1
else
tuple
if
not
in
self
# Unknown sequence; no mapping available
return
# Get distribution of target tokens
self
sum
for
in
sorted
lambda
1
True
return
def
_evict_cold_entries
self
"""Remove least-accessed n-gram patterns to stay within cache budget."""
# Compute frequency of each n-gram
for
in
self
sum
# Remove bottom 10% by frequency
len
self
10
sorted
lambda
1
for
in
del
self
class
VocabularyAdapter
"""
Adapt draft model vocabulary to target model vocabulary.
Uses n-gram cache to translate draft tokens to target tokens,
handling vocabulary mismatch transparently.
"""
def
__init__
self, draft_vocab_size: int, target_vocab_size: int,
hidden_dim: int = 768
super
self
self
# Learned projection from draft embeddings to target space