Add AutoTP=2 smoke test config and script - #1004
Open
delock wants to merge 5 commits into
Open
Conversation
Verified on 2x RTX 5090 with Qwen2.5-0.5B-Instruct: - Student and teacher both use AutoTP=2 - HybridEngineRollout.generate() produces identical output on both ranks - OPSD training loop runs end-to-end with temperature=0 (greedy) - No DistributedSampler in pure-TP mode (all ranks see same data) - Teacher uses ZeRO-0 when AutoTP is enabled (AutoTP+ZeRO-3 not supported) Requires DeepSpeed >= commit 53a2ac4 (AutoTP KV cache consistency fix). Signed-off-by: Guokai Ma <guokai.ma@intel.com> Signed-off-by: Guokai Ma <guokai.ma@gmail.com>
PKUWZP
self-requested a review
July 21, 2026 14:43
Contributor
Author
|
Note DeepSpeed AutoTP for now does not have column parallel in |
- teacher.py: drop the stale guard that forced ZeRO-0 whenever AutoTP was enabled. AutoTP + ZeRO-3 is now supported by recent DeepSpeed, so the two can be combined. Also gate ZeRO-3 on a real data-parallel dimension (world_size > autotp_size) instead of world_size > 1, so pure-TP runs (autotp_size == world_size, no offload) no longer pay needless ZeRO-3 per-forward gather overhead. - configs/smoke_ds_zero3_offload_autotp2.json: student ZeRO-3 + param/optimizer offload + AutoTP=2 DeepSpeed config. - configs/smoke_hybrid_autotp_zero3.json: OPSD smoke with teacher and student both on AutoTP=2 + ZeRO-3 (teacher offload). - test_teacher_autotp_zero3.py / test_student_autotp_zero3.py: isolated AutoTP + ZeRO-3 probes (env-tunable OFFLOAD/AUTOTP). Verified on 4x RTX 4080 SUPER with Qwen2.5-0.5B/1.5B-Instruct: - Teacher AutoTP=2 + ZeRO-3 (offload and 2x2) runs on upstream DeepSpeed master. - Student AutoTP=2 + ZeRO-3 (offload and 2x2) and the full OPSD smoke (teacher + student) require DeepSpeed PR #8168 (AutoTP + ZeRO-3 checkpoint consolidation). Signed-off-by: Guokai Ma <guokai.ma@intel.com> Signed-off-by: Guokai Ma <guokai.ma@gmail.com>
Contributor
Author
|
Now teacher support autotp + zero3, including autotp + zero3 offload. |
tohtana
requested changes
Jul 29, 2026
| # and deadlock the TP all-reduce. Only shard when there is real DP. | ||
| tp_size = student_engine.autotp_size() if hasattr(student_engine, 'autotp_size') else 1 | ||
| dp_size = dist_world_size() // tp_size | ||
| sampler = DistributedSampler(dataset, shuffle=cfg.data.shuffle) if dp_size > 1 else None |
Contributor
There was a problem hiding this comment.
Don't we need to pass dp size and rank to DistributedSampler?
| from deepspeed.accelerator import get_accelerator | ||
| from transformers import AutoModelForCausalLM | ||
|
|
||
| MODEL = os.environ.get("STUDENT_MODEL", "/root/autodl-tmp/models/Qwen2.5-0.5B-Instruct") |
Contributor
There was a problem hiding this comment.
We could replace it with HF model ID
| from teacher import TeacherWrapper | ||
| from config import TeacherConfig | ||
|
|
||
| MODEL = os.environ.get("TEACHER_MODEL", "/root/autodl-tmp/models/Qwen2.5-1.5B-Instruct") |
Contributor
There was a problem hiding this comment.
We could replace it with HF model ID
main.py: pass num_replicas=dp_size and rank=global_rank//tp_size to DistributedSampler so data shards only along the real DP dimension. Without this, the default sampler used the full world_size as replicas, splitting data across TP-group ranks and deadlocking the all-reduce. Verified end-to-end on CPU (4 procs, TP=2/DP=2) with Qwen2.5-0.5B-Instruct on DeepSpeed master: full OPSD loop (rollout+teacher+student) runs without deadlock. test_*_autotp_zero3.py: replace local model paths with HF model IDs so the defaults work out of the box. Signed-off-by: Guokai Ma <guokai.ma@intel.com> Signed-off-by: Guokai Ma <guokai.ma@gmail.com>
DeepSpeed uses 0 as the sentinel for 'AutoTP not configured' (tensor_parallel_config.autotp_size defaults to 0, and engine.autotp_size() returns it verbatim). Without a tensor_parallel section in the DS config (pure-DP runs), dist_world_size() // tp_size hit ZeroDivisionError. Normalize 0 -> 1 so the DP size math matches DeepSpeed's own convention (autotp_size not in (0, 1) means real TP). Verified pure-DP (world=2, TP=1, DP=2) now runs end-to-end on CPU. Signed-off-by: Guokai Ma <guokai.ma@intel.com> Signed-off-by: Guokai Ma <guokai.ma@gmail.com>
Contributor
Author
|
@tohtana thanks for the catches! I have updated the code and verified it on TP=2xDP=2. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Verified on 2x RTX 5090 with Qwen2.5-0.5B-Instruct:
Requires DeepSpeed >= commit 53a2ac4 (AutoTP KV cache consistency fix).