microsoft · text

phi-2

microsoft/phi-2

phi-2 at Q4_K_M is exactly 1,737,636,384 bytes (1.62 GiB / 1.74 GB) — an effective 5.001 bits per weight, not the nominal 4. Its KV cache at 32K is 10.00 GiB.

From the file· summed from 1 file(s)From the file· KV per layer
Parameters
2.8B
Architecture
phi2
32 layers
Context
2,048
native (config.json)
License
other

Shipped quantizations

exact bytes, summed from published files
QuantSizeExact bytesEffective bpwTensorsPublisher
Q2_K1.03 GiB1,109,719,5843.194second-state
Q2_K1.03 GiB1,109,719,5843.194MaziyarPanahi
Q2_K1.09 GiB1,173,610,3363.378TheBloke
Q3_K_S1.16 GiB1,250,819,9363.600TheBloke
Q3_K_S1.16 GiB1,250,826,7843.600MaziyarPanahi
Q3_K_S1.16 GiB1,250,826,7843.600second-state
Q3_K_M1.33 GiB1,432,689,1844.123MaziyarPanahi
Q3_K_M1.33 GiB1,432,689,1844.123second-state
Q3_K_M1.38 GiB1,480,195,9364.260TheBloke
Q3_K_L1.47 GiB1,575,229,9844.534MaziyarPanahi
Q3_K_L1.47 GiB1,575,229,9844.534second-state
Q4_01.49 GiB1,602,461,5364.612TheBloke
Q4_01.49 GiB1,602,468,3844.612second-state
Q3_K_L1.49 GiB1,604,714,3364.618TheBloke
Q4_K_S1.50 GiB1,615,568,7364.650TheBloke
Q4_K_S1.52 GiB1,631,959,5844.697MaziyarPanahi
Q4_K_S1.52 GiB1,631,959,5844.697second-state
Q4_K_M1.62 GiB1,737,636,3845.001MaziyarPanahi
Q4_K_M1.62 GiB1,737,636,3845.001second-state
Q4_K_M1.67 GiB1,789,239,1365.149TheBloke
Q5_K_S1.80 GiB1,933,418,3365.564TheBloke
Q5_01.80 GiB1,933,418,3365.564TheBloke
Q5_01.80 GiB1,933,425,1845.564second-state
Q5_K_S1.80 GiB1,933,425,1845.564MaziyarPanahi
Q5_K_S1.80 GiB1,933,425,1845.564second-state
Q5_K_M1.87 GiB2,003,057,1845.765MaziyarPanahi
Q5_K_M1.87 GiB2,003,057,1845.765second-state
Q5_K_M1.93 GiB2,072,682,3365.965TheBloke
Q6_K2.13 GiB2,285,059,9366.577TheBloke
Q6_K2.13 GiB2,285,066,7846.577second-state
Q6_K2.13 GiB2,285,066,7846.577MaziyarPanahi
Q8_02.75 GiB2,958,032,7368.513TheBloke
Q8_02.75 GiB2,958,039,5848.513MaziyarPanahi
Q8_02.75 GiB2,958,039,5848.513second-state

KV cache by context

computed per layer
ContextKV cache (f16)Flat formulaOverstated byFull / windowed / recurrent
4,0961.25 GiB1.25 GiB32 / 0 / 0
8,1922.50 GiB2.50 GiB32 / 0 / 0
16,3845.00 GiB5.00 GiB32 / 0 / 0
32,76810.00 GiB10.00 GiB32 / 0 / 0
65,53620.00 GiB20.00 GiB32 / 0 / 0
131,07240.00 GiB40.00 GiB32 / 0 / 0

Compare with

same modality, comparable size

Will it run on your card?

full quant x context sweep

Why other calculators give a different number

A parameters × bits ÷ 8 estimate puts Q4_K_M at roughly 1.46 GiB. The real file is 1.62 GiB, because a quantization is a mixture and some tensors are always kept at higher precision.

Architecture

from config.json
Layers
32
Attention heads
32
KV heads
32
Head dim
80
Hidden size
2560
Vocab
51,200
Sliding window
none
SWA period
MLA
no
Experts
Experts per token
use_sliding_window

Questions people ask

How much VRAM does phi-2 need?
Q4_K_M is exactly 1,737,636,384 bytes (1.62 GiB) in weights. Add the KV cache, which depends on your context length, plus roughly half a gigabyte of runtime overhead.
How large is phi-2's KV cache?
10.00 GiB at 32K context with an f16 cache, computed per layer. Quantizing the cache to q8_0 roughly halves it, which is often the difference between a context length fitting and not.
Which quantization of phi-2 should I use?
Q4_K_M is the usual default. Pick the largest quantization that fits your card at the context you actually need — the table above gives exact sizes for every one published.