Fix PPFormulaNet training loss: prevent incorrect label shift in ForCausalLMLoss - #47319
Closed
sagnikai wants to merge 1 commit into
Closed
Fix PPFormulaNet training loss: prevent incorrect label shift in ForCausalLMLoss#47319sagnikai wants to merge 1 commit into
sagnikai wants to merge 1 commit into
Conversation
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: pp_formulanet |
Contributor
CI recapDashboard: View test results in Grafana
|
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.
ForCausalLMLoss internally shifts labels left by 1 (labels[..., 1:]) when shift_labels is not provided. However, PPFormulaNet is an encoder-decoder model where logits are already aligned with labels — no shift is needed. This causes the model to train against misaligned labels, losing the last target token.
This fix passes shift_labels=labels to ForCausalLMLoss, telling it to skip the internal shift. This matches the same pattern used by Florence2 (fixed in #46898), which PPFormulaNet inherits from but overrides orward().
Fixes #47317.