Skip to content

Fix chunked loss initialization in TorchFT trainer - #4575

Open
jojoinfra wants to merge 1 commit into
pytorch:mainfrom
jojoinfra:fix-chunk-loss
Open

Fix chunked loss initialization in TorchFT trainer#4575
jojoinfra wants to merge 1 commit into
pytorch:mainfrom
jojoinfra:fix-chunk-loss

Conversation

@jojoinfra

Copy link
Copy Markdown
Contributor

While testing DeepSeek-V4 Flash training with TorchTitan and TorchFT across 128 dies, I ran into several issues and fixed them in my downstream setup. I'd like to contribute these fixes upstream as small, focused PRs. This PR addresses one of them.

With chunked loss enabled, FaultTolerantTrainer does not bind the model's lm_head to ChunkedLossWrapper or set _skip_lm_head. These steps already exist in Trainer, but are missing from TorchFT's separate initialization path.

This PR extracts the existing setup into Trainer._configure_chunked_loss() and calls it from both trainers after model construction. The helper preserves the existing handling of non-pipeline training and pipeline stages, while keeping this fix limited to chunked-loss initialization.

Validation:

  • Added one CPU unit test verifying lm_head binding and _skip_lm_head in the non-pipeline case: passed.

1. Share Trainer setup so TorchFT binds lm_head and skips the model projection.
2. Add one focused CPU regression test for non-pipeline training.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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