Repository navigation
Fix PaliGemma labels for unpadded batches - #51222
Open
stefanielizeth73-art wants to merge 1 commit into
Open
stefanielizeth73-art wants to merge 1 commit into
stefanielizeth73-art wants to merge 1 commit into
Conversation
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: paligemma |
This branch has not been deployed
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?
Fix label construction for unpadded PaliGemma batches with different sequence lengths. The tokenizer accepts these batches, but converting all input IDs into one NumPy array raises before the processor can return the encoded examples for later collation.
Build labels per sequence, keeping the prefix masked with
-100.BatchFeaturehandles the requested tensor conversion. The regression test compares an unpadded batch with processing each example separately and checks that both masked prefix and supervised suffix tokens remain present.Reproducer
Run on CPU against main
e35e1a5087907deb2cbdd7304dd3ff047dca4135. This loads only processor/tokenizer assets from a published checkpoint.Main raises
ValueError: setting an array element with a sequenceat label construction. With this change it returns sequence and label lengths[266, 274].Validation
pytest tests/models/paligemma/test_processing_paligemma.py -q: 37 passed, 36 skipped.pytest tests/models/paligemma/test_modeling_paligemma.py -q --timeout=180(the additional module selected bytests_fetcher.py): 145 passed, 112 skipped, 33 xfailed, 6 xpassed, with 1,563 subtests passing.make stylechecks passed through the equivalentutils/checkers.pycommand.make fix-repoequivalent completed its other fixers; the docstring checker raises anIndexErroron its/src/path split on Windows. Unrelated generated auto-mapping changes were discarded.The implementation and local tests were completed with Codex assistance.