cd /news/large-language-models/qwen-27b-with-128k-context-on-24gb-v… · home topics large-language-models article
[ARTICLE · art-73671] src=promptcube3.com ↗ pub= topic=large-language-models verified=true sentiment=· neutral

Qwen 27B with 128k Context on 24GB VRAM?

Users report running Qwen 27B with a 128k context window on a single 24GB VRAM card by setting Ollama environment variables OLLAMA_FLASH_ATTENTION=1 and OLLAMA_KV_CACHE_TYPE=q4_0, which quantizes the KV cache to q4_0 and reduces memory usage to 83% at 128k context. Without these flags, the KV cache alone would exceed 24GB. Performance reaches about 30 tok/s, dropping to 4 tok/s if spilling to system RAM.

read2 min views1 publishedJul 25, 2026
Qwen 27B with 128k Context on 24GB VRAM?
Image: Promptcube3 (auto-discovered)

Running a 27B model with a 128k context window on a single 24GB card sounds like a recipe for an OOM (Out of Memory) crash, but I'm seeing reports that it's actually working. The key seems to be a specific combo of Ollama environment variables that drastically cuts down the memory footprint of the KV cache.

It's a decent deep dive into how much we can optimize the AI workflow by tweaking the backend rather than just hoping for a smaller model. If you've been capping your context at 32k because of VRAM limits, definitely test these flags.

If you're trying to squeeze long-context LLM agents into limited VRAM, you need to look at these two flags:

OLLAMA_FLASH_ATTENTION=1
OLLAMA_KV_CACHE_TYPE=q4_0

The q4_0

KV cache quantization is the real heavy lifter here. Instead of storing the cache in FP16, it compresses it, which is why someone is reporting 83% VRAM usage at 128k context on a 24GB card. Without this, the KV cache for a 27B model at that context length would easily blow past 24GB on its own, regardless of the model quantization.

The performance hit is surprisingly minimal too—hitting around 30 tok/s. If it spills over into system RAM, you're looking at a drop to maybe 4 tok/s, which makes the local deployment basically unusable for real-time work.

A few observations from this setup:

Q4 Quantization: 128k context fits comfortably.Q5 Quantization: Hits a wall around 96k context.

It's a decent deep dive into how much we can optimize the AI workflow by tweaking the backend rather than just hoping for a smaller model. If you've been capping your context at 32k because of VRAM limits, definitely test these flags.

Next DeepSeek-R1 Local Deployment: My Hardware Struggles →

All Replies (4) #

Q

Flash attention 2 makes a huge difference here, though it's a pain to compile sometimes.

0

N

KV cache quantization helps, but I still hit a wall around 64k on my 3090.

0

T

Does the perplexity tank as you get closer to that limit, or does it hold up?

0

J

That's the real question. I've noticed some "lost in the middle" issues with other models, wonder if Qwen does the same.

0

── more in #large-language-models 4 stories · sorted by recency
── more on @qwen 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/qwen-27b-with-128k-c…] indexed:0 read:2min 2026-07-25 ·