← Back to Pull requests

[model] feat: add Qwen3.5 text model bridges (dense + MoE) #3769

Closed
unknown closed this pull request without merging on Jun 01, 2026 17:04 UTC
View on GitHub
unknown unknown commented on May 10, 2026 11:40 UTC
Author

What does this PR do?

Add Megatron Bridge support for Qwen3.5 language models (Qwen3.5-LM), which are the text-only component extracted from Qwen3.5-VL. The model architecture is similar to Qwen3-Next (hybrid GDN + standard attention)~, but the HF checkpoint organization follows the Qwen3.5-VL convention (model.language_model. prefix instead of model.layers.)~. Additionally, the MTP mcore path is renamed from transformer_layer to mtp_model_layer to align with Megatron-Core's actual module naming.

Changelog

  • Add Qwen3_5Bridge for dense Qwen3.5 language models (qwen3_5_bridge.py)

  • Add Qwen3_5MoEBridge for MoE variant of Qwen3.5 language models (qwen3_5_moe_bridge.py)

  • Register both bridges in models/qwen/__init__.py with model types qwen3_5_text and qwen3_5_moe_text

  • Fix MTP parameter paths in qwen3_bridge.py: mtp.layers..transformer_layer. → mtp.layers..mtp_model_layer.

  • Fix MTP parameter paths in qwen3_next_bridge.py: same rename as above (13 mappings updated)

  • Add comprehensive unit tests for both bridges (test_qwen35_bridge.py)
  • Second commit changelog

    - Rename Qwen3_5Bridge → Qwen35Bridge and Qwen3_5MoEBridge → Qwen35MoEBridge
    to follow project naming conventions.
    - Merge dense and MoE text bridges into a single qwen35_bridge.py module with
    extracted helper functions and static mapping methods that are consumed by both text and VL bridges, eliminating code duplication.
    - Fix incorrect HF param paths in dense LM mappings (removed spurious language_model nesting).
    - Remove transpose_on_export from Qwen3.5 bridge to fix shape mismatch.
    - Add functional tests for dense and MoE bridges.

    Key design decisions

    | Aspect | Qwen3.5-LM | Qwen3-Next (reference) |
    |--------|-----------|----------------------|
    | HF param prefix | model.language_model. | model.layers. |
    | Decoder expert format | Fused (gate_up_proj) | Individual (gate_proj/up_proj) |
    | MTP expert format | Individual per-expert | Individual per-expert |
    | GDN linear mapping | GDNLinearMappingSeparate (4-tensor: qkv/z/b/a) | GDNLinearMapping (2-tensor: qkvz/ba) |

    GitHub Actions CI

    See the CI section in the Contributing doc for how to trigger the CI. A Nvidia developer will need to approve and trigger the CI for external contributors.

    Before your PR is "Ready for review"

    Pre checks:

  • Make sure you read and followed Contributor guidelines

  • Did you write any new necessary tests? — Unit tests for both dense and MoE bridges added

  • Did you add or update any necessary documentation?

  • Does the PR affect components that are optional to install? — No, uses existing dependencies only
  • Additional Information

  • Qwen3.5-LM is the standalone text model extracted from Qwen3.5-VL, sharing the same hybrid GDN+Attention architecture as Qwen3-Next ~but with VL-style checkpoint organization (This is because Hugging Face transformers do not accept other state dict organizations)~.

  • Standalone Qwen3.5-LM is necessary for me and other guys. Please refer to #2973.

  • Potential third party bug that brakes Qwen3.5-VL unit tests: (https://github.com/huggingface/transformers/issues/45375).
  • Acknowledgements

    From Engine Architecture Group 5, Engine Infrastructure Department, Xiaohongshu (RedNote).

    Note to maintainers: please include the following trailers when squashing:

    >
    > Co-authored-by: HuayiJin <27394199+HuayiJin@users.noreply.github.com>
    > Co-authored-by: whitelok <whitelok@163.com>
    > 

    Diff: 471 lines (+353 / -118) across 5 files Reviewer: HowardZorn Review duration: 32004m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.46) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.46 · 471 lines diff across 5 files
    0.46
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.368
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3769"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.7% (MEDIUM) · Higher = larger blast radius
    45.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.1% · Safe to merge
    18.1%