Fix missing mm_token_type_ids when training new Qwen VLMs with liger kernel#6234
Open
apardyl wants to merge 1 commit into
Open
Fix missing mm_token_type_ids when training new Qwen VLMs with liger kernel#6234apardyl wants to merge 1 commit into
apardyl wants to merge 1 commit into
Conversation
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?
Newer versions of the Qwen model (e.g., Qwen3.5) introduce a new input field,
mm_token_type_ids, which is currently handled only in the standard loss computation path. This PR extends support for this field to the Liger Kernel path as well, enabling training of newer Qwen VLMs with the Liger Kernel loss. Simple tests included.Before submitting
AI writing disclosure
We welcome the use of AI tools to help with contributions. For transparency and to help us improve our review process, please indicate the level of AI involvement in this PR.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag members/contributors who may be interested in your PR.
Note
Low Risk
Narrow, conditional forward-arg change gated on
pixel_values; standard loss path already handled the field. Risk is mainly incorrect VLM forward inputs for Qwen3.5+ with Liger.Overview
Fixes Qwen3.5+ VLM GRPO training with Liger by threading
mm_token_type_idsthrough the fused-loss path, which previously omitted this input while the standard log-prob forward already included it._get_last_hidden_statenow acceptsmm_token_type_idsand adds it to backbonemodel_inputswhenpixel_valuesis present (alongside existing Qwen fields likeimage_grid_thw). The Liger loss step passesinputs.get("mm_token_type_ids")into that helper.Tests add Qwen3.5 to
test_train_vlm_and_liger(transformers ≥ 5.2.0) andtest_get_last_hidden_state_passes_mm_token_type_ids, which asserts scored batches include the field and that backboneforwardreceives matching tensors.Reviewed by Cursor Bugbot for commit 8a0962a. Bugbot is set up for automated code reviews on this repo. Configure here.