SPEC-Distill: Towards Efficient Speculative Distillation for Reinforcement Learning with Verifiable Rewards
Bingshuai Liu1,2*, Ante Wang1,2*, Zijun Min1,2*, Jiajun Cao1,2
Haibo Zhang3, Liang Yao3, Shuman Liu3, Anxiang Zeng3, Jinsong Su1,2†
1 School of Informatics, Xiamen University
2 Key Laboratory of Digital Protection and Intelligent Processing of Intangible Cultural Heritage
of Fujian and Taiwan (Xiamen University), Ministry of Culture and Tourism, China
3 Independent Researcher
* Equal contribution † Corresponding author
bsliu@stu.xmu.edu.cn · jssu@xmu.edu.cn
Code · Installation · Training · Evaluation
SPEC-Distill moves teacher guidance offline, keeping online reinforcement learning student-only. Built on verl, it introduces teacher knowledge through speculative rollout construction and trains the student with verifiable rewards and GRPO.
SPEC-Distill separates teacher guidance from the online training loop:
- Build an expert cache once. Generate teacher drafts and token log-probabilities offline with Qwen3-14B. The same cache can support multiple student sizes.
- Warm up with teacher prefixes. The student verifies cached drafts, retains the prefix before the first rejection, and generates the continuation.
- Continue with student self-reuse. After the teacher-prefix phase, reuse refreshed student rollouts as drafts. Apply verifier rewards and the standard GRPO update throughout online training.
The provided configurations cover Qwen3-1.7B, 4B, and 8B students, alongside vanilla GRPO and Luffy baselines.
Use a CUDA environment compatible with verl 0.5.x and vLLM 0.9.1. A starting Docker image is:
verlai/verl:app-verl0.5-vllm0.9.1-mcore0.12.2-te2.2
Alternatively, prepare the dependencies following the verl 0.5.x installation guide.
Download the code and install the additional dependencies inside your environment:
git clone https://github.com/XMUDeepLIT/SPEC-Distill.git
cd SPEC-Distill
pip install -r requirements.txt
pip install math-verify antlr4-python3-runtime==4.9.3
export PROJECT_DIR="$PWD"
export WORKING_DIR="$PROJECT_DIR"
export PYTHONPATH="$PROJECT_DIR${PYTHONPATH:+:$PYTHONPATH}"Run training from the repository root so Python uses the bundled verl implementation. This checkout does not include a root setup.py or pyproject.toml, so pip install -e . is not an installation step here.
The example launchers are configured for multi-GPU training, typically eight GPUs. Adjust GPU visibility, tensor parallelism, batch sizes, and memory utilization for your hardware.
vLLM vocabulary patch: Several launchers actively call sudo bash training_scripts/fix_vllm_oov.sh. Review this call before launching and comment it out if your environment does not need the vLLM 0.9.1 vocabulary patch.
export MODEL_PATH=/path/to/models
export SAVE_PATH=/path/to/checkpoints
export SPEC_DISTILL_EXPERT_DATA_DIR=/path/to/offline_teacher_rolloutsMODEL_PATH is a parent directory: the launchers load models from paths such as $MODEL_PATH/Qwen3-1.7B and $MODEL_PATH/Qwen3-14B. Download the corresponding model weights before running.
Datasets, generated teacher rollouts, and checkpoints are not bundled. The supplied non-thinking launchers expect this layout:
data/
└── distill-data/
├── train_sample_no_think.parquet
├── train_sample_part_1_no_think.parquet
├── train_sample_part_2_no_think.parquet
├── train_sample_part_3_no_think.parquet
├── train_sample_part_4_no_think.parquet
├── train_sample_part_5_no_think.parquet
├── train_sample_part_6_no_think.parquet
└── test.parquet
The full training file is used by student training; the six partitions are used by the offline teacher-generation launcher. Prepare these as verl-compatible parquet datasets, keeping the teacher inputs aligned with the student training examples. To use a different layout, edit --dataset_name and --train_file_name in the selected launcher. The shared backends read data/<dataset_name>/<train_file_name>.parquet and data/<dataset_name>/test.parquet.
bash training_scripts/distill-data-generation/qwen-3-distill-14b-no-think.shThe launcher runs Qwen3-14B over the six training partitions. Before student training, organize the generated rollout artifacts into the directory configured for 14b-no-think-16k in the expert registry. The registry resolves paths relative to SPEC_DISTILL_EXPERT_DATA_DIR; update its path field to match your cache location.
Check the available entries and resolved path:
python3 training_scripts/resolve_expert.py --list
python3 training_scripts/resolve_expert.py 14b-no-think-16kThe cache-linking helper expects paired .jsonl and .pt files with stems -1, -2, -3, -4, -5, and 0. Ensure these artifacts are present before training. At launch, init_expert_files.sh links them into rollouts/<run_name>/.
Choose the launcher for your student model:
# Qwen3-1.7B
bash training_scripts/spec-distill/1.7B-think-14B-non-think.sh
# Qwen3-4B
bash training_scripts/spec-distill/4B-think-14B-non-think.sh
# Qwen3-8B
bash training_scripts/spec-distill/8B-think-14B-non-think.shDespite the think segment in the filenames, these launchers select the 14b-no-think-16k teacher cache. Their shared backend is train_grpo-spec-distill-warm-up.sh.
The main SPEC-Distill options are:
--expert_id: select a teacher cache from the registry.--spec_decoding True: enable speculative prefix reuse.--spec_warmup_epoch 1: use teacher prefixes for the initial epoch.--warmup_bias 4.0: set the teacher-prefix log-lenience, corresponding to a lenience factor ofexp(4.0).--bias 0.5: set the subsequent speculative-phase log-lenience, corresponding toexp(0.5).
# Vanilla GRPO; 4B and 8B launchers are in the same directory
bash training_scripts/vanilla-grpo/1.7B-grpo-non-think.sh
# Luffy; a 4B launcher is also provided
bash training_scripts/luffy/1.7B-luffy-deepmath-non-think-qwen3-14b.shReview the dataset and teacher-cache settings in each baseline launcher before running.
Training defaults to console logging. To enable Weights & Biases, run wandb login and change the logger override in the relevant shared training backend to:
trainer.logger=['console','wandb']
Set PROJECT_NAME in the selected launcher to organize your runs.
The math evaluation harness follows the SPEC-RL / SimpleRL-Reason setup.
Configure your checkpoint run and base model, then launch:
export CHECKPOINT_DIR=/path/to/checkpoint_run
export INIT_MODEL=/path/to/models/Qwen3-1.7B
bash training_scripts/eval/start_spec_distill.shThe checkpoint run directory should contain global_step_*/actor/huggingface subdirectories. The launcher evaluates:
- MATH500, GSM8K, OlympiadBench, and MMLU-STEM with one sample per problem.
- AIME24 and AIME25 with 32 samples per problem.
- AMC23 with 16 samples per problem.
Results are written under the checkpoint run directory in eval_results, eval_results_avg32, and eval_results_avg16.
AIME25 data is not included. Add evaluation/simplelr_math_eval/data/aime25/test.jsonl, or remove aime25 from the benchmark list in the launcher.
The evaluation backend installs its own dependencies, including a different ANTLR runtime version from training. Use a separate evaluation environment to keep the training environment consistent. See the evaluation README for details of the underlying harness.
├── verl/ # Training and speculative rollout implementation
├── training_scripts/
│ ├── spec-distill/ # SPEC-Distill launchers
│ ├── distill-data-generation/ # Offline teacher rollout generation
│ ├── vanilla-grpo/ # GRPO baselines
│ ├── luffy/ # Luffy baselines
│ ├── eval/ # Evaluation launchers
│ └── expert_registry.yaml # Teacher-cache registry
├── custom_reward/ # Math verifier reward functions
├── evaluation/simplelr_math_eval/
├── fix_oov/ # vLLM vocabulary patch helpers
└── data/ # Location for prepared datasets
We thank the developers of verl for the RL training framework, SPEC-RL for its work on speculative rollouts, and SimpleRL-Reason for the math evaluation harness. Our implementation also builds on vLLM for inference and Qwen3 as the model family.