Phi-4 14B on RTX 4090 D (24GB) — VRAM, KV Cache & Throughput
Phi-4 14B (14.66B total, 14.66B active, Dense GQA) uses 8.28 GiB of 4-bit weights (Q4_K_M), requiring 10.4 GiB total at 8K context and 15.09 GiB at 32K on RTX 4090 D (~68.2 tok/s decode).
Recommended Hardware for Current Configuration
Production Launch Commands
llama-server -hf unsloth/phi-4-GGUF:Q4_K_M \ --ctx-size 8192 -ngl 999 --flash-attn
vllm serve microsoft/phi-4 \ --max-model-len 8192 --gpu-memory-utilization 0.92
Cloud GPU Comparison & Rent-vs-Buy TCO
Verified public rates across RunPod, Vast.ai, Vultr, and DigitalOcean.
| Provider | Recommended Instance | Total VRAM | Hourly Rate | Monthly at Selected Hours | Billing Mode | Deploy |
|---|---|---|---|---|---|---|
| RunPod | 1x RTX 3090 (Community Cloud) | 24 GB | $0.22 / hr | $26.75 / mo | Per-second | Deploy GPU ↗ |
| Vast.ai | 1x RTX 3060 12GB (Verified Host) | 12 GB | $0.06 / hr | $7.42 / mo | Spot / On-demand | Deploy GPU ↗ |
| Vultr ($300 Free Credit*) | 1x L40S 48GB (Dedicated Instance · $300 Credit*) | 48 GB | $1.67 / hr | $203.19 / mo | Hourly | Deploy GPU ↗ |
| Vultr Cloud GPU | 1x L40S 48GB (Dedicated Instance) | 48 GB | $1.67 / hr | $203.19 / mo | Hourly | Deploy GPU ↗ |
| DigitalOcean | 1x RTX 6000 Ada (Dedicated Instance) | 48 GB | $1.57 / hr | $190.91 / mo | Per-second | Deploy GPU ↗ |
Rates reflect public listings on the verification date and fluctuate with regional inventory.
Fine-Tuning VRAM Requirements (QLoRA / LoRA / Full) — Phi-4 14B
Engineering Sizing Notes & Optimization Playbook
Quick Hardware Verdict
RTX 4090 D (24GB physical, 22.8 GiB usable) runs 4-bit (Q4_K_M) Phi-4 14B at 8K context using 10.4 GiB with 12.4 GiB of safe headroom (~68.2 tok/s single-stream decode).
KV Cache & Runtime Tuning
Phi-4 14B uses Dense GQA (14.66B total, 14.66B active per token). Moving from 8K to 32K context expands FP16 KV cache from 1.56 GiB to 6.25 GiB; enabling 8-bit KV cache (llama.cpp -ctk q8_0 -ctv q8_0 or vLLM --kv-cache-dtype fp8) saves 3.12 GiB at 32K (reducing total VRAM to 11.97 GiB).
VRAM Scaling Across Context Windows (4K to 128K, 4-bit Weights)
Quantization Precision & Memory Matrix — Phi-4 14B @ 8K
| Quantization Format | Weights (GiB) | KV Cache | Total VRAM (GiB) | Decode Speed | Compatibility (RTX 4090 D) | Recommended GPU | Data Source |
|---|---|---|---|---|---|---|---|
| Native Weights (BF16 / FP8 / MXFP4 — Lossless) (BF16) | 27.31 GiB | 1.56 GiB | 29.43 GiB (31.6 GB) | ~7.3 tok/s | Exceeds Available GPU Memory | Radeon AI PRO R9700 32GB (32GB) | Official checkpoint size |
| FP8 / GGUF Q8_0 (8-bit — Near-Lossless) (Q8_0) | 14.51 GiB | 1.56 GiB | 16.63 GiB (17.86 GB) | ~40.6 tok/s | Fits with Safe Headroom | Arc Pro B60 24GB (24GB) | Measured GGUF shard size |
| GGUF Q6_K (6-bit — High Precision) (Q6_K) | 11.2 GiB | 1.56 GiB | 13.32 GiB (14.3 GB) | ~51.7 tok/s | Fits with Safe Headroom | RTX 4060 Ti 16GB (16GB) | Measured GGUF shard size |
| GGUF Q5_K_M (5-bit — Balanced) (Q5_K_M) | 9.7 GiB | 1.56 GiB | 11.82 GiB (12.69 GB) | ~59 tok/s | Fits with Safe Headroom | RTX 4060 Ti 16GB (16GB) | Measured GGUF shard size |
| Q4_K_M / UD-Q4_K_XL / AWQ (4-bit — Recommended) (Q4_K_M) | 8.28 GiB | 1.56 GiB | 10.4 GiB (11.17 GB) | ~68.2 tok/s | Fits with Safe Headroom | RTX 4060 Ti 16GB (16GB) | Measured GGUF shard size |
| GGUF IQ4_XS (4.25-bit — Compact) (IQ4_XS) | 7.4 GiB | 1.56 GiB | 9.52 GiB (10.22 GB) | ~75.4 tok/s | Fits with Safe Headroom | RTX 4060 Ti 16GB (16GB) | Config-derived formula |
| GGUF Q3_K_M (3-bit — Low VRAM) (Q3_K_M) | 6.7 GiB | 1.56 GiB | 8.82 GiB (9.47 GB) | ~82.3 tok/s | Fits with Safe Headroom | RTX 4060 Ti 16GB (16GB) | Measured GGUF shard size |
| GGUF UD-Q2_K_XL (2-bit — Extreme MoE) (UD-Q2_K_XL) | 4.9 GiB | 1.56 GiB | 7.02 GiB (7.54 GB) | ~107.9 tok/s | Fits with Safe Headroom | RTX 4060 Ti 16GB (16GB) | Config-derived formula |
Technical Specifications & FAQ
Does Phi-4 14B fit on RTX 4090 D (24GB)?
In 4-bit (Q4_K_M) at 8,192 context, Phi-4 14B requires 10.4 GiB total GPU memory (8.28 GiB weights + 1.56 GiB KV cache + 0.56 GiB runtime buffers) against 22.8 GiB usable on RTX 4090 D, delivering ~68.2 tok/s decode.
How much VRAM does Phi-4 14B need at 32K context?
At 32,768 context tokens, Phi-4 14B (Dense GQA) allocates 6.25 GiB for KV cache and state, bringing total 4-bit VRAM to 15.09 GiB (16.2 GB decimal).