ollama - 💡(How to fix) Fix Feature Request: Add Flash Attention support for EXAONE 4.0 architecture [2 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
ollama/ollama#14909Fetched 2026-04-08 00:53:08
View on GitHub
Comments
2
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
commented ×2cross-referenced ×1subscribed ×1

EXAONE 4.0 32B (by LG AI Research) is not included in Ollama's Flash Attention allowlist, causing KV cache to fall back to FP16 instead of q8_0. This doubles the KV cache memory usage, severely limiting the usable context window on multi-GPU setups.

Root Cause

When running EXAONE 4.0 32B (GGUF from LGAI-EXAONE/EXAONE-4.0-32B-GGUF) with OLLAMA_FLASH_ATTENTION=1 and OLLAMA_KV_CACHE_TYPE=q8_0, the q8_0 KV cache is not applied. Instead, Ollama falls back to FP16 KV cache because the EXAONE architecture is not in the Flash Attention supported model list.

Code Example

Per token: 2 (K+V) × 64 layers × 8 KV heads × 128 head_dim × 2 bytes (FP16) = 262,144 bytes/token

---

Per token: 2 (K+V) × 64 layers × 8 KV heads × 128 head_dim × 1 byte (q8_0) = 131,072 bytes/token
RAW_BUFFERClick to expand / collapse

Summary

EXAONE 4.0 32B (by LG AI Research) is not included in Ollama's Flash Attention allowlist, causing KV cache to fall back to FP16 instead of q8_0. This doubles the KV cache memory usage, severely limiting the usable context window on multi-GPU setups.

Problem

When running EXAONE 4.0 32B (GGUF from LGAI-EXAONE/EXAONE-4.0-32B-GGUF) with OLLAMA_FLASH_ATTENTION=1 and OLLAMA_KV_CACHE_TYPE=q8_0, the q8_0 KV cache is not applied. Instead, Ollama falls back to FP16 KV cache because the EXAONE architecture is not in the Flash Attention supported model list.

Impact (measured on RTX 3060 12GB + RTX 3090 24GB = 36GB VRAM)

QuantizationMax Context (100% GPU)Ollama Est. VRAMActual nvidia-smi
Q4_K_M45K (46,080)35 GB~27 GB
Q5_K_M37K (37,888)35 GB~29 GB

If q8_0 KV cache were supported (1 byte per value instead of 2 bytes for FP16), the KV cache would be halved, allowing approximately 90K context for Q4 and 70K context for Q5 on the same hardware.

KV Cache calculation (FP16 fallback, current)

Per token: 2 (K+V) × 64 layers × 8 KV heads × 128 head_dim × 2 bytes (FP16) = 262,144 bytes/token

KV Cache calculation (q8_0, desired)

Per token: 2 (K+V) × 64 layers × 8 KV heads × 128 head_dim × 1 byte (q8_0) = 131,072 bytes/token

Technical Details

  • EXAONE 4.0 uses standard Grouped Query Attention (GQA) — structurally compatible with Flash Attention
  • Architecture: 64 layers, 40 attention heads, 8 KV heads, 128 head dimension
  • The model supports up to 32,768 native context (extendable with RoPE)
  • Ollama version: latest (as of March 2026)

Environment

  • OS: Ubuntu 22.04 (Linux)
  • GPUs: RTX 3060 (12GB) + RTX 3090 (24GB)
  • Ollama settings: OLLAMA_FLASH_ATTENTION=1, OLLAMA_KV_CACHE_TYPE=q8_0, OLLAMA_SCHED_SPREAD=1
  • Model source: LGAI-EXAONE/EXAONE-4.0-32B-GGUF (Q4_K_M and Q5_K_M)

Request

Please add EXAONE 4.0 architecture to the Flash Attention supported model list so that q8_0/q4_0 KV cache types work correctly with this model. This would significantly improve the usable context window for EXAONE users on consumer GPUs.

extent analysis

Fix Plan

To fix the issue, we need to add the EXAONE 4.0 architecture to the Flash Attention supported model list. Here are the steps:

  • Update the supported_models list in the Ollama configuration file to include the EXAONE 4.0 architecture.
  • Modify the flash_attention.py file to include the EXAONE 4.0 architecture in the SUPPORTED_MODELS dictionary.

Example code:

# In flash_attention.py
SUPPORTED_MODELS = {
    # ... existing models ...
    'exaone-4.0-32b': {
        'num_layers': 64,
        'num_heads': 40,
        'num_kv_heads': 8,
        'head_dim': 128
    }
}

# In ollama_config.py
supported_models = [
    # ... existing models ...
    'exaone-4.0-32b'
]
  • Restart the Ollama service to apply the changes.

Verification

To verify that the fix worked, run the following command:

OLLAMA_FLASH_ATTENTION=1 OLLAMA_KV_CACHE_TYPE=q8_0 python -c "import ollama; print(ollama.get_kv_cache_type())"

This should output q8_0 if the fix was successful.

Extra Tips

  • Make sure to update the Ollama version to the latest one to ensure compatibility with the EXAONE 4.0 architecture.
  • If you encounter any issues during the update process, refer to the Ollama documentation for troubleshooting guides.
  • To further optimize the KV cache, consider using a smaller head dimension or reducing the number of KV heads. However, this may impact the model's performance.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING