fix(mcore-adapter): drop mm_token_type_ids before forwarding into GPTModel.forward - #493
Open
AmirF194 wants to merge 1 commit into
Open
fix(mcore-adapter): drop mm_token_type_ids before forwarding into GPTModel.forward#493AmirF194 wants to merge 1 commit into
AmirF194 wants to merge 1 commit into
Conversation
…Model.forward Fixes alibaba#457
Contributor
Author
|
Bumping this after a week of quiet. The fix is narrow: Megatron's GPTModel.forward chokes on mm_token_type_ids from the multimodal processor, so this drops the unrecognized kwargs before the call. CI's clean if that helps triage. |
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
Qwen3_5Model.forward(mcore_adapter/src/mcore_adapter/models/qwen3_5/modeling_qwen3_5.py)pops
force_vit_image/force_vit_videoout of**kwargsand then forwards the rest ofkwargsunfiltered intosuper().forward(...), which resolves throughMcaGPTModeltoMegatron's
GPTModel.forward. That method has a fixed keyword signature with no**kwargscatch-all, so any extra key raises
TypeErrorat argument-binding time, before the methodbody runs.
transformers'Qwen3VLProcessor(used for Qwen3.5-VL too) setsreturn_mm_token_type_ids: Trueby default and listsmm_token_type_idsin itsmodel_input_names. Nothing in ROLL ormcore_adapter reads that key (
grep -rn "token_type" .returns zero hits repo-wide), so aQwen3.5 VLM batch carries it straight through to
GPTModel.forwardand crashes everytraining/inference forward call, matching the traceback in #457.
Fix
Pop
mm_token_type_idsnext to the two VIT-only kwargs that are already popped, before thekwargs dict reaches either of the two
super().forward()call sites in this method (bothshare the same dict, so one pop covers both paths).
Verification
TypeError: GPTModel.forward() got an unexpected keyword argument 'mm_token_type_ids'in a cleanpython:3.11-slimcontainer against current HEAD(
192b1a0), driving a bareQwen3_5Modelinstance throughforward()the way anon-first pipeline-parallel stage calls it (no GPU/NPU needed: the failure is pure
keyword-argument binding).
tests/models/test_qwen3_5_forward_kwargs.py(2 tests). Ran both on unmodified192b1a0(both fail with theTypeErrorabove) and on this branch (both pass), in thesame container.
transformerspackage thatmm_token_type_idsis theonly processor-emitted key beyond what
forward()already declares by name.weights, unavailable here). No CI workflow in this repo currently runs
tests/models/(
ci-npu-test.ymlonly runstests/utilsandtests/third_party/sglang), so this testisn't wired into a gate; happy to add that if you'd like.
Fixes #457
FYI, out of scope here
mcore_adapter/src/mcore_adapter/models/qwen3_vl/modeling_qwen3_vl.pyhas the identicalpattern (pops
force_vit_image/force_vit_videoonly, forwards the rest ofkwargsunfiltered) and the same processor would hit it the same way. I did not reproduce or touch
it since #457 is scoped to Qwen3.5; flagging in case it's worth a follow-up.