Qwen3.8-27B keeps a KV cache in only 16 of 64 layers: what that means for 80 GB GPUs and the 1M-token path
TL;DR Qwen3.8-27B is an Apache 2.0, 27.78B-parameter dense vision-language model on Hugging Face. Its 64 layers are 48 Gated DeltaNet (linear attention) layers and 16 full-attention layers, so only a quarter of the sta
TL;DR
- Qwen3.8-27B is an Apache 2.0, 27.78B-parameter dense vision-language model on Hugging Face. Its 64 layers are 48 Gated DeltaNet (linear attention) layers and 16 full-attention layers, so only a quarter of the stack grows a KV cache with context.
- By my arithmetic from
config.json, that cache costs 64 KiB (65,536 bytes) per token in BF16: 17.2 GB at the native 262,144 tokens, against 68.7 GB if all 64 layers were full attention. - The BF16 weights are 55.56 GB on disk. Weights plus one 262K sequence come to about 72.7 GB, which squeezes onto an 80 GB card but leaves no room for a second long request.
- The default
reasoning_effortisxhigh, so output tokens, not the cache, may be the larger bill in agent loops. The card's own tip says lower effort can raise total retries.
Everything below is arithmetic from the public config and card, plus vendor-reported scores. I did not run the model.
What is actually inside Qwen3.8-27B?
The model card lists a hidden layout of 16 x (3 x (Gated DeltaNet -> FFN) -> 1 x (Gated Attention -> FFN)). The layer_types array in config.json agrees: three linear_attention entries, then one full_attention, repeated 16 times, for 64 layers. full_attention_interval is 4.
| Field | Value |
|---|---|
| Parameters (safetensors, BF16) | 27,781,427,952 |
| Layers | 64 (48 linear, 16 full) |
| Hidden size | 5120 |
| Full-attention heads | 24 query, 4 KV, head_dim 256 |
| DeltaNet heads | 16 QK, 48 V, dim 128 |
| Native context | 262,144 tokens |
| Extended context | up to 1,000,000 with YaRN |
| License | Apache 2.0 |
The file is a vision-language checkpoint (Qwen3_5ForConditionalGeneration), so a vision encoder with 27 layers rides along, and one multi-token-prediction layer is declared in the config. The card says it works with Transformers, vLLM, SGLang and TokenSpeed.
The architecture is the Qwen3.5 family layout. The card says Qwen3.8 builds on that foundation, so tooling that already handles Qwen3.5 hybrid models is the natural starting point.
How big is the KV cache for a 27B hybrid model?
Only full-attention layers store keys and values per token. Each one stores K and V for 4 KV heads of 256 dimensions. In BF16 that is:
bytes per token per layer = 2 (K and V) x 4 heads x 256 dim x 2 bytes = 4,096
bytes per token, 16 layers = 4,096 x 16 = 65,536 (64 KiB)
Scaled to context lengths, using decimal gigabytes:
| Context | Hybrid, 16 layers | If all 64 layers were full attention |
|---|---|---|
| 32,768 | 2.15 GB | 8.59 GB |
| 131,072 | 8.59 GB | 34.36 GB |
| 262,144 | 17.18 GB | 68.72 GB |
| 1,000,000 | 65.54 GB | 262.14 GB |
The "all 64 layers" column is a hypothetical with the same head layout, included only to show what the 3:1 pattern saves. It is a 4x reduction by construction.
The DeltaNet layers do not grow with context. Each keeps a fixed recurrent state. The config sets mamba_ssm_dtype to float32, and the state per layer is value heads x key dim x value dim:
48 x 128 x 128 x 4 bytes = 3,145,728 bytes (3 MiB) per layer
x 48 layers = 150,994,944 bytes (about 151 MB) per sequence
That excludes a small convolution state (kernel size 4) and assumes a runtime keeps the state in fp32 as the config field suggests. Even so, 151 MB per sequence is noise next to a 17 GB cache at 262K, and it does not depend on how long the prompt is. This is why hybrid models are friendlier to many concurrent medium-length requests than to one giant one.
Does it fit on one GPU?
Weights first. The safetensors shards add up to 55,563,006,776 bytes, which is 55.56 GB (51.75 GiB). Add the cache for a single sequence:
| Context (one sequence) | Weights + KV cache |
|---|---|
| 32,768 | 57.7 GB |
| 131,072 | 64.2 GB |
| 262,144 | 72.7 GB |
| 1,000,000 | 121.1 GB |
Reading that against common cards:
- 80 GB (H100 or A100 80GB): one 262K sequence fits on paper, with about 7 GB left for activations, CUDA graphs and fragmentation. That is thin. After weights, 80 GB leaves roughly 24.4 GB for cache, or about 373,000 cached tokens summed across all requests, before any runtime overhead.
- 141 GB class (H200): about 85 GB of headroom after weights, or roughly 1.3 million cached tokens across requests. A single 1M sequence at 121 GB fits on paper.
- 96 GB class: roughly 40 GB of headroom, about 617,000 tokens of cache in total.
- 48 GB class: the BF16 weights alone do not fit. You need quantization or tensor parallelism. Quantized builds exist from the community, but I did not check their quality.
Two caveats. First, serving engines reserve a fraction of memory and manage the cache in pages, so real capacity is lower than this ceiling. Second, an 8-bit KV cache would roughly halve the cache numbers, but I did not measure the accuracy cost on this model.
A quick way to compute the cache for your own context target:
import json, urllib.request
cfg = json.load(urllib.request.urlopen(
"https://huggingface.co/Qwen/Qwen3.8-27B/raw/main/config.json"))["text_config"]
full = sum(t == "full_attention" for t in cfg["layer_types"])
per_token = 2 * cfg["num_key_value_heads"] * cfg["head_dim"] * 2 * full # BF16 bytes
for ctx in (32_768, 131_072, 262_144, 1_000_000):
print(f"{ctx:>9,} tokens: {per_token * ctx / 1e9:6.2f} GB ({full} full-attention layers)")
It prints 2.15, 8.59, 17.18 and 65.54 GB. Swap in a different model's config to compare, as long as it exposes layer_types.
What does the 1M-token path require?
Native context is 262,144 tokens. The card describes reaching 1,000,000 by overriding the rope parameters to YaRN with a factor of 4.0 and an original maximum of 262,144, then launching the server with a matching maximum length (for vLLM, VLLM_ALLOW_LONG_MAX_MODEL_LEN=1 and --max-model-len 1000000). It also advises changing rope_parameters only when you need long contexts, and tuning the factor to your typical length: for a 524,288 token workload, use 2.0.
Memory-wise, the 1M path is a different class of machine. The cache alone is about 65.5 GB for one sequence, before 55.6 GB of weights. The card also says a hosted version with 1M context by default is coming from the vendor's cloud, which is the intended route for most users.
Is the reasoning default the bigger cost?
Thinking mode is on by default. The card documents reasoning_effort with three levels: xhigh (the default), medium and low. It also enables preserve_thinking by default, which keeps reasoning blocks from earlier turns in the context. The card says this improves cache reuse and consistency in agent scenarios.
That interacts with the memory numbers. Retained reasoning makes every turn's prompt longer, so a long agent session reaches the 262K ceiling sooner than the visible conversation suggests. The vendor also recommends generous output budgets for agentic tasks.
from openai import OpenAI
client = OpenAI() # base URL and key from environment
resp = client.chat.completions.create(
model="Qwen/Qwen3.8-27B",
messages=[{"role": "user", "content": "Summarize this stack trace."}],
reasoning_effort="medium", # card levels: xhigh (default), medium, low
extra_body={"chat_template_kwargs": {"enable_thinking": True,
"preserve_thinking": True}},
)
print(resp.usage)
The card adds a counterintuitive note: in multi-turn agentic tasks, lower reasoning effort does not always cut total time, because insufficient analysis can lead to failures and repeated retries. So measure tokens per completed task, not tokens per turn. For cost modeling, log usage for the same 50 tasks at each effort level and compare completed tasks per dollar.
Recommended sampling in thinking mode is temperature=1.0, top_p=0.95, top_k=20, with different values for the non-thinking mode (temperature=0.7, top_p=0.80, presence_penalty=1.5).
What do the benchmark numbers say?
These are vendor-reported, and the harness details matter. The card says the coding results use the Claude Code harness at a 256K context window with temperature 1.0, and that baselines were re-evaluated on a refined version of SWE-bench Pro.
| Benchmark | Qwen3.8-27B | Qwen3.6-27B | Qwen3.7-Plus | Opus4.6 Max |
|---|---|---|---|---|
| Terminal Bench 2.1 | 73.0 | 63.4 | 64.0 | 78.2 |
| SWE-bench Pro | 61.7 | 53.5 | 57.6 | 53.4 |
| DeepSWE 1.1 | 42.2 | 13.3 | 14.2 | n/a |
| QwenSWEBench | 79.0 | 49.3 | 59.2 | 63.8 |
| OSWorld-Verified | 84.3 | 63.9 | 73.3 | 72.7 |
| GPQA Diamond | 89.2 | 87.8 | 90.3 | 91.3 |
| LiveCodeBench v6 | 90.3 | 83.9 | 89.6 | 88.8 |
The largest jumps against the previous 27B are in agent and computer-use tasks (DeepSWE, OSWorld, QwenSWEBench), while the reasoning-only rows move by a few points. QwenSWEBench is the vendor's in-house benchmark, so weigh it accordingly. None of these rows is independent. Re-run the ones that match your workload, on your harness, before you commit hardware.
How should you size a deployment?
- Pick the context target and concurrency first. Multiply 65,536 bytes by tokens in flight across all requests. That is your cache budget in BF16.
- Add weights. 55.56 GB in BF16, less with quantization.
- Reserve 10 to 20 percent for activations, graphs and paging overhead, then check what the runtime actually allocates at startup.
-
Account for retained reasoning. With
preserve_thinkingon, count reasoning tokens as part of the prompt on later turns. -
Measure tokens per completed task at each
reasoning_effortlevel.
For a single user on an 80 GB card, 128K contexts are comfortable (64.2 GB total). For several concurrent agents, the cache budget, not the weights, decides the batch size, and an H200 class card changes the picture more than any software setting.
FAQ
What is the architecture of Qwen3.8-27B?
A dense 27.78B-parameter vision-language model with 64 layers: 48 Gated DeltaNet linear-attention layers and 16 full-attention layers in a repeating 3:1 pattern, per the card and config.json.
How much KV cache does Qwen3.8-27B need?
By my arithmetic, 64 KiB per token in BF16, which is 17.18 GB at 262,144 tokens and 65.54 GB at 1,000,000 tokens for a single sequence. Fixed-size DeltaNet state adds about 151 MB per sequence if kept in fp32.
Can Qwen3.8-27B run on one 80 GB GPU?
One 262K sequence fits on paper (about 72.7 GB with BF16 weights), but with little headroom. Shorter contexts or an 8-bit cache are safer, and the 1M path does not fit.
What license does it use?
Apache 2.0, as stated in the card metadata and the repository's LICENSE file.
What does reasoning_effort change?
It sets reasoning depth: xhigh by default, with medium and low for lower cost and latency. The card warns that lower effort can increase retries in multi-turn agent tasks.
Are the benchmark scores independent?
No. They are reported by the vendor, some on an in-house benchmark. Reproduce the rows that matter to you.
Links
- Model: Qwen/Qwen3.8-27B
- Config used for the layer pattern: config.json
- vLLM recipe linked from the card: recipes.vllm.ai/Qwen/Qwen3.8-27B
Further reading
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.