Skip to content

Refactor/dp only remove tp pp ep sp - #17

Merged
CanGeng merged 3 commits into
masterfrom
refactor/dp-only-remove-tp-pp-ep-sp
Jun 25, 2026
Merged

Refactor/dp only remove tp pp ep sp#17
CanGeng merged 3 commits into
masterfrom
refactor/dp-only-remove-tp-pp-ep-sp

Conversation

@CanGeng

@CanGeng CanGeng commented Jun 25, 2026

Copy link
Copy Markdown
Owner

No description provided.

CanGeng added 3 commits June 26, 2026 02:57
Narrow the framework to data parallelism (DDP / FSDP / DeepSpeed ZeRO) and
remove tensor/pipeline/expert/sequence parallelism, which were never
real-GPU validated and carried maintenance cost without a clear user.

Removed:
- builtin_plugins/distributed/model_parallel/ (tp_auto, tp_aware, sp, ep)
  and pipeline/ (schedules); recipes 3d_parallel.yaml, tp_ddp.yaml
- ParallelSection tp/pp/ep/sp + tensor_parallel/pipeline; TPConfig/PipelineConfig
- ModelParallelStrategy/PipelineSchedule protocols + registry categories
- _runtime _build_model_parallel_strategy/_build_pipeline_schedule/_preflight_parallel
- ParallelContext reduced to data-parallel only (1-D dp DeviceMesh)

Bundled fixes (intermingled in the same files):
- fix(distributed): broadcast run_dir from rank 0 so all ranks share one dir;
  a per-rank datetime.now() timestamp split ranks across sibling dirs when a
  launch straddled a one-second boundary. Gate the lineage store to rank 0.
- fix(cli): destroy_process_group() on train/resume exit (NCCL teardown warning)
- fix(recipes): quote mixed_precision "no" in fsdp/zero2 (YAML bool coercion)
- docs: rewrite operations/distributed(.zh-CN) + recipes tables to DP-only scope

Validated on a real single-node 4xH20 box: DDP + FSDP run clean, loss drops,
all ranks share one run_dir. Full suite 4465 passed; ruff + mypy clean.

CanGeng
ZeRO had no tests (not even CPU) and the lighttrain<->DeepSpeed seam broke on
real multi-GPU. Fixes to make ZeRO-2 actually run:

- zero.py: add train_micro_batch_size_per_gpu / gradient_accumulation_steps so
  DeepSpeed derives train_batch_size from the live world_size (the hardcoded
  train_batch_size=1 was rejected when world_size > 1).
- zero.py: clip_grad_norm returns 0.0 when get_global_grad_norm() is None
  (lighttrain clips before optimizer_step; DeepSpeed only has the norm after
  engine.step()).
- route zero_grad through GradSyncStrategy: DeepSpeedEngine.zero_grad() lacks
  the set_to_none kwarg and step() already zeroed grads. Add zero_grad to the
  protocol + ddp/fsdp/noop (set_to_none=True) and zero (no-op); the update loop
  calls grad_sync.zero_grad(optimizer) instead of optimizer.zero_grad directly.
- recipes/nano_zero2.yaml: complete tiny_lm ZeRO-2 smoke recipe.

Validated on a real single-node 4xH20 box: ZeRO-2 trains, loss drops, ranks
exit clean. Full suite 4466 passed; ruff + mypy clean.

CanGeng
safetensors save_model refuses to persist aliased storage. Under ZeRO-2
(DeepSpeed flattens params into one buffer) tiny_lm's tied tok_emb/lm_head
became non-covering slices, so save_model raised and aborted crash / frozen /
nan-repro diagnostic snapshots.

Add save_model_safe (lighttrain/observability/diagnostics/_save.py): try
save_model, and on RuntimeError clone the state dict to break the storage
sharing and save the raw tensors (values preserved; tying metadata dropped —
fine for a diagnostic snapshot). Route frozen_step / crash_bundle / nan_repro
through it; correct the stale nan_repro comment that claimed save_model already
handled tied weights.

CanGeng
@CanGeng
CanGeng merged commit c5b836f into master Jun 25, 2026
3 checks passed
@CanGeng
CanGeng deleted the refactor/dp-only-remove-tp-pp-ep-sp branch June 25, 2026 19:16
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.

1 participant