Qwen 3.8 27B at 50 tok/s with 100k Context on a 16GB GPU! (beellama.cpp)
Mirrored from r/LocalLLaMA for archival readability. Support the source by reading on the original site.
I wanted to share my successful setup for running a Qwen 3.8 27B model with a massive context window on a consumer 16GB GPU (RTX 4070 Ti SUPER). The goal was to fit everything into VRAM without sacrificing quality or speed.
🧠 Key Components
- Model:
Qwen3.8-27B-i1-IQ4_XS-GGUF-Smallerfrom jrell on Hugging Face. It's a custom hybrid quantization specifically designed to fit Multi-Token Prediction (MTP) and long contexts into a 16GB VRAM budget. - Chat Template: I used the Jinja template from peculiar-ragdoll's Qwen-Sharp-Chat-Templates. It helps use fewer thinking tokens without noticeably affecting quality, which is great for speed.
- Inference Engine: This is crucial. I used beellama.cpp (GitHub link) because it supports the
kvarnKV cache types, which are key to this optimization.
🖥️ Optimized llama-server Command (Windows)
Here's the polished command I'm running. The magic is in the kvarn cache settings and the tail precision.
%LLAMA_DIR%/llama-server.exe ^ -m %MODEL_PATH% ^ -a %MODEL_NAME% ^ --port 11434 ^ --temp 1.0 ^ --top-p 0.95 ^ --top-k 20 ^ --min-p 0.0 ^ --presence-penalty 0.0 ^ --repeat-penalty 1.0 ^ --parallel 1 ^ --n-gpu-layers 99 ^ --batch-size 1024 ^ --ubatch-size 256 ^ --flash-attn on ^ --spec-type draft-mtp ^ --spec-draft-n-max 2 ^ --cache-type-k kvarn5 ^ <-- Key: Higher precision for K cache --cache-type-v kvarn4 ^ <-- Key: Balanced precision for V cache --kv-tail-tokens 1024 ^ <-- Keeps recent tokens at full precision --ctx-size 100000 ^ --fit-ctx 100000 ^ --jinja ^ --chat-template-kwargs "{\"preserve_thinking\": true, \"reasoning_effort\":\"medium\"}" ^ --chat-template-file %MODEL_JINJA% ^ --no-mmproj-offload ^ --threads 7 ^ --threads-batch 8 ^ --metrics ^ --verbosity 3 ^ --perf 📊 Results & Optimization Notes
| Metric | Result | Note |
|---|---|---|
| Generation Speed | 47-50 tokens/second | Excellent for a 27B dense model. |
| Context Window | 100,000 tokens | Successfully pushed from 88k by optimizing the cache. |
| VRAM Usage | ~15.93 GB (70 MB free) | Perfectly tuned to the limit for maximum context. |
| KV Cache Type | kvarn5 (K) / kvarn4 (V) | Uses the kvarn types from beellama. The asymmetric mix balances memory and quality. |
| Precision Tail | --kv-tail-tokens 1024 | This is key. It keeps recent tokens at higher precision, preserving output quality. |
What I Optimized:
- KV Cache Quantization: Moving from
kvarn5/kvarn5tokvarn5/kvarn4saved ~6% VRAM, allowing the context size to increase from 88k to 100k with minimal quality loss. - Batch Sizes: Set
--batch-size 1024and--ubatch-size 256to balance prompt processing speed and VRAM usage. - Threading: Adjusted
--threads 7and--threads-batch 8for my Ryzen 7 CPU. - Speculative Decoding: Using
--spec-type draft-mtpwith 2 draft tokens (the model supports this) gave a huge speed boost.
The near-lossless kvarn quantization for the KV cache is the real star here. It delivers q5-class fidelity at q4-class memory usage, which is incredible.
Hopefully, this helps anyone trying to squeeze maximum performance out of a 16GB card! Cheers.
[link] [comments]
More from r/LocalLLaMA
-
Uncensored Multi-Model Releases, LongCat-Flash-Lite-Sparse with MTPs and LSAs, Qwen3.8-27B with MTPs, Qwen3.5-122B-A10B with MTPs, Qwen3-Coder-Next and Laguna-S2.1 with Vision, All Available in GGUF Format! Bonus: Links to my llama.cpp Fork for LongCat-Flash-Lite Support and…
Aug 30
-
Got MiniMax H3 video generation running in TensorSharp
Aug 30
-
Qwen3.8-Flash-Next NVFP4 2xDGX Spark config: 50t/s decode, 2,900t/s prefill
Aug 30
-
Don't Sleep on EXL3 Quants
Aug 30
Discussion (0)
Sign in to join the discussion. Free account, 30 seconds — email code or GitHub.
Sign in →No comments yet. Sign in and be the first to say something.