[Distillation] Fix eod masking + strategy refactoring#3478
Draft
[Distillation] Fix eod masking + strategy refactoring#3478
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Description
The current code didn't correctly mask eod tokens when they are segment delimiters - sft mode was fine, but the pretraining incorrectly included that token into prediction.
The last token in the sample still need to predict the eod token as expected, it is the oed input token which need to be excluded from the loss.
The kl divergence averaging wasn't correct as well.
Since this logic was in anonymous labels_fn function, it is hard to unit test it.
Since we are not longer inheriting from tunix distillation strategy, we can add it directly to our custom strategy class.
The base strategy class has been intrduced.
Tests
A new test test_strategy_ignores_segmentation_zero_tokens() has been added to tests/post_training/unit/train_distill_test.py
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.