Skip to content

Add AutoTP=2 smoke test config and script - #1004

Open
delock wants to merge 2 commits into
masterfrom
gma/opsd-autotp
Open

Add AutoTP=2 smoke test config and script#1004
delock wants to merge 2 commits into
masterfrom
gma/opsd-autotp

Conversation

@delock

@delock delock commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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).

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>
@delock
delock requested a review from tjruwase as a code owner July 21, 2026 14:42
@PKUWZP
PKUWZP self-requested a review July 21, 2026 14:43
@delock

delock commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Note DeepSpeed AutoTP for now does not have column parallel in lm_head, we expect deepspeedai/DeepSpeed#8146 and its follow up (inplace softmax) would significantly reduce memory overhead in case of long sequence OPSD.

- 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>
@delock

delock commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Now teacher support autotp + zero3, including autotp + zero3 offload.

@tohtana tohtana left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @delock,
This is a great improvement of the OPSD example! I left a few comments. I think the sampler issue should be addressed before we merge.

Comment thread training/opsd/main.py
# 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could replace it with HF model ID

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants