Repository navigation
[v0.5.10][3] Fix processor return_tensors duplicate kwarg for transformers >=5.0 #927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
38458fc
Bump sglang to v0.5.10
yueming-yuan fee8ee2
Fix PyJWT uninstall conflict with v0.5.10 base image
yueming-yuan dedb1fa
Fix PyJWT: rm debian package files before pip install
yueming-yuan 6d0a8e3
Retrigger CI
yueming-yuan ffd110b
Fix FastAPI add_event_handler removed in newer versions
yueming-yuan 3cf7a9f
Fix OpenAIServingChat missing reasoning_parser in test mock
yueming-yuan 44e83de
Fix mask_utils for transformers >=5.0 BatchEncoding return type
yueming-yuan 1a2d5e8
Format
yueming-yuan 14a0cdb
Merge branch 'fix/mask-utils-transformers-v5' into bump-sglang-v0.5.10
yueming-yuan d549b26
Revert "Merge branch 'fix/mask-utils-transformers-v5' into bump-sglan…
yueming-yuan ec3cb15
Reapply "Merge branch 'fix/mask-utils-transformers-v5' into bump-sgla…
yueming-yuan a723a03
Fix processor return_tensors duplicate kwarg for transformers >=5.0
yueming-yuan fbec694
Use Megatron-Bridge fix/rope-theta branch for transformers 5.x compat
yueming-yuan 1b1e83f
Disable flashinfer allreduce fusion for H100 colocate to save NVLS ha…
yueming-yuan e848032
Revert "Disable flashinfer allreduce fusion for H100 colocate to save…
yueming-yuan c72aa96
Fix tool call tokenizer tests for transformers v5 compatibility
guapisolo f058d37
Fix apply_chat_template return type for transformers v5
guapisolo 9cb379a
Fix Step-3.5-Flash tool-call tokenizer test classification
guapisolo 82a2787
Merge branch 'bump-sglang-v0.5.10' into fix/processor-return-tensors
yueming-yuan 0a0786a
Merge branch 'bump-sglang-v0.5.10' into fix/mask-utils-transformers-v…
yueming-yuan f000d74
Merge branch 'fix/mask-utils-transformers-v5-v2' into fix/processor-r…
yueming-yuan 51c5785
Merge branch 'main' into fix/mask-utils-transformers-v5-v2
yueming-yuan 9918d0a
Revert CI test docker/branch and Dockerfile changes
yueming-yuan b04589e
Merge branch 'fix/mask-utils-transformers-v5-v2' into fix/processor-r…
yueming-yuan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -28,17 +28,13 @@ def load_tokenizer(name_or_path: str, chat_template_path: str = None, **kwargs): | |||||||
|
|
||||||||
| def build_processor_kwargs(multimodal_inputs: dict | None = None) -> dict: | ||||||||
|
|
||||||||
| forced = { | ||||||||
| # force return_tensors to None for input_ids | ||||||||
| "return_tensors": None, | ||||||||
| } | ||||||||
| modality_forced = {"return_tensors": "pt"} | ||||||||
|
|
||||||||
| result = dict(multimodal_inputs) if multimodal_inputs else {} | ||||||||
|
|
||||||||
| result.update(forced) | ||||||||
|
|
||||||||
| # set return_tensors="pt" for modality-specific outputs | ||||||||
| # return_tensors=None for text (input_ids), "pt" for modality-specific outputs. | ||||||||
| # Use per-modality dicts to avoid transformers >=5.0 duplicate kwarg error. | ||||||||
| result["text_kwargs"] = {**result.get("text_kwargs", {}), "return_tensors": None} | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| for key in ("audio_kwargs", "images_kwargs", "videos_kwargs"): | ||||||||
| if key in result: | ||||||||
| result[key] = {**result[key], **modality_forced} | ||||||||
|
|
||||||||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To fully resolve the duplicate keyword argument issue in
transformers >= 5.0, any existing top-levelreturn_tensorsshould be removed from theresultdictionary. Since the logic now explicitly setsreturn_tensorswithin modality-specific dictionaries (liketext_kwargs), leaving it at the top level—if it was provided in the inputmultimodal_inputs—will still trigger aValueErrordue to the conflict between the global and nested settings.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me