Skip to content

[kimi] Fix FSDP finalization in Kimi K3 pipeline stage - #5142

Merged
shuhuayu merged 1 commit into
pytorch:mainfrom
shuhuayu:k3-pp
Oct 8, 2026
Merged

shuhuayu merged 1 commit into
pytorch:mainfrom
shuhuayu:k3-pp

Conversation

@shuhuayu

@shuhuayu shuhuayu commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Mirror the FSDP setup in the upstream PipelineStage forward path.
  • Enable manual backward finalization before the Kimi K3 attention-residual stage runs its model forward.
  • Fix the Kimi K3 PP B200 test regression exposed after deferred FSDP gradient reduction was adopted in [PP] Overlap FSDP gradient reduction waits #4661.

Why

AttnResPipelineStage overrides forward_one_chunk. The override omitted the FSDP manual-finalization setup now performed by the PyTorch base implementation. Runtime pipeline schedules later call finalize_backward and fail with:

FSDP finalize_backward requires manual backward finalization. Call set_manual_backward_finalization(True) before forward

The resulting test regression was reproduced by the kimi_k3_fsdp2_tp2_ep2_pp2_vpp4 B200 lane in https://github.com/pytorch/torchtitan/actions/runs/37123140508/job/111203042475.

Test plan

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 8, 2026
Mirror PipelineStage's FSDP setup in the AttnRes forward override so runtime schedules can explicitly finalize accumulated gradients. This fixes the Kimi K3 PP test regression exposed after deferred FSDP gradient reduction was adopted.
@shuhuayu
shuhuayu marked this pull request as ready for review October 8, 2026 06:31
@pytorch-bot pytorch-bot Bot added the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Oct 8, 2026
@shuhuayu shuhuayu added the ciflow/b200 Trigger B200 CI label Oct 8, 2026
@shuhuayu

shuhuayu commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor Author

the targeted test passed but there are some other test failures, will fix them in later prs.

@shuhuayu shuhuayu changed the title Fix FSDP finalization in Kimi K3 pipeline stage [kimi] Fix FSDP finalization in Kimi K3 pipeline stage Oct 8, 2026
@shuhuayu
shuhuayu merged commit 08f7c39 into pytorch:main Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/b200 Trigger B200 CI ciflow/fake-pg Run 1-GPU Fake PG integration tests CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants