Repository navigation
Fix the TRL-latest packing test failure blocking CI on every PR - #7713
Closed
danielhanchen wants to merge 1 commit into
Closed
danielhanchen wants to merge 1 commit into
danielhanchen wants to merge 1 commit into
Conversation
TRL 1.7.0 removed completion_only_loss from trl.trainer.sft_trainer.DataCollatorForLanguageModeling when label construction moved from collation into dataset preparation (huggingface/trl#6037). tests/utils/test_packing.py passed that kwarg on every construction attempt, so on TRL 1.x every attempt raised TypeError, _DummyTrainer.data_collator was never assigned, and test_enable_sample_packing failed with AttributeError on the HF=latest + TRL=latest matrix leg. Filter the collator kwargs against the installed dataclass signature so the dummy tracks whatever fields TRL currently exposes, and add a regression test pinning the production contract that enable_sample_packing only requires torch_call on the collator.
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Member
Author
|
Superseded by #7722, which combines this with the other two repo-wide CI fixes so a single merge unblocks the whole batch. The files there are byte-identical to this PR's head, and the commits are cherry-picked with provenance. Closing. |
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.
Core (HF=latest + TRL=latest)has been red on every open PR in the repo, including ones that touch nothing near packing. The failure is in the test, not in the library.What breaks
tests/utils/test_packing.py::_DummyTrainerbuilds TRL'sDataCollatorForLanguageModelingfrom a hardcoded kwarg set and then walks a ladder oftry/except TypeErrorfallbacks for the optional flags.completion_only_losswas in the always-passed group, so when TRL removed that field from this collator the first constructor call raisedTypeErrorand every rung of the ladder raised it too. The dummy trainer then has nodata_collatorat all, and the test fails with anAttributeErrorthat names neither TRL nor the removed field.Upstream removal: huggingface/trl commit
f9aeb59(huggingface/trl#6037), which moved completion-only label masking into dataset preparation. First released in TRL v1.7.0.The fix
Build the collator from the installed TRL's live signature instead of guessing:
This subsumes the fallback ladder: any field TRL adds or drops is handled by the same filter, rather than by another rung. The post-hoc
hasattrdefaults are kept so the dummy still presents the attributes the packing code checks for.Also adds
test_enable_sample_packing_only_requires_torch_call, which pins the contract the test was implicitly relying on:enable_sample_packingmay require nothing of a collator beyondtorch_call. That is what stops the next TRL field change from turning into a red CI run.Scope
Test-only. Production is already defensive and was never affected:
unsloth/utils/packing.pyreads the collator viagetattr(trainer, "data_collator", None)and guards every optional field withhasattrbefore assigning.unsloth/models/rl.pyreferences the transformersDataCollatorForLanguageModeling, not TRL's, so the upstream removal does not reach it.Verification
tests/utils/test_packing.pypasses on TRL 0.22.2, 0.25.1, 0.29.1, 1.6.0, 1.7.1 and 1.9.2 (52 passed on the version installed here, 0.25.1). Both the pre-1.7 and post-1.7 field sets are covered, so this is not a fix that trades one pinned version for another.