Repository navigation
fix: text-only qwen3_5 checkpoints crash in get_rope_index (vision_config undefined) - #1818
Closed
eduardoworrel wants to merge 1 commit into
Closed
eduardoworrel wants to merge 1 commit into
eduardoworrel wants to merge 1 commit into
Conversation
… checkpoints Qwen3_5ForCausalLM inherits get_rope_index from the Qwen2-VL lineage, where a vision tower is always present. A text-only checkpoint (model_type qwen3_5_text) has no vision_config, so reading vision_config.spatial_merge_size throws before the ?? 2 fallback can apply -- even for a pure-text generate() call.
eduardoworrel
marked this pull request as draft
October 23, 2026 23:43
Author
|
Closing: the dereference is only reachable when the ONNX graph exports a |
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.
Problem
Qwen3_5ForCausalLMthrows ingenerate()for a text-onlyqwen3_5checkpoint (model_type: "qwen3_5_text", novision_config) when the ONNX graph exposes aposition_idsinput:Repro:
AutoModelForCausalLM.from_pretrained(<qwen3_5_text checkpoint whose decoder exports position_ids>)thenmodel.generate({ ...tokenizer('Hello'), max_new_tokens: 4 }). No image involved.Cause
prepare_inputs_for_generationgates on the export:get_rope_index(inherited from the Qwen2-VL lineage) then does:The
?? 2fallback cannot apply — reading.spatial_merge_sizeonundefinedthrows first.Qwen3_5ForCausalLMextendsQwen3_5ForConditionalGeneration, which extendsQwen3VLForConditionalGeneration, so a text-only checkpoint inherits a multimodalget_rope_indexthat assumes a vision tower exists.Checkpoints whose export omits
position_idsare unaffected, which is why this only surfaces with certain exports.Fix
No behaviour change when
vision_configexists; the value is only consumed inside theif (image_grid_thw || video_grid_thw)branch.Verification
Same checkpoint, same call:
generate()throwsCannot read properties of undefined (reading 'spatial_merge_size')fromget_rope_index.get_rope_indexwithout throwing and proceeds past that point.Scope of this patch is only the undefined dereference.
References
Qwen3_5ForCausalLMsubclassesQwen3_5PreTrainedModeland composesQwen3_5TextModel— a sibling of the multimodal class, whoseget_rope_indexhandles the text-only case. The JS port inherits the multimodal one instead.Qwen2VLForConditionalGenerationdocuments that "CausalLM variants (e.g., Qwen2VLForCausalLM) extend this class but load only embed_tokens + decoder_model_merged (no vision_encoder)" — this dereference defeats that for a checkpoint with novision_configat all.