Support Qwen3.6 hybrid-attention blockwise calibration#34
Merged
FKKimura merged 6 commits intoJul 22, 2026
Merged
Conversation
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.
Summary
Extended
onecomp/utils/blockwise.pycalibration handling to support Qwen3.6's hybrid decoder, which mixes GatedDeltaNetlinear_attentionlayers with regularfull_attentionlayers (the samelayer_typesscheme as transformers'Qwen3_5architecture), alongside the existing Gemma-stylefull_attention/sliding_attentionmixed-attention handling.Added dedicated test coverage in
tests/onecomp/utils/test_blockwise.pyfor the new hybrid-attention logic, which previously had no tests.Details
Qwen3.6 support (GatedDeltaNet hybrid linear-attention / full-attention layers)
onecomp/utils/blockwise.pyto support Qwen3.6's hybrid decoder, which mixes GatedDeltaNetlinear_attentionlayers with regularfull_attentionlayers (samelayer_typesscheme as transformers'Qwen3_5architecture)linear_attention+full_attentionmix (is_qwen35_like_hybrid), alongside the existing Gemma-stylefull_attention+sliding_attentionmix (is_gemma_like_mixed_attention);has_mixed_typesis true when either applies_create_linear_attention_mask(), ported from transformers'Qwen3_5Model._update_linear_attn_mask: returnsNonefor cached-decode or no-padding forwards, otherwise the boolean padding mask_compute_per_type_attention_masks()now dispatches to a Qwen-hybrid mask-creator mapping (linear_attention->_create_linear_attention_mask,full_attention->create_causal_mask) instead of the Gemma pair (create_causal_mask/create_sliding_window_causal_mask) when the model's layer types match the hybrid setTests
_get_block_layer_type'slinear_attnfallback and priority order,_create_linear_attention_mask's cached/no-padding/padding branches, the mask-creator dispatch added to_compute_per_type_attention_masksfor{"linear_attention", "full_attention"}layer-type sets (with a regression guard for the existing Gemma-style{"full_attention", "sliding_attention"}path), and end-to-end hybrid-layer-type detection inget_blocks_and_inputs(tests/onecomp/utils/test_blockwise.py)Validation
Verified the implementation with the following script: