DeepSpeed
429e2ad2 - Add Hybrid Engine rollout in DeepSpeed to support On-Policy Distillation (OPSD) Trainer (#8027)

Commit
138 days ago
Add Hybrid Engine rollout in DeepSpeed to support On-Policy Distillation (OPSD) Trainer (#8027) ## Summary This PR adds a DeepSpeed-native on-policy distillation trainer. It also incorporates the PR from @delock (https://github.com/PKUWZP/DeepSpeed/pull/1), which abstracts the OPSD example into DeepSpeed submodules, including a rollout engine abstract layer, two rollout implementations (HybridEngine and vLLM), and OPSD trainer. On-policy distillation: a small **student** generates rollouts, a frozen large **teacher** scores them, and the student is updated by a per-token divergence (forward-KL / reverse-KL / JSD) between the two distributions on the student's own samples. Each step has three phases — student rollout → teacher forward + CPU logit cache → student forward + streamed divergence + backward — so the full `[B, T, V]` teacher tensor never co-resides with the student logits on the training device. ## Key Design Decisions - Rollout engine abstracted as RolloutEngine ABC, created via `build_rollout()` factory - `HybridEngineRollout` runs in-process, reusing model weights — no cross-process weight transfer needed - `VLLMRollout` runs as a subprocess to avoid vLLM's `new_group()` deadlocking with DeepSpeed launcher - `HybridEngineRollout` support continuous batching and graph capture **Modules**: - `deepspeed/runtime/rlhf/trainer/opsd.py` — chunked / streamed forward-KL, reverse-KL, JSD with sequence-axis chunking - `deepspeed/runtime/rlhf/trainer/teacher.py` — frozen teacher wrapper + `TeacherLogitCache` (host-resident, chunk fetch) - `deepspeed/runtime/rlhf/rollout/hybrid_engine_rollout.py` — HybridEngine rollout backends - `deepspeed/runtime/rlhf/rollout/vllm_rollout.py` — vLLM rollout backends - `benchmarks/opsd` — Benchmark scripts for OPSD training - `tests/unit/runtime/rollout` — testing scripts for OPSD rollout backends (vLLM + HybridEngine) **Validated end-to-end**: On 2× H200 with Qwen2.5-0.5B-Instruct student + Qwen2.5-1.5B-Instruct teacher via the hybrid-engine path; loss finite for 5 steps. See README for the smoke recipe. **Follow-up items**: documented in README file and SGLang rollout integration. ## Test plan - [x] `cd examples/opsd && python -m pytest tests/ -v` → **87/87 passing** on CPU - [x] `deepspeed --num_gpus 2 main.py --config configs/smoke_hybrid.json` end-to-end on 2× H200 → 5 finite-loss steps - [x] `pre-commit run --files <all changed files>` → green (yapf, flake8, check-torchdist, check-license, check-torchcuda, codespell) - [x] vLLM rollout end-to-end - [ ] Larger-scale training run (out of scope for the initial PR) --------- Signed-off-by: Zhipeng Wang <zhipengbayern@gmail.com> Signed-off-by: Guokai Ma <guokai.ma@intel.com> Co-authored-by: Guokai Ma <guokai.ma@intel.com> Co-authored-by: Ma, Guokai <guokai.ma@gmail.com>
Author
Parents
Loading