feat(pp): support FusedLinearCrossEntropy under pipeline parallelism#2927
Open
beccohov wants to merge 1 commit into
Open
feat(pp): support FusedLinearCrossEntropy under pipeline parallelism#2927beccohov wants to merge 1 commit into
beccohov wants to merge 1 commit into
Conversation
…nder PP Signed-off-by: Arkadii Be <beccohov@gmail.com>
Author
|
Hey @akoumpa, |
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.
What does this PR do ?
Makes
FusedLinearCrossEntropyactually run under pipeline parallelism instead ofsilently falling back to
MaskedCrossEntropyon every PP run (#2681).Changelog
recipes/llm/train_ft.py: run the loss-capability check on the real last-stagemodule, not the
AutoPipelinewrapper (which defines noforward, so the checkalways failed and silently swapped
FusedLinearCrossEntropyforMaskedCrossEntropy). Extracted into_maybe_downgrade_loss_fn.recipes/llm/train_ft.py: gate fused CE under PP to the generic patched forward —MoE/custom-forward models (e.g. deepseekv3) fall back to
MaskedCrossEntropywith aclear warning instead of crashing; flag the last stage to emit hidden states when
fused CE is active.
distributed/pipelining/hf_utils.py: the last stage skips thelm_headprojectionand returns hidden states when flagged; mark the model fused-CE-capable only when the
generic forward is installed.
distributed/pipelining/functional.py: size the last-stage output as[mb, seq, hidden]instead of[mb, seq, vocab]on the fused path.components/loss/mtp.py:PipelineCausalLMLosstreats a bare last-stage tensor ashidden states for
FusedLinearCrossEntropy(running the fusedlm_head+CE) and raisesa clear error for the unsupported MTP-tuple + fused-CE combination.
loss routes the bare tensor to hidden states; capability/gate truth table.
Before your PR is "Ready for review"
Pre checks:
Additional Information
custom-forward models (deepseekv3, nemotron_v3, step3p7) are gated to
MaskedCrossEntropyand left as a follow-up.warning and produces bit-identical loss/grad-norm to
MaskedCrossEntropyacross steps(confirms correctness under TP-sharded vocab).