Save products you love by clicking the heart icon.
Evidenzbasierte Testing-Praxis aus Produktions-Codebasen — property-basierte Invarianten, gezielte Fehlerinjektion, Contract-Tests, benchmark-verifizierte Performance und Qualitäts-Gates, die durchgesetzt werden, nicht nur versprochen.
Optimizing AI inference for XR devices — model quantization, NPU acceleration, hierarchical serving, bandwidth optimization for real-time 60fps rendering.
Running a 27 billion parameter model with 128,000 token context on a laptop sounds like it needs a 48 GB GPU. Pure transformer models require a KV cache that grows linearly with context length -- at 128k tokens, a 27B model needs roughly 33 GB just for the key-value cache. That is three RTX 4080 Laptop GPUs worth of VRAM.
The bottleneck is not model weights. A 27B model at Q4_K_M quantization is about 17 GB -- large, but manageable with partial CPU offload. The bottleneck is the KV cache, and it is the reason most people run 7B models with 8k context and call it a day.
Qwen3.8-27B changes the equation. It uses a hybrid attention/SSM architecture: 48 of its 65 layers are Mamba-style state-space models that need no KV cache at all. Only 17 layers (every 4th) use standard attention. The KV cache is 5.9x smaller than a pure attention model of the same size.
This article benchmarks that claim on real hardware: an RTX 4080 Laptop with 12 GB VRAM, running llama.cpp with CUDA.
| Component | Specification |
|---|---|
| CPU | Intel Core i9-14900HX (24C/32T, P-cores to 5.8 GHz) |
| GPU | NVIDIA RTX 4080 Laptop (12 GB GDDR6X, Ada Lovelace SM 8.9) |
| RAM | 64 GB DDR5-5600 (2x32 GB Kingston) |
| Storage | 2x Samsung 990 PRO 4TB NVMe RAID |
| OS | Windows 11, CUDA 12.4 |
| Property | Value |
|---|---|
| Model | Qwen3.8-27B Abliterated Q4_K_M |
| Parameters | 27.3B (dense) |
| File size | 16.8 GB |
| Architecture | qwen35 hybrid: 17 attention + 48 SSM/Mamba layers |
| Full attention interval | Every 4th layer |
| Native context | 256,000 tokens |
| Tool calling | Built-in |
| MTP | 1 speculative decoding draft layer |
| Source | Blackfrost-AI/Qwen3.8-27B-ABLITERATED-GGUF |
22 of 65 layers offloaded to GPU (34%), 43 on CPU (66). This leaves 3.4 GB GPU headroom at maximum 128k context.
./build/bin/Release/llama-server.exe \
-m models/Qwen3.8-27B-ABLITERATED-Q4_K_M.gguf \
-c 131072 \
-ngl 22 \
--temp 0.6 \
--top-k 40 \
-np 1
The hybrid architecture splits the KV cache naturally. With layers 0-21 on GPU (containing 6 of the 17 attention layers) and layers 22-64 on CPU (containing 11 attention layers), the KV cache distributes itself:
| Allocation | Size | Notes |
|---|---|---|
| GPU model (22 layers) | 5.7 GB | |
| GPU KV (6 attn layers, 128k) | 3.1 GB | |
| GPU total | 8.8 GB | 3.4 GB headroom |
| CPU model (43 layers) | 11.1 GB | |
| CPU KV (11 attn layers, 128k) | 5.7 GB | |
| CPU total | 16.8 GB | of 64 GB |
| System total | 25.5 GB |
Counterfactual: a pure attention 27B model at 128k needs 32.7 GB KV cache. That does not fit in 12 GB VRAM at all -- you would need a second GPU or a desktop card. The SSM layers reduce the KV cache by 5.9x, making the entire setup possible.
This is the most interesting result. Prefill is how fast the model processes your input prompt. For pure attention models, this degrades significantly as context grows because each attention layer does O(n^2) work over the sequence length.
| Input tokens | tok/s | Time | % of peak |
|---|---|---|---|
| 128 | 236 | 0.5s | 99% |
| 512 | 236 | 2.2s | 99% |
| 2,048 | 238 | 8.6s | 100% |
| 4,096 | 221 | 18.5s | 93% |
| 8,192 | 210 | 39.1s | 88% |
| 16,384 | 205 | 79.8s | 86% |
| 32,768 | 191 | 171.3s | 80% |
Going from 512 tokens to 32,768 tokens is a 64x increase in input size. The prefill speed drops from 236 tok/s to 191 tok/s -- only a 19% degradation. For a pure attention 27B model over the same range, you would expect 40-60% degradation.
Why? Because 74% of the layers (the SSM layers) are O(1) in context length. They do the same amount of work whether the input is 512 or 32k tokens. Only the 17 attention layers see the quadratic cost, and even those are amortized across the SSM layers.
Generation produces one token at a time. Here, the bottleneck is memory bandwidth, not compute. Each layer must read its full weight matrix for every single token.
| GPU layers | CPU layers | tok/s | Per token | vs baseline |
|---|---|---|---|---|
| 10 | 55 | 2.05 | 488ms | baseline |
| 22 | 43 | 2.76 | 362ms | +35% |
| 35 | 30 | 2.92 | 342ms | +42% |
The critical insight: generation speed is constant across all context lengths. Whether the context is 1k or 128k tokens, you get 2.76 tok/s. The SSM layers contribute to this -- their state is a fixed-size buffer, so growing the KV cache in the attention layers does not dominate.
The second insight: GPU layers have diminishing returns. Going from 10 to 22 GPU layers gives +35%. Going from 22 to 35 gives only +6%. The bottleneck is DDR5 RAM bandwidth for the 43 CPU layers. The GPU is fast, but it sits idle waiting for the CPU layers to finish.
A typical agentic coding turn: send context (project files, conversation history, tool outputs), receive a response (tool call, code edit, or analysis).
| Context | Prefill | Generation (128 tok) | Total | TTFT |
|---|---|---|---|---|
| 4k | 18.5s | 46.4s | 64.9s | 18.5s |
| 8k | 39.1s | 46.4s | 85.5s | 39.1s |
| 16k | 79.8s | 46.4s | 126.2s | 79.8s |
| 32k | 171.3s | 46.4s | 217.7s | 171.3s |
Generation time is identical at every context length. At 8k context, generation takes 54% of the turn. At 32k, it is only 21%. The bottleneck shifts from balanced to prefill-dominated, but generation never gets slower.
With a pure attention model, every file you add to the context makes generation slower because the KV cache grows. With hybrid SSM, adding context only affects the 26% of layers that use attention. The cost of stuffing your entire project into context is minimal compared to the fixed generation cost.
At 2.76 tok/s, every agent turn has a floor of about 46 seconds for 128 output tokens (a typical tool call or code edit). This is the cost of running 43 layers on DDR5 RAM. No amount of context optimization changes this number.
The model includes a built-in MTP (multi-token prediction) draft layer for speculative decoding. When properly supported by llama.cpp, this could push generation from 2.76 to 5-8 tok/s by predicting multiple tokens per forward pass. This is the single highest-impact optimization for this setup.
Matters:
Does not matter:
The Qwen3.8 hybrid SSM architecture is not just an incremental improvement. It changes what is possible on consumer hardware. A 27B model with 128k context on a 12 GB laptop GPU was not feasible six months ago -- not because of model quality, but because the KV cache physically did not fit.
The architecture choice matters more than the parameter count. A 27B hybrid SSM model fits where a 7B pure attention model would struggle. If you are choosing a model for local inference with long context, look at the architecture first and the parameter count second.
All benchmarks run with llama.cpp commit 76da2450a (build 9586), CUDA backend, -fa auto, 3 repetitions each. Test hardware: i9-14900HX, RTX 4080 Laptop 12 GB, 64 GB DDR5-5600.
Reproduction: Model: hf download Blackfrost-AI/Qwen3.8-27B-ABLITERATED-GGUF Qwen3.8-27B-ABLITERATED-Q4_K_M.gguf -- llama.cpp: cmake -B build -DGGML_CUDA=ON && cmake --build build --config Release