Gated DeltaNet layer

hh [B, 1, 8192]to hnexth_{\mathrm{next}} [B, 1, 8192]

decode · one new token after P=1,000P = 1{,}000 positions · kept between calls by a GDN layer: its memory, 128 matrices of 128 × 128, and the last 4 inputs, 20,480 wide, of its short convolution · 2,179,072 values at any P

Parameters26,262,741,376 × 69 layers

26,262,741,376 parameters per GDN layer, across its learned components

ComponentParameters
GDN RMSNorm8,192
Gated DeltaNet438,387,072
MoE RMSNorm8,192
Mixture of experts25,824,337,920
Per-instance total26,262,741,376

One of 69 independent GDN layers.

Explanation

Layers 1, 2, 3, 5, 6, 7, …, 91: layer_types names them linear_attention (config.json).

Sources

In codeQwen3_5MoeDecoderLayer(config, layer_idx)

Open pinned code ↗

Direct evidence

A decoder layer has Gated DeltaNet or gated attention by its layer type, the MoE block, and two RMSNorms.

modeling_qwen3_5_moe.py 933–944 ↗ · huggingface/transformers @ 18329f106538

Excerpt
class Qwen3_5MoeDecoderLayer(GradientCheckpointingLayer):
    def __init__(self, config: Qwen3_5MoeTextConfig, layer_idx: int):
        super().__init__()
        self.hidden_size = config.hidden_size
        self.block_type = config.layer_types[layer_idx]
        if self.block_type == "linear_attention":
            self.linear_attn = Qwen3_5MoeGatedDeltaNet(config, layer_idx)
        elif self.block_type == "full_attention":
            self.self_attn = Qwen3_5MoeAttention(config, layer_idx)
        self.mlp = Qwen3_5MoeSparseMoeBlock(config)
        self.input_layernorm = Qwen3_5MoeRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
        self.post_attention_layernorm = Qwen3_5MoeRMSNorm(config.hidden_size, eps=config.rms_norm_eps)

A layer is pre-norm: the token mixer reads the normalised input and its output is added to the residual; the MoE reads the normalised sum and its output is added again.

modeling_qwen3_5_moe.py 946–989 ↗ · huggingface/transformers @ 18329f106538

Excerpt
    def forward(
        self,
        hidden_states: torch.Tensor,
        position_embeddings: tuple[torch.Tensor, torch.Tensor],
        attention_mask: torch.Tensor | None = None,
        position_ids: torch.LongTensor | None = None,
        past_key_values: Cache | None = None,
        **kwargs: Unpack[FlashAttentionKwargs],
    ) -> torch.FloatTensor:
        residual = hidden_states

        hidden_states = self.input_layernorm(hidden_states)

        # Token Mixer
        if self.block_type == "linear_attention":
            hidden_states = self.linear_attn(
                hidden_states=hidden_states,
                cache_params=past_key_values,
                attention_mask=attention_mask,
                **kwargs,
            )
        elif self.block_type == "full_attention":
            # Self Attention
            hidden_states, _ = self.self_attn(
                hidden_states=hidden_states,
                attention_mask=attention_mask,
                position_ids=position_ids,
                past_key_values=past_key_values,
                position_embeddings=position_embeddings,
                **kwargs,
            )

        hidden_states = residual + hidden_states

        # Fully Connected
        residual = hidden_states
        hidden_states = self.post_attention_layernorm(hidden_states)
        hidden_states = self.mlp(hidden_states)
        # For the MoE layers, we need to unpack
        if isinstance(hidden_states, tuple):
            hidden_states, _ = hidden_states
        hidden_states = residual + hidden_states

        return hidden_states

When layer_types is not given, a layer is full_attention when its 1-based index is divisible by full_attention_interval and linear_attention otherwise; the checkpoint’s configuration lists them explicitly in that pattern.

configuration_qwen3_5_moe.py 115–129 ↗ · huggingface/transformers @ 18329f106538

Excerpt
    layer_types: list[str] | None = None

… lines 116–121 omitted …

    def __post_init__(self, **kwargs):
        kwargs.setdefault("partial_rotary_factor", 0.25)  # assign default for BC
        if self.layer_types is None:
            interval_pattern = kwargs.pop("full_attention_interval", 4)
            self.layer_types = [
                "linear_attention" if bool((i + 1) % interval_pattern) else "full_attention"
                for i in range(self.num_hidden_layers)
            ]