DeepSeek made every attention layer cheaper and kept them all. Qwen took the other road: it removed most attention layers. From Qwen3-Next on, three of every four layers are Gated DeltaNet (GDN), whose per-sequence state has a fixed size whatever the context; only every fourth layer keeps a growing KV cache. The later generations then worked on what that left over: the remaining attention layers (a gate, then sparse reads), the residual stream (widened and gated), and parameters that cost no FLOPs (n-gram tables).
As in the DeepSeek lesson, the components are derived in their own lessons — the delta rule and chunkwise GDN in linear attention and SSMs, QSA next to DSA in sparse attention, the output gate and Gated Residual in stability components, n-gram embeddings in MTP and embeddings. The per-report details are in the reviews of Qwen3, Qwen3-Next and Qwen3.5 and Qwen3.8-Flash-Next. One caveat: Qwen3-Next and Qwen3.5 have no technical report; their evidence comes from blogs, model cards, the Gated Attention paper and the ablations in the later Qwen3.8 report.
The hybrid’s memory bill
With softmax-attention layers (each storing bytes per token) and linear layers (each holding a state of bytes), memory per sequence is
For GDN, is one matrix per value head plus a short-convolution buffer. With Qwen3-Next’s config (linear_num_value_heads: 32, key/value head dim 128, FP32 state as in mamba_ssm_dtype), MB per layer, 77 MB for 36 layers. Each gated-attention layer keeps bytes per token (2 KV heads of 256, BF16). Compare an all-attention model with the same number of active parameters, Qwen3-30B-A3B ( B per token). The hybrid holds less memory only once the KV it avoids pays for its state:
Below about a thousand tokens the hybrid is the more expensive model to hold in memory; at 256K it holds a quarter. Interestingly, the per-layer KV entry is 2,048 B in every Qwen generation (4 KV heads × 128 in Qwen3, 2 × 256 afterwards): what changed is how many layers carry one. The same arithmetic applies to compute: a GDN layer’s decode cost is a constant (about MACs per head, our estimate), an attention layer’s grows with .
DeepSeek은 모든 attention 층을 싸게 만들고 그대로 두었다. Qwen은 다른 길을 갔다. attention 층 대부분을 없앴다. Qwen3-Next부터 네 층 중 세 층은 Gated DeltaNet(GDN)으로, 시퀀스당 상태 크기가 문맥과 무관하게 고정이다. 네 번째 층만 자라는 KV 캐시를 가진다. 이후 세대는 남은 것을 다듬었다. 남은 attention 층(gate, 그다음 sparse 읽기), residual stream(넓히고 gate), 그리고 FLOPs가 들지 않는 파라미터(n-gram 테이블).
DeepSeek 레슨처럼 부품은 각자의 레슨에서 유도한다. delta rule과 chunkwise GDN은 linear attention과 SSM, DSA 옆의 QSA는 sparse attention, 출력 gate와 Gated Residual은 안정화 부품, n-gram 임베딩은 MTP와 임베딩. 보고서별 세부는 Qwen3, Qwen3-Next와 Qwen3.5, Qwen3.8-Flash-Next 리뷰에 있다. 주의할 점 하나: Qwen3-Next와 Qwen3.5에는 기술 보고서가 없다. 근거는 블로그, 모델 카드, Gated Attention 논문, 그리고 나중에 나온 Qwen3.8 보고서의 ablation이다.
하이브리드의 메모리 청구서
softmax attention 층 개(각각 토큰당 바이트 저장)와 linear 층 개(각각 바이트 상태 보유)가 있으면 시퀀스당 메모리는
GDN의 는 value head마다 행렬 하나와 짧은 convolution 버퍼다. Qwen3-Next config(linear_num_value_heads: 32, key·value head 차원 128, mamba_ssm_dtype처럼 FP32 상태)로 MB/층, 36층이면 77 MB. gated attention 층 하나는 토큰당 바이트를 보관한다(256차원 KV head 2개, BF16). 같은 활성 파라미터의 전부-attention 모델 Qwen3-30B-A3B(토큰당 B)와 비교하면, 하이브리드는 피한 KV가 상태 비용을 갚은 뒤에야 메모리를 덜 쓴다.
약 천 토큰 아래에서는 하이브리드가 메모리상 더 비싼 모델이다. 256K에서는 1/4만 쓴다. 흥미롭게도 층당 KV 항목은 모든 Qwen 세대에서 2,048 B다(Qwen3는 128차원 KV head 4개, 이후는 256차원 2개). 바뀐 것은 그 항목을 가진 층의 수다. 계산도 같은 산수다. GDN 층의 디코드 비용은 상수(head당 약 MAC, 우리 추정)이고 attention 층의 비용은 과 함께 자란다.
2025-04 · 235B / 22B · 94층 · d 40962025-04 · 235B / 22B · 94 layers · d 4096
2025-09 · 80B / 3B · 48층 · d 20482025-09 · 80B / 3B · 48 layers · d 2048 · 강조 = Qwen3 대비 바뀐 부분highlight = changed since Qwen3
2026-02 · 397B / 17B · 60층 · d 40962026-02 · 397B / 17B · 60 layers · d 4096 · 강조 = Qwen3-Next 대비 바뀐 부분highlight = changed since Qwen3-Next
2026-08 · 125B / 6B (+51B n-gram) · 48층 · d 25602026-08 · 125B / 6B (+51B n-gram) · 48 layers · d 2560 · 강조 = Qwen3.5 대비 바뀐 부분highlight = changed since Qwen3.5
config.json (top row: token mixer, bottom row: FFN); the block below highlights what changed against the previous generation, and the right column names the bottleneck each change attacked with the evidence its report gives. Stats are computed from the configs at the chosen context (decode of one token; FLOPs = 2 × (active params + attention MACs); KV in each model's shipped format). Watch two numbers move: KV per token and layers whose KV grows with context. 세대를 클릭하세요. 띠는 모델 config.json의 모든 층을 그린다(윗줄 token mixer, 아랫줄 FFN). 아래 블록은 직전 세대 대비 바뀐 부분을 강조하고, 오른쪽 열은 각 변경이 노린 병목과 보고서의 근거를 적는다. 통계는 고른 문맥에서 config로 계산한 값이다(토큰 하나 디코드, FLOPs = 2 × (활성 파라미터 + attention MAC), KV는 각 모델이 실제 쓰는 형식). 두 숫자가 어떻게 움직이는지 보라: 토큰당 KV와 문맥에 따라 KV가 자라는 층 수. Qwen3: the conventional baseline
Qwen3 (April–May 2025) is the last all-attention generation: Qwen3-235B-A22B has 94 GQA layers (64 query, 4 KV heads of 128), so 192.5 KB of KV per token. Its two architectural changes over Qwen2.5 are about stability and balance, not cost. QK-Norm (RMSNorm on and , QKV bias removed) keeps attention logits from saturating the softmax at large learning rates. The MoE drops the shared expert (128 experts, top-8) and computes the load-balancing loss over the global batch instead of each micro-batch: a micro-batch LBL forces every packed, single-domain sequence to spread over all experts, which penalises specialisation rather than imbalance. Qiu et al. measure the effect directly (Balance BSZ 16→512: average PPL 5.778→5.603, GSM8k 48.07→54.28 on a 15A2.54B MoE).
Long context was handled by YaRN on top of full attention, so the cost line in the second figure grows as in every layer.
Qwen3-Next: remove three quarters of the attention
Qwen3-Next-80B-A3B (September 2025) changes all three slots at once.
Token mixer: 3 GDN : 1 gated attention. The config’s full_attention_interval: 4 produces the strip in the figure: twelve repeats of [GDN, GDN, GDN, attention]. GDN is the delta rule with a data-dependent decay,
an online regression from keys to values that can overwrite an association () and forget globally (). Why GDN rather than Mamba-2 or a sliding window, and why keep any attention at all? The blog states that GDN had better in-context learning than SWA or Mamba-2 and that the 3:1 mix beat every single architecture; the numbers came later, in the Qwen3.8 report’s controlled comparison on a 25B-A3B MoE with the Qwen3.5 structure (Table 1): average 49.87 for all full attention, 51.15 for an SWA(128) hybrid, 53.81 for the GDN hybrid, which wins 8 of 9 benchmarks. A fixed-size state cannot store arbitrarily many exact associations (recall degrades once you write more than about independent keys per head), which is the case for keeping one global-attention layer in four.
Gated attention. The remaining 12 attention layers multiply the SDPA output by a sigmoid gate computed from the current token, , use head dimension 256 (fewer, wider attention layers) and rotate only the first 25% of dimensions (partial_rotary_factor: 0.25). The gate gives a head a way to output nothing without parking its probability mass on a sink token. In the Gated Attention paper (15A2B MoE, 400B tokens) the elementwise gate lowers average PPL 6.026→5.761, far more than spending the same parameters on KV heads or experts; it makes a learning rate that diverges without it train fine; and it lifts RULER at 128K from 31.65 to 58.82 after YaRN extension.
FFN: 512 experts, 10 routed + 1 shared. Expert width 512 and about 3.7% of experts active per token. The blog’s justification is a scaling observation — under global-batch balancing, more total experts at fixed active experts kept lowering the loss — the same law Kimi K2 fitted (Kimi lineage). The shared expert comes back.
Stability. Having seen QK-Norm weights grow abnormally in Qwen3, Qwen3-Next uses zero-centred RMSNorm with weight decay on the norm weights and normalises the router at initialisation. Add MTP trained over several steps for speculative decoding. The blog reports training at under 80% of the GPU hours of Qwen3-30B-A3B and 9.3% of the compute of Qwen3-32B, and decode throughput above 10× Qwen3-32B beyond 32K context — a ratio that also contains the 3B vs 32B difference in active parameters.
Qwen3.5: the same block, scaled
Qwen3.5-397B-A17B (February 2026) is the Qwen3-Next design at 60 layers ( [3 GDN, 1 attention]), , GDN with 64 value heads, 32 query heads in attention, experts of width 1,024, a 248,320-token vocabulary and native multimodality. Nothing in the token mixer is new — open its tab and only sizes are highlighted. The blog’s decode throughput is 3.5× (32K) and 7.2× (256K) that of Qwen3-235B-A22B: the ratio grows with context exactly as the memory model predicts, since one model’s KV grows 6.3× faster per token than the other’s.
Qwen3.8-Flash-Next: rework what the hybrid left
With three quarters of the layers fixed-cost, the remaining quarter became the bill. The NumPy block below shows it: at 256K, the 12 attention layers account for about 89% of Qwen3-Next’s decode FLOPs, even though they are a quarter of the layers. Qwen3.8-Flash-Next (125B total, 6B active, August 2026; “an experimental preview of the architecture that will underpin Qwen4”) made four changes, each with an ablation in an architecture-only report.
- Qwen Sparse Attention. The attention layers become sparse. An MQA indexer (4 query heads, one shared 128-d key) scores average-pooled blocks of 4 tokens and keeps 512 blocks (2,048 tokens) plus the current block. Pooling is the fix for DSA’s residual problem: DSA’s indexer scores every token, QSA’s scores blocks. Against full attention: 8-benchmark average 75.9→76.8, RULER 512K–1M 90.08→93.00, attention kernels 7.6× faster in prefill and 4.9× in decode at 1M. It is introduced in continued pre-training (indexer distillation, then sparse training) rather than from scratch.
- Gated Residual. The residual becomes 4 branches; a block reads them through a per-branch, per-channel sigmoid gate predicted from all branches (rank-320 bottleneck), and writes with one scalar per branch. There is no branch-mixing matrix , unlike HC/mHC, so there is one fewer full read of the residual state per block — the dominant decode cost of a widened stream. On 25B-A3B, 560B tokens: pre-norm loss 1.617 → static mHC 1.596 → dynamic mHC 1.594 → GR 1.590, benchmark average 50.91→54.66. The residual is stored in FP8 because the gates bound what is written into it.
- n-gram embeddings. A 20M-slot bigram/trigram hash table (51B parameters, host memory, prefetched because addresses depend only on input tokens) added at layer 2: average 45.44→47.94 at a fixed parameter budget. But growing the n-gram vocabulary kept lowering loss while MATH fell — the report’s own example that loss and benchmarks can disagree.
- Smaller fixes and the optimiser. GDN’s output gate SiLU→sigmoid; Muon on 2-D weights with a refitted LR/batch scaling law, no batch warm-up and no loss spikes without qk-clip. A NoPE variant was indistinguishable in pre-training but produced far more endless generations after post-training, so RoPE stayed.
The report’s headline: this 125B-A6B base leads the 397B-A17B base on 8 of 14 benchmarks with 1/3 of the active parameters, 1/3 of the tokens and about 1/9 of the training FLOPs.
Qwen3: 전통적인 기준선
Qwen3(2025년 4–5월)는 마지막 전부-attention 세대다. Qwen3-235B-A22B는 GQA 94층(query 64, 128차원 KV head 4)이라 토큰당 KV가 192.5 KB다. Qwen2.5 대비 구조 변경 둘은 비용이 아니라 안정성과 균형에 관한 것이다. QK-Norm(·에 RMSNorm, QKV bias 제거)은 큰 학습률에서 attention 로짓이 softmax를 포화시키지 않게 한다. MoE는 shared expert를 빼고(128 expert, top-8) load-balancing loss를 micro-batch마다가 아니라 global batch에서 계산한다. micro-batch LBL은 단일 도메인으로 packing된 시퀀스 하나하나가 모든 expert로 퍼지도록 강요해 불균형이 아니라 전문화를 벌한다. Qiu et al.이 효과를 직접 쟀다(Balance BSZ 16→512: 15A2.54B MoE에서 평균 PPL 5.778→5.603, GSM8k 48.07→54.28).
긴 문맥은 full attention 위의 YaRN으로 처리했으므로 두 번째 그림의 비용선은 모든 층에서 로 자란다.
Qwen3-Next: attention의 3/4을 없앤다
Qwen3-Next-80B-A3B(2025년 9월)는 세 자리를 한꺼번에 바꾼다.
토큰 혼합: GDN 3 : gated attention 1. config의 full_attention_interval: 4가 그림의 띠를 만든다. [GDN, GDN, GDN, attention]의 12회 반복. GDN은 데이터 의존 decay를 가진 delta rule이다.
key에서 value로 가는 온라인 회귀로, 연관을 덮어쓰고() 전역적으로 잊을 수 있다(). 왜 Mamba-2나 sliding window가 아니라 GDN이고, 왜 attention을 조금이라도 남기나? 블로그는 GDN이 SWA나 Mamba-2보다 in-context learning이 낫고 3:1 혼합이 어떤 단일 구조보다 낫다고만 썼다. 숫자는 나중에 Qwen3.8 보고서가 Qwen3.5 구조의 25B-A3B MoE로 한 대조 비교에서 나왔다(표 1). 평균은 전부 full attention 49.87, SWA(128) 하이브리드 51.15, GDN 하이브리드 53.81이고 GDN 하이브리드가 9개 중 8개 벤치마크에서 이긴다. 고정 크기 상태는 정확한 연관을 무한히 담을 수 없다(head당 대략 개보다 많은 독립 key를 쓰면 recall이 떨어진다). 네 층에 한 층 전역 attention을 남기는 이유다.
Gated attention. 남은 attention 12층은 SDPA 출력에 현재 토큰에서 계산한 sigmoid gate를 곱하고 , head 차원 256을 쓰며(더 적고 더 넓은 attention 층), 차원의 앞 25%만 회전시킨다(partial_rotary_factor: 0.25). gate는 head에게 확률 질량을 sink 토큰에 주차하지 않고도 아무것도 출력하지 않을 방법을 준다. Gated Attention 논문(15A2B MoE, 400B 토큰)에서 원소별 gate는 평균 PPL을 6.026→5.761로 낮춘다. 같은 파라미터를 KV head나 expert에 쓰는 것보다 훨씬 크다. gate 없이 발산하는 학습률도 학습되게 하고, YaRN 확장 뒤 128K RULER를 31.65에서 58.82로 올린다.
FFN: expert 512개, routed 10 + shared 1. expert 폭 512, 토큰당 약 3.7%의 expert가 활성. 블로그의 근거는 스케일링 관찰이다. global-batch 균형 아래에서 활성 expert 수를 고정하고 총 expert를 늘리면 loss가 계속 내려갔다. Kimi K2가 적합한 것과 같은 법칙이다(Kimi 계보). shared expert가 돌아왔다.
안정성. Qwen3에서 QK-Norm weight가 비정상적으로 커지는 것을 보고, Qwen3-Next는 zero-centred RMSNorm에 norm weight decay를 걸고 router를 초기화 때 정규화한다. 추측 디코딩용으로 여러 단계를 함께 학습한 MTP도 더했다. 블로그는 학습이 Qwen3-30B-A3B GPU 시간의 80% 미만, Qwen3-32B 계산의 9.3%였고, 32K 이상 문맥에서 디코드 처리량이 Qwen3-32B의 10배를 넘는다고 보고한다. 이 비율에는 활성 파라미터 3B vs 32B의 차이도 섞여 있다.
Qwen3.5: 같은 블록을 키운다
Qwen3.5-397B-A17B(2026년 2월)는 Qwen3-Next 설계를 60층( [GDN 3, attention 1]), , value head 64개의 GDN, attention의 query head 32개, 폭 1,024 expert, 248,320 토큰 어휘, 네이티브 멀티모달로 키운 것이다. 토큰 혼합에는 새것이 없다. 탭을 열면 크기만 강조된다. 블로그의 디코드 처리량은 Qwen3-235B-A22B의 3.5배(32K), 7.2배(256K)다. 비율이 문맥과 함께 커지는 것은 메모리 모델이 예측하는 그대로다. 한 모델의 토큰당 KV가 다른 모델보다 6.3배 빨리 자라기 때문이다.
Qwen3.8-Flash-Next: 하이브리드가 남긴 것을 고친다
층의 3/4이 고정 비용이 되자 남은 1/4이 청구서가 됐다. 아래 NumPy 블록이 보여 준다. 256K에서 attention 12층은 층 수로는 1/4이지만 Qwen3-Next 디코드 FLOPs의 약 89%를 차지한다. Qwen3.8-Flash-Next(총 125B, 활성 6B, 2026년 8월, “Qwen4의 기반이 될 아키텍처의 실험적 preview”)는 네 가지를 바꿨고, 아키텍처 전용 보고서에 각각 ablation이 있다.
- Qwen Sparse Attention. attention 층이 sparse가 된다. MQA indexer(query head 4개, 공유 128차원 key 하나)가 4토큰 평균 풀링 블록에 점수를 매겨 블록 512개(2,048 토큰)와 현재 블록을 남긴다. 풀링이 DSA의 잔여 문제에 대한 해법이다. DSA indexer는 모든 토큰에, QSA indexer는 개 블록에 점수를 매긴다. full attention 대비 8개 벤치 평균 75.9→76.8, RULER 512K–1M 90.08→93.00, 1M에서 attention kernel이 prefill 7.6배, decode 4.9배 빠르다. 처음부터가 아니라 연속 사전학습(indexer 증류, 그다음 sparse 학습)에서 들어간다.
- Gated Residual. residual이 4개 branch가 된다. 블록은 모든 branch로부터 예측한 branch·채널별 sigmoid gate(rank 320 병목)로 읽고, branch당 스칼라 하나로 쓴다. HC/mHC와 달리 branch 혼합 행렬 가 없어서 블록마다 residual 상태 전체 읽기가 하나 줄어든다. 넓힌 stream의 디코드 지배 비용이다. 25B-A3B, 560B 토큰에서 pre-norm loss 1.617 → 정적 mHC 1.596 → 동적 mHC 1.594 → GR 1.590, 벤치 평균 50.91→54.66. gate가 쓰이는 값을 묶어 주므로 residual은 FP8로 저장한다.
- n-gram 임베딩. 슬롯 20M개의 bigram/trigram 해시 테이블(51B 파라미터, host 메모리, 주소가 입력 토큰에만 의존하므로 prefetch)을 층 2에 넣었다. 고정 파라미터 예산에서 평균 45.44→47.94. 그러나 n-gram 어휘를 키우면 loss는 계속 내려가는데 MATH는 떨어졌다. loss와 벤치마크가 어긋날 수 있다는 보고서 자신의 예다.
- 작은 수정과 옵티마이저. GDN 출력 gate SiLU→sigmoid. 2-D 가중치에 Muon, LR·batch 스케일링 법칙 재적합, batch warm-up 없음, qk-clip 없이 loss spike 0회. NoPE 변형은 사전학습에서는 구별되지 않았지만 사후학습 뒤 끝없는 생성이 훨씬 많아서 RoPE를 남겼다.
보고서의 헤드라인: 이 125B-A6B base는 활성 파라미터 1/3, 토큰 1/3, 학습 FLOPs 약 1/9로 397B-A17B base를 14개 중 8개 벤치마크에서 앞선다.
Reading the crossover figure
- KV + state per sequence at the far left (1K): the hybrids sit above the all-attention models of matching active size — Qwen3-Next’s 77 MB of GDN state is more than 1K tokens of Qwen3-30B-A3B’s KV. The hollow circle at ~1K marks where that flips; Qwen3.5-397B crosses Qwen3-235B at ~1.2K.
- Drag the softmax-attention interval to 1 (every layer attention): all hybrid lines jump onto all-attention slopes. Set it to 8: KV shrinks again, but the state grows (more GDN layers) — and, more importantly, you are now relying on a fixed state for most of the model’s recall. The memory curve alone cannot tell you where to stop; Qwen’s choice of 4 comes from the quality side (the 3:1 > every single architecture claim, and Kimi Linear’s ratio sweep in the Kimi lineage).
- FLOPs per token: Qwen3-Next and Qwen3.5-35B bend upward past ~32K because their attention layers are dense; Qwen3.8’s line goes flat after ~2K tokens — that is QSA, whose per-layer crossover with dense attention is tokens.
- HBM bytes per token, batch 1: weights decide and Qwen3-Next / Qwen3.5-35B (3B active) win. Batch 512 at 256K: the KV read decides; Qwen3.8 reads only 2,048 tokens’ KV per attention layer plus a quarter-resolution indexer key, and wins.
import numpy as np
# Per-layer cache sizes from config.json (BF16 KV; GDN state FP32 as in mamba_ssm_dtype; short-conv state BF16)
def kv_entry(kv_heads, head_dim): # K and V, BF16, bytes per token per attention layer
return 2 * kv_heads * head_dim * 2
def gdn_state(v_heads, qk_heads, dk=128, dv=128, conv=4):
return v_heads * dk * dv * 4 + (2 * qk_heads * dk + v_heads * dv) * (conv - 1) * 2
# name: (layers, full_attention_interval, q_heads, kv_heads, head_dim, GDN V heads, active B)
CFG = {
'Qwen3-30B-A3B': (48, 1, 32, 4, 128, 0, 3.3),
'Qwen3-235B-A22B': (94, 1, 64, 4, 128, 0, 22),
'Qwen3-Next-80B-A3B': (48, 4, 16, 2, 256, 32, 3),
'Qwen3.5-35B-A3B': (40, 4, 16, 2, 256, 32, 3),
'Qwen3.5-397B-A17B': (60, 4, 32, 2, 256, 64, 17),
'Qwen3.8-Flash-Next': (48, 4, 24, 2, 256, 48, 6),
}
def layout(name, interval=None): # reproduces config layer_types: 3 x linear, then full
n, iv = CFG[name][0], interval or CFG[name][1]
return ['full' if iv == 1 or (i + 1) % iv == 0 else 'linear' for i in range(n)]
def memory(name, L, interval=None): # bytes per sequence at context L
n, iv, q, kv, hd, vh, act = CFG[name]
lay = layout(name, interval)
n_full = lay.count('full')
extra = n_full * (L // 4) * 256 if name.startswith('Qwen3.8') else 0 # QSA: pooled 128-d indexer key per 4 tokens
return n_full * kv_entry(kv, hd) * L + lay.count('linear') * gdn_state(vh, 16) + extra
lt = layout('Qwen3.5-397B-A17B')
print("Qwen3.5-397B layout:", lt[:4], "... full:", lt.count('full'), "linear:", lt.count('linear'), "(config: 15 / 45)")
for name in CFG:
n, iv, q, kv, hd, vh, act = CFG[name]
lay = layout(name)
print(f"{name:19s} KV/token {lay.count('full') * kv_entry(kv, hd):7,d} B fixed state {lay.count('linear') * gdn_state(vh, 16) / 1e6:6.1f} MB")
# crossover: the hybrid's fixed state is paid back once the KV it avoids exceeds it
for small, hyb in [('Qwen3-30B-A3B', 'Qwen3-Next-80B-A3B'), ('Qwen3-235B-A22B', 'Qwen3.5-397B-A17B')]:
slope = memory(small, 1) - memory(small, 0)
slope_h = memory(hyb, 1) - memory(hyb, 0)
print(f"{hyb} holds less than {small} above L* = {memory(hyb, 0) / (slope - slope_h):,.0f} tokens")
for L in (4096, 32768, 262144):
print(f"L={L:>6}: " + " | ".join(f"{k} {memory(k, L) / 1e9:5.2f} GB" for k in ['Qwen3-30B-A3B', 'Qwen3-Next-80B-A3B', 'Qwen3.8-Flash-Next']))
# why QSA: in a 3:1 hybrid at long context, the 1/4 attention layers still dominate FLOPs
def flops(name, L, sparse=False, budget=2048, r=4):
n, iv, q, kv, hd, vh, act = CFG[name]
lay = layout(name)
per_key = 2 * q * hd # QK + AV MACs per cached token
attn = (L // r) * 4 * 128 + min(L, budget + r - 1) * per_key if sparse else L * per_key
lin = 4 * vh * 128 * 128 # GDN decode, ~4 dk dv per head (estimate)
return 2 * (act * 1e9 + lay.count('full') * attn + lay.count('linear') * lin), 2 * lay.count('full') * attn
for L in (32768, 262144):
f, a = flops('Qwen3-Next-80B-A3B', L)
fs, as_ = flops('Qwen3.8-Flash-Next', L, sparse=True)
fd, ad = flops('Qwen3.8-Flash-Next', L, sparse=False)
print(f"L={L:>6}: Qwen3-Next attention share {a / f:.0%} | Qwen3.8 dense-attn share {ad / fd:.0%} -> with QSA {as_ / fs:.0%}, FLOPs x{fs / fd:.2f}")
Ls = np.arange(1024, 4096)
q_layer = (Ls // 4) * 512 + np.minimum(Ls, 2051) * 12288
print("one QSA layer is cheaper than dense above L =", Ls[np.argmax(q_layer < Ls * 12288)], "(analytic 2048*12288/12160 =", round(2048 * 12288 / 12160), ")")Check in the output: the layout function reproduces the config’s 15/45 split; the per-layer KV entry is the same 2,048 B in every model, so KV per token is just (attention layers) × 2,048; the two crossovers land at ~1.05K and ~1.19K tokens; and at 256K the attention quarter is ~89% of Qwen3-Next’s decode FLOPs, which QSA cuts to ~10% (an overall ×0.15 for Qwen3.8’s FLOPs per token).
Two design habits
Change one quarter, keep the rest fixed. Every Qwen generation from Next on keeps full_attention_interval: 4, GDN with 16 QK heads of 128, 2 KV heads of 256 with 25% RoPE, and a 512-expert MoE with 10+1 active. Qwen3.5 changed only sizes; Qwen3.8 changed what happens inside the attention quarter and around the blocks (residual, embeddings). That makes each change attributable — and the Qwen3.8 report is explicit that its component ablations are run on the Qwen3.5 structure.
Judge after post-training. Two Qwen3.8 candidates were dropped although pre-training loss and benchmarks liked them: NoPE in the attention layers (endless generation after post-training) and reading only the top-2 residual branches (quality loss after post-training). The n-gram vocabulary study is a third case where loss and downstream diverge. For an architecture lineage that is a methodological change: the selection criterion moved downstream.
Why does Qwen3-Next hold MORE memory per sequence than Qwen3-30B-A3B at a 512-token context?
Memory per sequence is . Qwen3-Next’s attention KV grows 4× slower ( vs bytes per token), but it pays MB up front for GDN states. The crossover is tokens; at 512 tokens the hybrid is the more expensive one. (Expert count affects weights, not per-sequence memory.)
In Qwen3-Next at 256K context, roughly what share of decode FLOPs comes from the 12 attention layers, and what did Qwen3.8 do about it?
With 3B active parameters the weight FLOPs are ~6 GFLOPs per token, while 12 dense attention layers at 256K cost GFLOPs — about 89% of the total. QSA reads 2,048 tokens per query plus an indexer over pooled blocks, dropping attention to ~10% of Qwen3.8’s per-token FLOPs.
Summary
- Qwen cut cost by removing attention layers, not by shrinking them: from Qwen3-Next on, 3 of every 4 layers are Gated DeltaNet with a fixed state; per-token KV falls 4× (the per-layer entry stays 2,048 B).
- The hybrid pays a fixed state up front (77 MB in Qwen3-Next, 192 MB in Qwen3.5-397B), so it holds more memory below ~1K tokens and less above; at 256K about a quarter.
- Evidence for the hybrid comes from the later Qwen3.8 report (GDN hybrid 53.81 vs SWA hybrid 51.15 vs full 49.87); the gate on the remaining attention removes sinks, stabilises high learning rates and doubles 128K RULER after extension.
- Qwen3.5 scaled the same block; Qwen3.8 made the attention quarter sparse (QSA, block-pooled indexer, crossover ~2K tokens), widened and gated the residual without , and added FLOP-free n-gram parameters.
- Qwen3.8 dropped NoPE and top-2 residual reads because of post-training behaviour, not pre-training metrics.
교차점 그림 읽기
- 맨 왼쪽(1K)의 시퀀스당 KV+상태: 하이브리드가 같은 활성 크기의 전부-attention 모델보다 위에 있다. Qwen3-Next의 GDN 상태 77 MB는 Qwen3-30B-A3B KV 1K 토큰어치보다 크다. 약 1K의 빈 원이 그것이 뒤집히는 지점이다. Qwen3.5-397B는 약 1.2K에서 Qwen3-235B와 교차한다.
- softmax attention 간격을 1(모든 층 attention)로 끌면 모든 하이브리드 선이 전부-attention 기울기로 뛴다. 8로 두면 KV는 다시 줄지만 상태는 커지고(GDN 층이 늘어서), 더 중요하게는 모델 recall 대부분을 고정 상태에 맡기게 된다. 메모리 곡선만으로는 어디서 멈출지 알 수 없다. Qwen이 4를 고른 근거는 품질 쪽(3:1이 어떤 단일 구조보다 낫다는 주장, 그리고 Kimi 계보의 Kimi Linear 비율 sweep)이다.
- 토큰당 FLOPs: Qwen3-Next와 Qwen3.5-35B는 attention 층이 밀집이라 약 32K 뒤로 위로 휜다. Qwen3.8 선은 약 2K 토큰 뒤 평평해진다. QSA이고, 층별 밀집 attention과의 교차점은 토큰이다.
- 토큰당 HBM 바이트, batch 1: 가중치가 결정하고 Qwen3-Next / Qwen3.5-35B(활성 3B)가 이긴다. batch 512, 256K: KV 읽기가 결정한다. Qwen3.8은 attention 층마다 2,048 토큰의 KV와 1/4 해상도 indexer key만 읽어서 이긴다.
import numpy as np
# config.json의 층별 캐시 크기 (KV는 BF16, GDN 상태는 mamba_ssm_dtype처럼 FP32, short-conv 상태는 BF16)
def kv_entry(kv_heads, head_dim): # attention 층 하나의 토큰당 K+V 바이트(BF16)
return 2 * kv_heads * head_dim * 2
def gdn_state(v_heads, qk_heads, dk=128, dv=128, conv=4):
return v_heads * dk * dv * 4 + (2 * qk_heads * dk + v_heads * dv) * (conv - 1) * 2
# 이름: (층 수, full_attention_interval, q heads, kv heads, head dim, GDN V heads, 활성 B)
CFG = {
'Qwen3-30B-A3B': (48, 1, 32, 4, 128, 0, 3.3),
'Qwen3-235B-A22B': (94, 1, 64, 4, 128, 0, 22),
'Qwen3-Next-80B-A3B': (48, 4, 16, 2, 256, 32, 3),
'Qwen3.5-35B-A3B': (40, 4, 16, 2, 256, 32, 3),
'Qwen3.5-397B-A17B': (60, 4, 32, 2, 256, 64, 17),
'Qwen3.8-Flash-Next': (48, 4, 24, 2, 256, 48, 6),
}
def layout(name, interval=None): # config layer_types 재현: linear 3개 다음 full
n, iv = CFG[name][0], interval or CFG[name][1]
return ['full' if iv == 1 or (i + 1) % iv == 0 else 'linear' for i in range(n)]
def memory(name, L, interval=None): # 문맥 L에서 시퀀스당 바이트
n, iv, q, kv, hd, vh, act = CFG[name]
lay = layout(name, interval)
n_full = lay.count('full')
extra = n_full * (L // 4) * 256 if name.startswith('Qwen3.8') else 0 # QSA: 4토큰마다 풀링된 128차원 indexer key
return n_full * kv_entry(kv, hd) * L + lay.count('linear') * gdn_state(vh, 16) + extra
lt = layout('Qwen3.5-397B-A17B')
print("Qwen3.5-397B 배치:", lt[:4], "... full:", lt.count('full'), "linear:", lt.count('linear'), "(config: 15 / 45)")
for name in CFG:
n, iv, q, kv, hd, vh, act = CFG[name]
lay = layout(name)
print(f"{name:19s} 토큰당 KV {lay.count('full') * kv_entry(kv, hd):7,d} B 고정 상태 {lay.count('linear') * gdn_state(vh, 16) / 1e6:6.1f} MB")
# 교차점: 피한 KV가 하이브리드의 고정 상태를 넘어서면 본전
for small, hyb in [('Qwen3-30B-A3B', 'Qwen3-Next-80B-A3B'), ('Qwen3-235B-A22B', 'Qwen3.5-397B-A17B')]:
slope = memory(small, 1) - memory(small, 0)
slope_h = memory(hyb, 1) - memory(hyb, 0)
print(f"L* = {memory(hyb, 0) / (slope - slope_h):,.0f} 토큰 이상에서 {hyb}가 {small}보다 메모리를 덜 씀")
for L in (4096, 32768, 262144):
print(f"L={L:>6}: " + " | ".join(f"{k} {memory(k, L) / 1e9:5.2f} GB" for k in ['Qwen3-30B-A3B', 'Qwen3-Next-80B-A3B', 'Qwen3.8-Flash-Next']))
# 왜 QSA인가: 3:1 하이브리드의 긴 문맥에서도 1/4인 attention 층이 FLOPs를 지배한다
def flops(name, L, sparse=False, budget=2048, r=4):
n, iv, q, kv, hd, vh, act = CFG[name]
lay = layout(name)
per_key = 2 * q * hd # 캐시 토큰당 QK + AV MAC
attn = (L // r) * 4 * 128 + min(L, budget + r - 1) * per_key if sparse else L * per_key
lin = 4 * vh * 128 * 128 # GDN 디코드, head당 ~4 dk dv (추정)
return 2 * (act * 1e9 + lay.count('full') * attn + lay.count('linear') * lin), 2 * lay.count('full') * attn
for L in (32768, 262144):
f, a = flops('Qwen3-Next-80B-A3B', L)
fs, as_ = flops('Qwen3.8-Flash-Next', L, sparse=True)
fd, ad = flops('Qwen3.8-Flash-Next', L, sparse=False)
print(f"L={L:>6}: Qwen3-Next attention 비중 {a / f:.0%} | Qwen3.8 밀집 attention 비중 {ad / fd:.0%} -> QSA로 {as_ / fs:.0%}, FLOPs x{fs / fd:.2f}")
Ls = np.arange(1024, 4096)
q_layer = (Ls // 4) * 512 + np.minimum(Ls, 2051) * 12288
print("QSA 층 하나가 밀집보다 싸지는 L =", Ls[np.argmax(q_layer < Ls * 12288)], "(해석해 2048*12288/12160 =", round(2048 * 12288 / 12160), ")")출력에서 확인할 것: layout 함수가 config의 15/45 분할을 재현한다. 층당 KV 항목은 모든 모델에서 같은 2,048 B라서 토큰당 KV는 (attention 층 수) × 2,048이다. 두 교차점은 약 1.05K, 1.19K 토큰. 256K에서 attention 1/4이 Qwen3-Next 디코드 FLOPs의 약 89%이고, QSA가 이를 약 10%로 줄인다(Qwen3.8 토큰당 FLOPs 전체로 ×0.15).
두 가지 설계 습관
1/4을 바꾸고 나머지는 고정. Next 이후 모든 Qwen 세대는 full_attention_interval: 4, 128차원 QK head 16개의 GDN, 25% RoPE의 256차원 KV head 2개, 10+1 활성의 512-expert MoE를 유지한다. Qwen3.5는 크기만 바꿨고, Qwen3.8은 attention 1/4의 안쪽과 블록 주변(residual, 임베딩)을 바꿨다. 그래서 각 변경의 효과를 따로 귀속할 수 있다. Qwen3.8 보고서는 부품 ablation을 Qwen3.5 구조 위에서 돌렸다고 명시한다.
사후학습 뒤에 판단한다. Qwen3.8 후보 둘은 사전학습 loss와 벤치마크가 좋아했는데도 버려졌다. attention 층의 NoPE(사후학습 뒤 끝없는 생성)와 상위 2개 residual branch만 읽기(사후학습 뒤 품질 저하). n-gram 어휘 연구는 loss와 다운스트림이 갈라지는 세 번째 사례다. 아키텍처 계보로서는 방법론의 변화다. 선택 기준이 다운스트림으로 옮겨 갔다.
문맥 512토큰에서 Qwen3-Next가 Qwen3-30B-A3B보다 시퀀스당 메모리를 더 쓰는 이유는?
시퀀스당 메모리는 다. Qwen3-Next의 attention KV는 4배 느리게 자라지만(토큰당 vs 바이트) GDN 상태로 MB를 미리 낸다. 교차점은 토큰이고, 512토큰에서는 하이브리드가 더 비싸다. (expert 수는 가중치에 영향을 주지 시퀀스당 메모리에는 주지 않는다.)
256K 문맥의 Qwen3-Next에서 attention 12층이 디코드 FLOPs의 대략 몇 %를 차지하고, Qwen3.8은 이에 대해 무엇을 했나?
활성 3B라 가중치 FLOPs는 토큰당 약 6 GFLOPs인데, 256K의 밀집 attention 12층은 GFLOPs로 전체의 약 89%다. QSA는 query마다 2,048 토큰과 개 풀링 블록 위의 indexer만 읽어 attention을 Qwen3.8 토큰당 FLOPs의 약 10%로 낮춘다.
정리
- Qwen은 attention 층을 줄이는 대신 없애서 비용을 깎았다. Qwen3-Next부터 네 층 중 세 층이 고정 상태의 Gated DeltaNet이고, 토큰당 KV가 4배 준다(층당 항목은 2,048 B 그대로).
- 하이브리드는 고정 상태를 미리 낸다(Qwen3-Next 77 MB, Qwen3.5-397B 192 MB). 그래서 약 1K 토큰 아래에선 메모리를 더, 위에선 덜 쓴다. 256K에서 약 1/4.
- 하이브리드의 근거는 나중의 Qwen3.8 보고서에서 나왔다(GDN 하이브리드 53.81 vs SWA 하이브리드 51.15 vs full 49.87). 남은 attention의 gate는 sink를 없애고 높은 학습률을 안정시키며 확장 후 128K RULER를 두 배로 만든다.
- Qwen3.5는 같은 블록을 키웠다. Qwen3.8은 attention 1/4을 sparse로(QSA, 블록 풀링 indexer, 교차점 약 2K 토큰), residual을 없이 넓히고 gate를 달았으며, FLOPs가 들지 않는 n-gram 파라미터를 더했다.
- Qwen3.8은 NoPE와 상위 2개 residual 읽기를 사전학습 지표가 아니라 사후학습 행동 때문에 버렸다.
더 읽을거리Further reading
- Qwen Team, Qwen3 Technical Report (2025) — QK-Norm, shared expert 제거, global-batch LBL. 출발점.QK-Norm, no shared expert, global-batch LBL. The starting point.
- Qwen Team, Qwen3-Next blog (2025-09) and model card — 3:1 GDN 하이브리드, gated attention, 512-expert MoE, MTP의 1차 출처. 기술 보고서는 없다.Primary source for the 3:1 GDN hybrid, gated attention, the 512-expert MoE and MTP. There is no technical report.
- Qiu et al., Gated Attention for Large Language Models (2025) — SDPA 출력 gate의 ablation(PPL, 안정성, RULER).Ablations of the SDPA output gate (PPL, stability, RULER).
- Qwen Team, Qwen3.8-Flash-Next (2026) — 아키텍처 전용 보고서. GDN vs SWA vs full 하이브리드 비교(표 1), QSA, Gated Residual, n-gram 임베딩, Muon.Architecture-only report. GDN vs SWA vs full hybrid comparison (Table 1), QSA, Gated Residual, n-gram embeddings, Muon.
- Yang, Kautz, Hatamizadeh, Gated Delta Networks: Improving Mamba2 with Delta Rule (2024) — GDN 원 논문.The original GDN paper.
- Hugging Face config.json: Qwen3-235B-A22B, Qwen3-30B-A3B, Qwen3-Next-80B-A3B, Qwen3.5-397B-A17B, Qwen3.5-35B-A3B, Qwen3.8-Flash-Next — layer_types, head 수, GDN 차원, indexer 설정 등 이 레슨의 모든 크기.layer_types, head counts, GDN dimensions, indexer settings and every other size in this lesson.