Add speculative decoding training via speculators library #88
All Vouch review confidence checks passed
Residual risk 0.44 = Change Risk (0.76) × (1 − Review Confidence (0.42)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.76 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 10%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
No Reviewer Assigned
no_reviewer_assigned
0.120
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #88"
general
weight: 0.35
Maxusmusti
Summary
Adds a new
speculative_decodingalgorithm that wraps the speculators library to train Eagle3 (and other) draft models for speculative decoding inference acceleration.speculative_decodingwithspeculatorsbackendoffline,online,train_only,data_onlyvllm_gpu_ids(data-parallel vLLM) andtraining_gpu_ids(FSDP training)training_gpu_idalso supportedtrain_speculator(),eagle3(),prepare_speculator_data()Closes #86
How It Works
Speculative decoding trains a small "draft" model that predicts tokens using hidden states from intermediate layers of a large "verifier" model. The pipeline has distinct stages:
1. Data prep — tokenize dataset, build loss masks, compute token frequencies
2. Hidden state extraction — run the verifier through vLLM to extract intermediate hidden states
3. Training — train the draft model on the extracted hidden states
Pipeline Modes
Offline (default) — bulk generate hidden states, then train from disk
Online — generate hidden states on-demand during training
With user-managed vLLM endpoint (offline or online)
Train-only — from pre-existing hidden states
Single-GPU training
vLLM Management
Two options for the vLLM server used for hidden state extraction:
| Option | How | When to use |
|--------|-----|-------------|
| Managed | Set
vllm_gpu_ids=[0, 1]| Default — backend handles lifecycle || User endpoint | Set
vllm_endpoint="http://..."| Custom vLLM config, different node, or shared server |Multiple GPUs for vLLM use data parallelism — separate vLLM instances per GPU, each handling different extraction requests in parallel.
Training Modes
| GPUs | How | What happens |
|------|-----|-------------|
| Single GPU |
training_gpu_id=0| In-process training via speculatorsTrainer|| Multi-GPU |
training_gpu_ids=[2, 3, 4, 5]|torchrunsubprocess with PyTorch FSDP |Multi-GPU training uses FSDP (Fully Sharded Data Parallel) to shard the draft model across GPUs, with
DistributedCheckpointerfor saving.Key Parameters
| Parameter | Default | Description |
|-----------|---------|-------------|
|
verifier_name_or_path| required | HF model ID or path to the verifier model ||
ckpt_output_dir| required | Directory for checkpoints ||
data_path| — | Dataset path, HF ID, or"sharegpt"||
mode|"offline"|offline,online,train_only,data_only||
speculator_type|"eagle3"|eagle3,dflash,mtp,peagle||
draft_vocab_size| auto | Draft model vocabulary size ||
epochs|3| Training epochs ||
lr|1e-4| Learning rate ||
total_seq_len|2048| Sequence length ||
vllm_gpu_ids| — | GPUs for managed vLLM data-parallel (e.g.[0, 1]) ||
training_gpu_id|0| GPU for single-GPU training ||
training_gpu_ids| — | GPUs for multi-GPU FSDP training (e.g.[2, 3]) ||
max_samples| — | Max samples from dataset ||
datagen_concurrency|4 * num_vllm_gpus| Concurrent extraction requests |Output
Checkpoints are saved as full HF-compatible models via
save_pretrained():The trained model can be loaded with:
Dependencies
speculators>=0.5.0— core training library (lazy import, not required at install time)vllm>=0.20.0— only needed for hidden state extraction (not training)torch,transformers,safetensors— standard ML stackNote: For offline/data_only modes,
speculatorsmust be installed from source (editable) so thescripts/directory is available, or setSPECULATORS_SCRIPTS_PATHenv var to point to the scripts directory.Test plan
Tested with speculators 0.5.0 + vLLM 0.20.0 on 8x H100 (driver 580, CUDA 13.0):
Single-GPU (all passed):
Multi-GPU — 2x vLLM (data-parallel) + 2x training (FSDP) (all passed):
Other:
SpeculatorModel.from_pretrained()🤖 Generated with Claude Code