Repository navigation
[v5] 减少 FSDP2 累积与 vLLM 权重发布开销 - #390
Closed
qychen2001 wants to merge 5 commits into
Closed
qychen2001 wants to merge 5 commits into
qychen2001 wants to merge 5 commits into
Conversation
Let FSDP workers retain the platform connection default. Set Megatron connection limits before backend imports can create a device context. Co-authored-by: OpenAI Codex <noreply@openai.com>
Use the FSDP2 gradient synchronization flags when no_sync is unavailable, preserving each sharded unit state across nested contexts. Co-authored-by: OpenAI Codex <noreply@openai.com>
Schedule longer causal-LM micro-batches first on distributed workers while retaining batch membership and output ordering. Check gradients, final-only synchronization and response alignment. Co-authored-by: OpenAI Codex <noreply@openai.com>
Reuse device bucket views for base unquantized weights until loading and TP barriers finish. Avoid heap collection and cache flushing on the reusable device-buffer path. Co-authored-by: OpenAI Codex <noreply@openai.com>
Provide the existing rollout feature hook and assert loss sum/count semantics in micro-batch regression fixtures. Co-authored-by: OpenAI Codex <noreply@openai.com>
qychen2001
marked this pull request as ready for review
November 17, 2026 09:42
tastelikefeet
added a commit
that referenced
this pull request
Nov 17, 2026
_no_sync_context now routes FSDPModule models (no no_sync method) to a flag-based context instead of nullcontext, cutting per-micro-batch reduces to one per accumulation window. Save/restore walks state._fsdp_param_groups (the same list torch's setter walks; the singular property returns None pre-init and raises on multi-group HSDP). Design adapted from #390.
tastelikefeet
added a commit
that referenced
this pull request
Nov 17, 2026
Extend borrow_bucket eligibility beyond independent receivers: every shared-TP rank loads views, synchronizes, and passes the TP barrier before the driver acks, so the sender still cannot overwrite early. Skip the receiver-side gc.collect/empty_cache and the sender-side heap collection on the reusable device-buffer path. Design adapted from #390.
tastelikefeet
added a commit
that referenced
this pull request
Nov 17, 2026
Drop the worker-wide CUDA_DEVICE_MAX_CONNECTIONS='1' pin from _torch_setup so FSDP2 workers keep the platform default (a single connection restricts communication/compute overlap). The Megatron models now set it in __init__ before any backend import or CUDA-context creation: '32' for sharded (FSDP) wrappers, setdefault '1' otherwise to depress megatron warnings. Design adapted from #390.
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.
修改动机与实现
减少 FSDP2 训练与 vLLM 权重发布中的同步、复制和内存清理开销,并改善各 rank 的 micro-batch 执行顺序。
配套:ms-swift #10586。
实验结果
Swift + Twinkle 联合优化后与 veRL 对比,各运行 5 步。Qwen3.5-4B,8 × PPU-ZW810:4 卡 FSDP2 训练 + 4 卡 rollout(TP2 × 2),每步 64 条样本,micro-batch/GPU=1,GA=16,最大生成长度 4096。
吞吐按实际消费的 response tokens / iteration 墙钟时间 / 8 计算。阶段耗时取第 2–4 步,避开首步预热与末步发布差异;veRL 的 old-logprob 同时计算 entropy。
AI assistance: OpenAI Codex.