[model] feat: Add text-only Qwen3.5 bridges (port from upstream main) - #18
Merged
Conversation
Port qwen35_bridge.py and its unit tests verbatim from NVIDIA-NeMo/Megatron-Bridge main (bfc4b41). Registers Qwen3_5ForCausalLM and Qwen3_5MoeForCausalLM -> GPTModel (model_type qwen3_5_text / qwen3_5_moe_text); this branch previously only had the VL-native ForConditionalGeneration bridges, so text-only Qwen3.5 checkpoints could not be bridged. All referenced mapping classes (GDNLinearMappingSeparate, GDNConv1dMapping, FusedExpertMapping, ...) and the full_attention_interval_from_hf helper already exist on this branch; no shared-code changes needed. Signed-off-by: Yusheng Su <yushengsu.thu@gmail.com>
This was referenced Jul 8, 2026
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
Port the text-only Qwen3.5 bridges from NVIDIA-NeMo/Megatron-Bridge
main(bfc4b418) to this branch:src/megatron/bridge/models/qwen/qwen35_bridge.py—Qwen35Bridge(Qwen3_5ForCausalLM) andQwen35MoEBridge(Qwen3_5MoeForCausalLM) →GPTModel, ported verbatimsrc/megatron/bridge/models/qwen/__init__.py— registration importtests/unit_tests/models/qwen/test_qwen35_bridge.py— upstream unit tests, ported verbatimWhy
This branch only registers the VL-native
Qwen3_5(Moe)ForConditionalGenerationbridges (qwen_vl/qwen35_vl_bridge.py), so a text-only Qwen3.5 checkpoint cannot be bridged at all —AutoBridgefinds no match forQwen3_5ForCausalLM/Qwen3_5MoeForCausalLM. Upstreammainadded these text bridges (the VL bridge derives from them there); this PR closes the gap for text-only LoRA/RL work.Compatibility notes
GDNLinearMappingSeparate,GDNConv1dMapping,FusedExpertMapping,FusedGatedExpertMapping, ...) andtransformers_compat.full_attention_interval_from_hfalready exist on this branch — zero shared-code changes.MegatronModelBridge.provider_bridge()used viasuper()exists on this branch.from transformers import Qwen3_5ForCausalLM, Qwen3_5MoeForCausalLMmatches the existing pattern (qwen3_next_bridge.py); verified importable on transformers 5.8.1 (the miles image environment).Validation
ruff checkclean on changed filespytest tests/unit_tests/models/qwen/test_qwen35_bridge.py— 38 passed