bridge.models.qwen.modeling_qwen35.hybrid#

Qwen3.5 composition of Core’s separate attention and feed-forward layers.

Module Contents#

Classes#

Qwen35HybridAttentionLayer

Keep TE’s class-level graph wrappers separate from the MoE/MLP subclasses.

Functions#

qwen35_pipeline_pattern

Assign Hybrid positions to PP/VPP stages without splitting HF blocks.

qwen35_hybrid_pattern

Expand each HF block into a GDN/attention position followed by its MLP.

qwen35_hybrid_stack_spec

Keep Core’s GDN and MLP kernels while enabling Qwen’s per-head Q/K norms.

configure_qwen35_hybrid

Convert the language configuration from HF block coordinates to Hybrid positions.

qwen35_hf_layer_config

Recover HF block counts and attention order from a finalized Hybrid pattern.

qwen35_hybrid_mappings

Translate GPT block templates to split Hybrid positions, retaining expert wildcards.

API#

class bridge.models.qwen.modeling_qwen35.hybrid.Qwen35HybridAttentionLayer#

Bases: megatron.core.transformer.transformer_layer.TransformerLayer

Keep TE’s class-level graph wrappers separate from the MoE/MLP subclasses.

Capturing TransformerLayer and its subclasses together can retain an inherited autocast wrapper on uncaptured MTP layers after graph creation. A sibling attention class preserves those layers’ quantization contexts.

bridge.models.qwen.modeling_qwen35.hybrid.qwen35_pipeline_pattern(
config: megatron.core.transformer.transformer_config.TransformerConfig,
pattern: str,
) → str#

Assign Hybrid positions to PP/VPP stages without splitting HF blocks.

bridge.models.qwen.modeling_qwen35.hybrid.qwen35_hybrid_pattern(
text_config: transformers.PretrainedConfig,
) → str#

Expand each HF block into a GDN/attention position followed by its MLP.

bridge.models.qwen.modeling_qwen35.hybrid.qwen35_hybrid_stack_spec() → megatron.core.transformer.spec_utils.ModuleSpec#

Keep Core’s GDN and MLP kernels while enabling Qwen’s per-head Q/K norms.

bridge.models.qwen.modeling_qwen35.hybrid.configure_qwen35_hybrid(
config_kwargs: dict[str, Any],
text_config: transformers.PretrainedConfig,
) → None#

Convert the language configuration from HF block coordinates to Hybrid positions.

bridge.models.qwen.modeling_qwen35.hybrid.qwen35_hf_layer_config(pattern: str) → dict[str, Any]#

Recover HF block counts and attention order from a finalized Hybrid pattern.

bridge.models.qwen.modeling_qwen35.hybrid.qwen35_hybrid_mappings(
mappings: list[megatron.bridge.models.conversion.param_mapping.MegatronParamMapping],
*,
num_layers: int,
) → list[megatron.bridge.models.conversion.param_mapping.MegatronParamMapping]#

Translate GPT block templates to split Hybrid positions, retaining expert wildcards.