Skip to content

Add mm_token_type_ids param to VL models lce_forward to fix ValueError#1120

Merged
Tcc0403 merged 4 commits intolinkedin:mainfrom
albertvillanova:fix-1117
Mar 6, 2026
Merged

Add mm_token_type_ids param to VL models lce_forward to fix ValueError#1120
Tcc0403 merged 4 commits intolinkedin:mainfrom
albertvillanova:fix-1117

Conversation

@albertvillanova
Copy link
Contributor

@albertvillanova albertvillanova commented Mar 3, 2026

Summary

This PR fixes the lce_forward function for VL models, adding support for mm_token_type_ids optional parameter related to multimodal processing:

  • glm4v
  • glm4v_moe
  • qwen2_vl
  • qwen2_5_vl
  • qwen3_vl
  • qwen3_vl_moe

Fix #1117.

This fixes a ValueError in model.generate() with transformers > 5.2.0, after they merged:

See related issue downstream in TRL:

Details

Multimodal token type support:

  • Added the mm_token_type_ids optional argument (of type torch.IntTensor) to the signature of lce_forward, allowing for the specification of multimodal token type IDs.
  • Passed the mm_token_type_ids argument to the underlying model call, ensuring it is incorporated into the forward computation.

Testing Done

We checked this fix solves the issue downstream in TRL.

  • Hardware Type:
  • run make test to ensure correctness
  • run make checkstyle to ensure code style
  • run make test-convergence to ensure convergence

@albertvillanova albertvillanova marked this pull request as ready for review March 3, 2026 20:28
@albertvillanova albertvillanova changed the title Add mm_token_type_ids param to qwen2_5_vl lce_forward Add mm_token_type_ids param to VL models lce_forward Mar 3, 2026
@albertvillanova
Copy link
Contributor Author

CC: @kashif

@albertvillanova albertvillanova changed the title Add mm_token_type_ids param to VL models lce_forward Add mm_token_type_ids param to VL models lce_forward to fix ValueError Mar 4, 2026
@albertvillanova
Copy link
Contributor Author

Transformers has just released v5.3.0 containing the PR I mentioned above:

Currently, liger-kernel throws a ValueError with the latest transformers version for the following models:

  • glm4v
  • glm4v_moe
  • qwen2_vl
  • qwen2_5_vl
  • qwen3_vl
  • qwen3_vl_moe

Copy link
Collaborator

@Tcc0403 Tcc0403 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Tcc0403 Tcc0403 added this pull request to the merge queue Mar 6, 2026
Merged via the queue into linkedin:main with commit 8e50f2a Mar 6, 2026
5 of 7 checks passed
@albertvillanova albertvillanova mentioned this pull request Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Qwen2.5-VL lce_forward() missing mm_token_type_ids causes ValueError in model.generate() with transformers > 5.2.0

2 participants