Study · Model anatomy
Inside Qwen3.5: a hybrid linear + full attention LLM Qwen3.5 해부: linear + full attention 하이브리드 LLM
Qwen3.5 answers the KV-cache problem architecturally: three of every four layers replace softmax attention with a Gated DeltaNet whose memory is a fixed-size matrix, and the remaining fourth keeps full attention as random-access memory over the context. Walk the 64-layer interleave, open both token mixers, then race their memory footprints out to 262K tokens. Qwen3.5는 KV cache 문제를 아키텍처로 푼다: 4개 layer 중 3개는 softmax attention을 고정 크기 행렬 메모리를 갖는 Gated DeltaNet으로 대체하고, 나머지 1개는 컨텍스트 전체를 임의 접근(random-access)할 수 있는 full attention으로 남겨 둔다. 64-layer 인터리브를 훑고, 두 token mixer를 열어 본 뒤, 262K token까지 메모리 경주를 돌려 보자.
config.json on 2026-07-04: 이 페이지의 config — Qwen3.5-27B (dense), 공개
config.json에서 2026-07-04에 직접 확인: 64 layers = 16 × (3 linear + 1 full) d_model 5,120 full: 24 Q / 4 KV heads × 256 linear: 16 K / 48 V heads × 128 FFN 17,408 (dense SwiGLU) vocab 248,320 native ctx 262,144 §1 The itch: memory that grows with every token 문제: token마다 자라는 메모리
A decoder LLM generates one token at a time, and to attend back over its past it must keep that past: every attention layer appends the new token's K and V vectors to a cache, and nothing is ever evicted. The cost is small per token and merciless in aggregate. A conventional all-attention model of this page's shape pays 256 KB of cache per token; run it to Qwen3.5's native 262,144-token context and one sequence holds 64 GB of cache — more than the 27B model's own BF16 weights (≈54 GB). Long context does not fail on compute first; it fails on memory. Batch sizes collapse, and the cost of a conversation scales with its length. decoder LLM은 token을 하나씩 생성하고, 과거를 attend하려면 그 과거를 보관해야 한다: 모든 attention layer가 새 token의 K, V 벡터를 cache에 덧붙이고, 무엇도 제거되지 않는다. token당 비용은 작지만 누적은 무자비하다. 이 페이지와 같은 shape의 전통적 all-attention 모델은 token당 cache 256 KB를 내는데, Qwen3.5의 네이티브 262,144-token context까지 돌리면 시퀀스 하나가 64 GB의 cache를 든다 — 27B 모델의 BF16 가중치(≈54 GB)보다 크다. long context는 연산보다 메모리에서 먼저 무너진다. batch 크기가 붕괴하고, 대화 비용이 길이에 비례해 커진다.
Can a layer mix the sequence without keeping the whole sequence around? 시퀀스 전체를 보관하지 않고도 layer가 시퀀스를 섞을 수 있을까?
§2 Foundations: two ways to remember a sequence 기초: 시퀀스를 기억하는 두 가지 방법
First, be precise about what the cache buys. At decode time, softmax attention lets the current query score every stored key and read the matching values — token 200,000 is as sharply addressable as token 3. It is a random-access archive: exact, position-addressable recall, paid for with O(T) memory and an O(T) read per token. 먼저 cache가 사 주는 것을 정확히 하자. decode 시점의 softmax attention은 현재 query가 저장된 모든 key를 채점하고 해당 value를 읽게 해 준다 — token 200,000도 token 3만큼 선명하게 지정된다. 이것은 random-access 아카이브다: 정확한 위치 지정 recall을, token당 O(T) 메모리와 O(T) 읽기로 사는 것이다.
The older alternative is the RNN's: fold history into a fixed-size state updated in place — O(1) memory, but the past survives only as a lossy summary. Linear attention connects the two worlds: drop the softmax, and the attention sum factors into a running matrix S = Σ v·kᵀ with output o = S·q — softmax attention's shape, an RNN's memory. But the plain version has two flaws: it never forgets (every write piles on top of the last), and it cannot correct — a new value for an old key just accumulates next to the stale one. Fixing those two flaws — a decay gate for forgetting, an error-correcting write for replacement — is exactly what "Gated" and "Delta" will mean in the mixer this page opens in §4. 더 오래된 대안은 RNN의 방식이다: 히스토리를 제자리에서 갱신되는 고정 크기 state로 접어 넣는다 — O(1) 메모리, 대신 과거는 손실 요약으로만 남는다. linear attention이 두 세계를 잇는다: softmax를 빼면 attention 합이 누적 행렬 S = Σ v·kᵀ로 인수분해되고 출력은 o = S·q — softmax attention의 형태에 RNN의 메모리다. 그러나 순정 버전에는 결함이 둘 있다: 망각이 없고(모든 쓰기가 이전 위에 쌓인다), 수정도 못 한다 — 같은 key의 새 value가 낡은 것 옆에 누적될 뿐이다. 이 두 결함을 고치는 것 — 망각을 위한 decay gate, 교체를 위한 오차-수정 쓰기 — 이 바로 §4에서 열어 볼 mixer의 "Gated"와 "Delta"의 의미다.
Qwen3.5 refuses to pick one end. Where, in its 64 layers, does it mix the two? Qwen3.5는 한쪽 끝을 고르지 않는다. 64개 layer의 어디에서 둘을 섞을까?
We now have the dial. Qwen3.5's position on it is written in a
single config field — layer_types — and you can read the whole answer in
one strip. 이제 다이얼을 손에 들었다. Qwen3.5의 선택은 config의 필드 하나 —
layer_types — 에 적혀 있고, 그 답 전체를 한 줄의 스트립으로 읽을 수 있다.
§3 The layer stack: 48 linear + 16 full 레이어 스택: linear 48 + full 16
The whole depth as one strip — exactly the
layer_types list from the config. Hover any layer for its mixer and
shapes; click to open the mixer internals below. 모델 전체 깊이를 한 줄로 — config의 layer_types
리스트 그대로다. layer에 hover하면 mixer 종류와 shape가 보이고, 클릭하면 아래
mixer 내부로 이동한다.
The strip is the config's layer_types verbatim: 16 repeats of three Gated
DeltaNet layers followed by one Gated Attention layer. Both mixers take [L × 5,120] in
and give [L × 5,120] out, and both are followed by the identical dense SwiGLU FFN
(5,120 → 17,408) — the residual stream cannot tell them apart. What differs is what each
layer must remember to serve the next token: the full layer appends 4 KB of K/V
per token and keeps it forever; the DeltaNet layer overwrites a fixed 3 MB matrix in place.
이 스트립은 config의 layer_types 그대로다: Gated DeltaNet 3개 + Gated
Attention 1개가 16번 반복된다. 두 mixer 모두 [L × 5,120]을 받아 [L × 5,120]을 내놓고,
뒤에는 동일한 dense SwiGLU FFN (5,120 → 17,408)이 붙는다 — residual stream 입장에서는
구분이 안 된다. 다른 것은 다음 token을 위해 각 layer가 기억해야 하는 것이다:
full layer는 token마다 4 KB의 K/V를 덧붙여 영원히 보관하고, DeltaNet layer는 고정된
3 MB 행렬을 제자리에서 덮어쓴다.
"Interchangeable from outside" — but what is actually inside each of the two boxes? "밖에서 보면 호환" — 그럼 두 상자의 안에는 실제로 무엇이 들어 있을까?
We know where the two mixers sit. This section opens both boxes at the tensor level — same input, same output, and the archive/slate split of §2 made concrete in silicon shapes. 두 mixer가 어디에 있는지는 알았다. 이 절에서는 두 상자를 tensor 수준에서 연다 — 같은 입력, 같은 출력, 그리고 §2의 아카이브/슬레이트 구분이 실제 shape로 구체화된 모습이다.
§4 The two token mixers, side by side 두 token mixer 나란히 보기
Same input, same output shape, opposite memory contracts. Hover every box for the exact op and its cost. 입력도 출력 shape도 같지만 메모리 계약은 정반대다. 각 박스에 hover하면 정확한 연산과 비용이 보인다.
One line is doing all the work: S ← α·S + β·(v − S·k)·kᵀ. Why the error term, and not just S + v·kᵀ? 모든 일을 하는 것은 한 줄이다: S ← α·S + β·(v − S·k)·kᵀ. 왜 그냥 S + v·kᵀ가 아니라 오차 항일까?
This is the hardest section of the page — one equation, taken slowly. Everything the 48 linear layers do to justify their fixed 3 MB hangs on it. 여기가 이 페이지에서 가장 어려운 절이다 — 식 하나를 천천히 읽는다. linear layer 48개가 고정 3 MB로 밥값을 하는 근거 전부가 이 식에 걸려 있다.
§5 Deep water: the delta rule is an online learner 깊은 물: delta rule은 온라인 학습기다
Read the update S ← α·S + β·(v − S·k)·kᵀ as one step of online regression: the state predicts S·k for the incoming key, the error (v − S·k) is written back along k with learning rate β, and α forgets. That error-correcting write is why DeltaNet-family mixers retrieve better than plain additive linear attention (S ← S + v·kᵀ) — a new value for an old key replaces the stale association instead of piling on top of it. §2's two flaws are answered in one line: α is the forgetting that additive linear attention lacked, and the (v − S·k) error term is the correction it could not do. 업데이트 S ← α·S + β·(v − S·k)·kᵀ는 온라인 회귀의 한 스텝으로 읽으면 된다: state가 들어온 key에 대해 S·k를 예측하고, 오차 (v − S·k)를 학습률 β로 k 방향에 되써 넣고, α가 망각을 담당한다. 이 오차-수정형 쓰기 덕분에 DeltaNet 계열이 단순 덧셈형 linear attention (S ← S + v·kᵀ)보다 retrieval에 강하다 — 같은 key의 새 value가 낡은 연합 위에 쌓이는 게 아니라 교체된다. §2의 두 결함이 한 줄에서 해결된다: α는 덧셈형 linear attention에 없던 망각이고, 오차 항 (v − S·k)는 그것이 못 하던 수정이다.
Two details in the §4 diagram are not decoration but stabilizers: the short kernel-4 causal convolution gives cheap local mixing where the recurrence has no positional signal, and the L2-norm on q/k replaces softmax's normalization so the recurrence stays bounded — together they are what makes this online learner trainable at 27B scale. Note also what α and β are: per-token, per-head projections of the input, so the model decides, token by token, how much to forget and how hard to write. §4 다이어그램의 디테일 두 개는 장식이 아니라 안정장치다: kernel 4짜리 짧은 causal convolution은 위치 신호가 없는 recurrence에 값싼 local mixing을 공급하고, q/k의 L2-norm은 softmax의 정규화를 대신해 recurrence를 유계로 유지한다 — 이 둘이 이 온라인 학습기를 27B 규모에서 학습 가능하게 만든다. α와 β의 정체도 눈여겨보자: token마다, head마다 입력에서 projection되는 값이라, 모델이 token 단위로 얼마나 잊고 얼마나 세게 쓸지를 스스로 결정한다.
A 3 MB slate per layer vs a cache growing 4 KB per token per layer — at what context length does the trade pay off, in actual bytes? layer당 3 MB 슬레이트 vs layer당 token마다 4 KB씩 자라는 cache — 이 거래는 실제 byte 기준으로 어느 context 길이부터 이득일까?
We have both mixers and the mechanism that lets one of them live on a fixed slate. What remains is arithmetic — and the arithmetic is the argument for the whole architecture. 두 mixer와, 그중 하나가 고정 슬레이트 위에서 살 수 있게 하는 메커니즘까지 갖췄다. 남은 것은 산수다 — 그리고 그 산수가 이 아키텍처 전체의 논증이다.
§6 The memory race: KV cache vs recurrent state 메모리 경주: KV cache vs recurrent state
Drag the context-length slider or step through the milestones. Full-attention layers pay 4 KB per token per layer; Gated DeltaNet layers pay a flat ~3.1 MB each, once. The counterfactual is the same model with all 64 layers full. context 길이 slider를 움직이거나 milestone을 넘겨 보자. full-attention layer는 layer당 token마다 4 KB를 내고, Gated DeltaNet layer는 layer당 ~3.1 MB를 한 번만 낸다. 비교 대상은 64개 layer 전부 full attention인 가상의 동일 모델이다.
Below the crossover the hybrid actually holds more memory: 48 linear layers carry a fixed 148 MB of fp32 state while 16 full layers have written only 512 × 64 KB = 32 MB of KV. The all-full model sits at 128 MB. Recurrent state is a fixed cost, paid up front.crossover 아래에서는 hybrid가 오히려 메모리를 더 쓴다: linear layer 48개가 고정 148 MB의 fp32 state를 들고 있는 동안, full layer 16개가 쓴 KV는 512 × 64 KB = 32 MB뿐이다. all-full 모델은 128 MB. recurrent state는 선불로 내는 고정비다.
Per layer, the trade is 3,227,648 bytes of constant state (3 MB matrix + 80 KB conv buffer) against 4,096 bytes of KV per token — they tie at 788 tokens. Everything past that is profit, and it compounds: at the native 262,144-token context the hybrid holds 16.1 GB where an all-full sibling would hold 64 GB. The asymptotic ratio is simply the layer ratio, 16/64 = 4×. Notice what the ratio does not change: the 16 full layers still grow linearly. The hybrid divides the KV-cache problem by four; it does not delete it. layer당 거래는 상수 state 3,227,648 bytes (3 MB 행렬 + 80 KB conv buffer) 대 token당 KV 4,096 bytes — 788 tokens에서 동점이 된다. 그 이후는 전부 이득이고 복리로 쌓인다: 네이티브 262,144 token context에서 hybrid는 16.1 GB, all-full 형제 모델은 64 GB를 든다. 점근 비율은 layer 비율 그대로 16/64 = 4×다. 이 비율이 바꾸지 못하는 것도 보인다: full layer 16개는 여전히 선형으로 자란다. hybrid는 KV cache 문제를 4로 나눌 뿐, 지우지는 않는다.
If the slate is this cheap, why keep any full-attention layers at all — why not 64 linear layers? 슬레이트가 이렇게 싸다면 full-attention layer를 왜 남겨 둘까 — 왜 64개 전부 linear가 아닐까?
The memory race makes all-linear look like a free win. This section is the other half of the ledger — what the published record says you give up when the last archive is gone. 메모리 경주만 보면 all-linear가 공짜 승리처럼 보인다. 이 절은 장부의 나머지 절반이다 — 마지막 아카이브까지 없앴을 때 무엇을 잃는지, 공개된 기록이 말해 주는 것.
§7 Why not 64 linear layers? The recall tax 왜 64개 전부 linear가 아닐까? recall의 대가
If constant-size state were free, every layer would be linear. The published record says it is not free — exact recall is what you pay. 고정 크기 state가 공짜라면 모든 layer가 linear였을 것이다. 공개된 결과들은 공짜가 아니라고 말한다 — 대가는 exact recall이다.
Gated DeltaNet arXiv 2412.06464
The mixer itself. Gating gives fast memory erasure, the delta rule gives targeted updates; the paper reports gains over Mamba2/DeltaNet on in-context retrieval among other axes — and its hybrid variants (adding attention layers) reach both better training efficiency and better task scores than pure linear stacks. mixer 그 자체. gating은 빠른 memory 삭제를, delta rule은 표적 업데이트를 준다. 논문은 in-context retrieval을 포함한 여러 축에서 Mamba2/DeltaNet 대비 향상을 보고하며, attention layer를 섞은 hybrid 변형이 순수 linear 스택보다 학습 효율과 태스크 점수 모두 낫다고 보고한다.
MiniMax-01 arXiv 2501.08313
Hybrid at 456B production scale — and pointedly not pure linear: one softmax-attention block is kept after every seven lightning (linear) attention blocks. Periodic full attention is what preserves long-context retrieval behavior at a 7:1 dilution. 456B 프로덕션 규모의 hybrid — 그리고 의도적으로 순수 linear가 아니다: lightning (linear) attention 블록 7개마다 softmax-attention 블록 1개를 남긴다. 7:1 희석에서도 long-context retrieval을 지켜주는 것이 주기적 full attention이다.
Qwen3-Next → Qwen3.5 3 : 1
Qwen settled at a denser 3:1 — the same
full_attention_interval: 4 in Qwen3-Next-80B-A3B and every published
Qwen3.5 config. The Qwen3-Next release reports ~10× inference throughput beyond
32K context vs the all-full-attention Qwen3-32B (different sizes, so indicative,
not an ablation). Qwen은 더 촘촘한 3:1에 안착했다 — Qwen3-Next-80B-A3B와 공개된
모든 Qwen3.5 config의 full_attention_interval: 4가 그것이다.
Qwen3-Next 릴리스는 32K 이상 context에서 all-full인 Qwen3-32B 대비 약 10×
추론 throughput을 보고한다 (모델 크기가 달라 방향성 지표이지 ablation은 아니다).
The mechanism behind the tax: a delta-rule state is 16,384 floats per head — a lossy compression of an unbounded past. Needle-in-a-haystack-style probes ask for verbatim, position-addressable lookup, which is exactly what a fixed-size state cannot guarantee and what softmax attention over a KV cache does natively. The interleaved full layers give every fourth layer a true random-access read of the whole context; the linear layers in between handle the bulk of sequence mixing at O(1) memory per token. 이 대가의 메커니즘: delta-rule state는 head당 16,384개 float — 무한한 과거의 손실 압축이다. needle-in-a-haystack류 프로브는 위치 지정 원문 lookup을 요구하는데, 이는 고정 크기 state가 보장할 수 없는 것이자 KV cache 위의 softmax attention이 기본으로 해내는 것이다. 인터리브된 full layer는 4개 layer마다 컨텍스트 전체에 대한 진짜 random-access 읽기를 제공하고, 사이의 linear layer들이 token당 O(1) 메모리로 시퀀스 혼합의 대부분을 처리한다.
The architecture is settled — 3:1, break-even at 788 tokens. What does it change for the people optimizing inference? 아키텍처는 정해졌다 — 3:1, 788 tokens에서 손익분기. 추론을 최적화하는 사람들에게는 무엇이 달라질까?
The tour is done: one dial, two mixers, one equation, one crossover. The last question is where the field takes it from here. 투어는 끝났다: 다이얼 하나, mixer 둘, 식 하나, crossover 하나. 마지막 질문은 필드가 여기서 어디로 가느냐다.
§8 Where this goes 여기서 어디로 가는가
Why this matters for efficiency work 효율화 연구에 왜 중요한가
Hybridization moves the serving bottleneck rather than removing it. First, the whole long-context memory budget now concentrates in 16 layers — any per-layer KV technique (quantization, eviction, offloading) applies to a 4× smaller surface, but its quality effect concentrates too, because those 16 layers are the model's only exact recall path. Second, the linear layers turn decode into a state-update workload — fixed-size fp32 state, read-modify-write every token — whose batching and kernel behavior is closer to an RNN than to attention. Third, the crossover logic runs in reverse for short sequences: under ~800 tokens the hybrid is the heavier model. Architecture choices like this are context-length bets, and the config tells you exactly where the bet breaks even. 하이브리드화는 serving 병목을 없애는 게 아니라 옮긴다. 첫째, long-context 메모리 예산 전체가 이제 16개 layer에 집중된다 — layer 단위 KV 기법(quantization, eviction, offloading)의 적용 면적은 4× 줄지만, 그 16개 layer가 모델의 유일한 exact recall 경로라서 품질 영향도 함께 집중된다. 둘째, linear layer들은 decode를 state-update 워크로드로 바꾼다 — 고정 크기 fp32 state를 token마다 read-modify-write — batching과 kernel 특성이 attention보다 RNN에 가깝다. 셋째, 짧은 시퀀스에서는 crossover 논리가 거꾸로 돈다: ~800 token 아래에서는 hybrid가 오히려 더 무거운 모델이다. 이런 아키텍처 선택은 context-length에 대한 베팅이고, config가 그 손익분기점을 정확히 알려 준다.
Three directions are visibly live. Ratios and layouts: 7:1 (MiniMax-01), 3:1 (Qwen3-Next, Qwen3.5) — how much full attention is enough, and where in the depth it belongs, is still decided empirically per model family. The remaining archive: once 48 layers are linear, the whole long-context budget sits in 16 full layers, so the KV-cache literature — quantization (KIVI, KVQuant), eviction (H2O), retrieval-head splitting (DuoAttention) — now applies to a smaller but more critical surface. The slate itself: better update rules than the delta rule, and kernels that make fixed-state decode fast, are an open race. 눈에 보이게 살아 있는 방향은 셋이다. 비율과 배치: 7:1 (MiniMax-01), 3:1 (Qwen3-Next, Qwen3.5) — full attention이 얼마면 충분한지, 깊이의 어디에 두어야 하는지는 여전히 모델 패밀리마다 경험적으로 정해진다. 남은 아카이브: 48개 layer가 linear가 되면 long-context 예산 전체가 full layer 16개에 앉게 되고, KV cache 문헌 — quantization (KIVI, KVQuant), eviction (H2O), retrieval-head 분리 (DuoAttention) — 이 더 작지만 더 결정적인 표면에 적용된다. 슬레이트 자체: delta rule보다 나은 update rule, 그리고 고정 state decode를 빠르게 만드는 kernel은 열린 경주다.
Going deeper 더 깊이 보기
- Qwen3.5-27B — model card & config.json (the numbers on this page)
- Qwen3-Next-80B-A3B — where the 3:1 hybrid layout debuted
- Gated DeltaNet — gated delta rule for linear transformers (arXiv 2412.06464)
- MiniMax-01 — lightning attention hybrid at 456B scale (arXiv 2501.08313)
- This site's review: Gated DeltaNet
- This site's review: MiniMax-01
- This site's review: KIVI — KV cache quantization
- This site's review: KVQuant
- This site's review: H2O — KV cache eviction
- This site's review: DuoAttention
All shapes and byte counts on this page come from the published
Qwen/Qwen3.5-27B config.json (fetched 2026-07-04):
64 layers with full_attention_interval 4; full attention 24 Q / 4 KV
heads × 256 with attn_output_gate and partial RoPE (factor 0.25); Gated
DeltaNet 16 K / 48 V heads × 128, conv kernel 4, mamba_ssm_dtype float32;
hidden 5,120; dense FFN 17,408; vocab 248,320; native context 262,144. KV bytes assume
BF16; state bytes use fp32 per the config; the conv-buffer estimate assumes BF16.
The 27B config also declares a 1-layer multi-token-prediction (MTP) head and a vision
encoder — both outside this page's scope. MoE FFNs appear in other family members
(e.g. Qwen3.5-397B-A17B), not in the dense 27B. The all-full-attention counterfactual
is arithmetic, not a released model.
이 페이지의 모든 shape와 byte 수치는 공개된 Qwen/Qwen3.5-27B config.json(2026-07-04 확인)에서 나왔다: 64 layers,
full_attention_interval 4; full attention은 24 Q / 4 KV heads × 256에
attn_output_gate와 partial RoPE (factor 0.25); Gated DeltaNet은 16 K /
48 V heads × 128, conv kernel 4, mamba_ssm_dtype float32; hidden 5,120;
dense FFN 17,408; vocab 248,320; native context 262,144. KV byte는 BF16 기준, state
byte는 config대로 fp32, conv buffer 추정치는 BF16 가정이다. 27B config에는 1-layer
multi-token-prediction (MTP) head와 vision encoder도 선언되어 있으나 이 페이지 범위
밖이다. MoE FFN은 dense 27B가 아니라 패밀리의 다른 모델(예: Qwen3.5-397B-A17B)에
있다. all-full-attention 비교 모델은 산술적 가정이지 실제 릴리스가 아니다.