bridge.models.qwen_vl.qwen35_vl_bridge#
Megatron Bridges for Qwen3.5 and Qwen3.6 Vision-Language Models.
Qwen3.5 and Qwen3.6 share a multimodal architecture that combines:
A hybrid Gated DeltaNet + Gated Attention language model (like Qwen3-Next)
A vision encoder (similar to Qwen3-VL)
Dense MLP or Mixture of Experts (MoE) with shared experts
This module provides three bridges:
Qwen35VLBridge: Dense variant (e.g., Qwen3.5-27B) Reference: https://huggingface.co/Qwen/Qwen3.5-27BQwen35TokenClassificationBridge: Dense token-classification variantQwen35VLMoEBridge: Qwen3.5/Qwen3.6 MoE variants Reference: https://huggingface.co/Qwen/Qwen3.5-397B-A17B Reference: https://huggingface.co/Qwen/Qwen3.6-35B-A3B
Module Contents#
Classes#
Megatron Bridge for Qwen3.5 and Qwen3.6 Vision-Language MoE models. |
|
Megatron Bridge for Qwen3.5 Dense Vision-Language Model. |
|
Bridge for Qwen3.5 VL models with a replicated per-token classification head. |
Functions#
Data#
API#
- bridge.models.qwen_vl.qwen35_vl_bridge.logger#
âgetLogger(âŠ)â
- bridge.models.qwen_vl.qwen35_vl_bridge._QWEN3_5_DENSE_HF_CLASS_NAME#
âQwen3_5ForConditionalGenerationâ
- bridge.models.qwen_vl.qwen35_vl_bridge._QWEN3_5_MOE_HF_CLASS_NAME#
âQwen3_5MoeForConditionalGenerationâ
- bridge.models.qwen_vl.qwen35_vl_bridge._QWEN3_5_TOKEN_CLASSIFICATION_HF_CLASS_NAME#
âQwen3_5ForTokenClassificationâ
- bridge.models.qwen_vl.qwen35_vl_bridge._get_vision_mappings()#
- class bridge.models.qwen_vl.qwen35_vl_bridge.Qwen35VLMoEBridge#
Bases:
megatron.bridge.models.conversion.model_bridge.MegatronModelBridgeMegatron Bridge for Qwen3.5 and Qwen3.6 Vision-Language MoE models.
This bridge handles conversion between Hugging Face Qwen3.5/Qwen3.6 VL models and Megatron-Core Qwen3VLModel formats, including weight mappings and configuration translation for the shared hybrid GDN+Attention VLM architecture.
The weight mappings handle:
Language model hybrid layers (GDN + standard attention)
MoE layers with routed and shared experts
Vision model weights (same as Qwen3-VL: deepstack, merger, patch embed)
QK layernorm, zero-centered RMSNorm for GDN output norm
mRoPE position embeddings
Layer counts, hidden dimensions, and MoE geometry are read from the checkpoint config. For example, Qwen3.5-397B-A17B has 60 language layers, while Qwen3.6-35B-A3B has 40.
.. rubric:: Example
from megatron.bridge import AutoBridge bridge = AutoBridge.from_hf_pretrained(âQwen/Qwen3.5-397B-A17Bâ) qwen36_bridge = AutoBridge.from_hf_pretrained(âQwen/Qwen3.6-35B-A3Bâ) provider = bridge.to_megatron_provider()
- mimo_source_prefixes#
None
- provider_bridge(
- hf_pretrained: megatron.bridge.models.hf_pretrained.causal_lm.PreTrainedCausalLM,
Create a Qwen35VLMoEModelProvider from a HuggingFace pretrained model.
Extracts both language model and vision model configurations from the HuggingFace config and maps them to Megatron provider parameters.
- Parameters:
hf_pretrained â HuggingFace pretrained VLM model
- Returns:
Qwen35VLMoEModelProvider configured with the HF modelâs parameters
- mapping_registry() megatron.bridge.models.conversion.mapping_registry.MegatronMappingRegistry#
Return parameter mappings for Qwen3.5 and Qwen3.6 VL MoE models.
Combines:
Language model mappings (Qwen3-Next hybrid architecture with VL prefixes):
Standard attention: QKV, output projection, QK layernorm
Linear attention (GDN): in_proj, out_proj, conv1d, A_log, dt_bias, out_norm
MoE: router, routed expert MLPs, shared expert MLPs, shared expert gate
Embeddings, output layer, final layernorm
Vision model mappings (Qwen3-VL style):
Vision transformer blocks: attention, MLP, layer norms
Deepstack visual mergers
Patch embedding and position embedding
Final merger (patch_norm, linear_fc1, linear_fc2)
Naming Convention:
Megatron language model params are prefixed with âlanguage_model.â
HF language model params are prefixed with âmodel.language_model.â
Megatron vision model params are prefixed with âvision_model.â
HF vision model params are prefixed with âmodel.visual.â
- Returns:
MegatronMappingRegistry with all parameter mappings
- class bridge.models.qwen_vl.qwen35_vl_bridge.Qwen35VLBridge#
Bases:
megatron.bridge.models.conversion.model_bridge.MegatronModelBridgeMegatron Bridge for Qwen3.5 Dense Vision-Language Model.
This bridge handles the conversion between HuggingFace Qwen3.5 dense VL model and Megatron-Core Qwen3VLModel formats. Unlike the MoE variant, this model uses a standard dense MLP (gate_proj + up_proj â linear_fc1, down_proj â linear_fc2).
The weight mappings handle:
Language model hybrid layers (GDN + standard attention)
Dense MLP with gated SiLU activation (fused pre-MLP layernorm)
Vision model weights (no deepstack mergers)
QK layernorm, zero-centered RMSNorm for GDN output norm
mRoPE position embeddings
Architecture (27B): 16 Ă (3 Ă GDN + 1 Ă Attention) = 64 layers
.. rubric:: Example
from megatron.bridge import AutoBridge bridge = AutoBridge.from_hf_pretrained(âQwen/Qwen3.5-27Bâ) provider = bridge.to_megatron_provider()
- mimo_source_prefixes#
None
- PROVIDER_CLASS#
None
- provider_bridge(
- hf_pretrained: megatron.bridge.models.hf_pretrained.causal_lm.PreTrainedCausalLM,
Create a Qwen35VLModelProvider from a HuggingFace pretrained model.
- mapping_registry() megatron.bridge.models.conversion.mapping_registry.MegatronMappingRegistry#
Return MegatronMappingRegistry for Qwen3.5 dense VL model.
Key differences from the MoE variant:
Dense MLP: gate_proj + up_proj fused into linear_fc1, down_proj as linear_fc2
Pre-MLP layernorm fused into mlp.linear_fc1 (not a separate pre_mlp_layernorm)
No MoE router, routed expert MLPs, or shared expert mappings
No deepstack visual mergers (deepstack_visual_indexes is empty)
- class bridge.models.qwen_vl.qwen35_vl_bridge.Qwen35TokenClassificationBridge#
Bases:
bridge.models.qwen_vl.qwen35_vl_bridge.Qwen35VLBridgeBridge for Qwen3.5 VL models with a replicated per-token classification head.
- PROVIDER_CLASS#
None
- provider_bridge(
- hf_pretrained: megatron.bridge.models.hf_pretrained.token_classification.PreTrainedTokenClassification,
Create a serializable token-classification provider from an HF config.
- Parameters:
hf_pretrained â Lazy Hugging Face token-classification wrapper.
- Returns:
A provider carrying the base VLM and classification-head configuration.
- mapping_registry() megatron.bridge.models.conversion.mapping_registry.MegatronMappingRegistry#
Return mappings for the Qwen3.5 base model and classification head.