code Llama 2 13B needs about 15.1 GB of memory at Q4_K_M (a 7.9 GB file) with an 8K context window, so it fits on a 16 GB GPU. This repository has 14 quants, from 4.9 GB (Q2_K) to 13.8 GB (Q8_0).
Code Llama 2 13B – a 13‑billion‑parameter coding model in GGUF format
Code Llama 2 13B is a 13‑billion‑parameter language model optimized for coding tasks. It supports up to 16384 context tokens and is available in multiple GGUF quantizations. The model is licensed under the llama2 license.
Good at
- Code completion
- Code infilling
- Instruction following
Limits
- No vision support
- Requires 8‑k context for memory estimates
- Commercial license
Best for
- Developers writing code
- Automating code reviews
- Generating SQL queries from natural language
Who it’s for. This model is suitable for developers, researchers, and enterprises needing a coding‑focused LLM. It is designed for English‑only use and requires a commercial license for deployment.
Quants & memory
| Quant | File | Est. memory | vs VRAM | Result | |
|---|---|---|---|---|---|
| Q2_K | 4.9 GB | 12.1 GB | Too big | Get file → | |
| IQ3_XS | 5.4 GB | 12.6 GB | Too big | Get file → | |
| IQ3_S | 5.7 GB | 12.9 GB | Too big | Get file → | |
| Q3_K_S | 5.7 GB | 12.9 GB | Too big | Get file → | |
| IQ3_M | 6.0 GB | 13.2 GB | Too big | Get file → | |
| Q3_K_M | 6.3 GB | 13.5 GB | Too big | Get file → | |
| Q3_K_L | 6.9 GB | 14.1 GB | Too big | Get file → | |
| IQ4_XS | 7.0 GB | 14.2 GB | Too big | Get file → | |
| Q4_K_S | 7.4 GB | 14.6 GB | Too big | Get file → | |
| Q4_K_M | 7.9 GB | 15.1 GB | Too big | Get file → | |
| Q5_K_S | 9.0 GB | 16.2 GB | Too big | Get file → | |
| Q5_K_M | 9.2 GB | 16.4 GB | Too big | Get file → | |
| Q6_K | 10.7 GB | 17.9 GB | Too big | Get file → | |
| Q8_0 | 13.8 GB | 21.0 GB | Too big | Get file → |
For 8‑GB VRAM, use Q4_K_M (file size 7.87 GB, memory 15.1 GB). For 16‑GB VRAM, Q5_K_M (9.23 GB, 16.4 GB) or Q6_K (10.68 GB, 17.9 GB). For 24‑GB VRAM, Q8_0 (13.83 GB, 21 GB) provides the highest quality.
What GPU do you need for code Llama 2 13B?
These figures add the file size, an fp16 KV cache at an 8K context window (worked out from this model’s own header) and about 0.5 GB for the runtime. They are estimates, so leave a little headroom, and expect to use less context or a smaller quant if you are right at the limit.
- 4 GB VRAM: no quant fits at an 8K context.
- 6 GB VRAM: no quant fits at an 8K context.
- 8 GB VRAM: no quant fits at an 8K context.
- 12 GB VRAM: no quant fits at an 8K context.
- 16 GB VRAM: the best quant that fits is Q4_K_M (7.9 GB file, about 15.1 GB in use).
- 24 GB VRAM: the best quant that fits is Q8_0 (13.8 GB file, about 21.0 GB in use).
Which code Llama 2 13B quant should you choose?
Q4_K_M is the usual starting point for code Llama 2 13B: it balances file size and quality well. Here it is a 7.9 GB file.
The Q8_0 file is 13.8 GB, about 1.8 times the size of Q4_K_M. It keeps the weights closer to the original, which only matters if you have the memory to spare.
If memory is tight, the smallest file is Q2_K at 4.9 GB, with the quality trade-offs that come with fewer bits. Use it only when memory is very tight. Expect a clear drop in quality, which is usually worse on small models and easier to live with on large ones.
New to quant names? Read GGUF quantization explained.
Specifications
Architecture from the GGUF header
Source
Frequently asked questions about code Llama 2 13B
How much VRAM does code Llama 2 13B need?
About 15.1 GB at Q4_K_M with an 8K context window. That is the 7.9 GB file, plus the KV cache and roughly 0.5 GB of runtime overhead. Smaller quants need less and longer context needs more.
Can I run code Llama 2 13B on an 8 GB GPU?
Not at an 8K context. The smallest file needs about 12.1 GB, so you would need a larger GPU or CPU offloading.
What is the file size of code Llama 2 13B GGUF?
It depends on the quant: Q2_K is 4.9 GB, IQ3_XS is 5.4 GB, IQ3_S is 5.7 GB, Q3_K_S is 5.7 GB, IQ3_M is 6.0 GB, Q3_K_M is 6.3 GB and 8 more.
What context length does code Llama 2 13B support?
The GGUF header lists a trained context length of 16,384 tokens (16K). The KV cache grows with the context you use: about 6.7 GB at 8K and 13.4 GB at 16K.
Where can I download code Llama 2 13B GGUF?
The files are on Hugging Face in the mradermacher/code-Llama-2-13B-GGUF repository. The download buttons on this page open the file on Hugging Face. ggufmodels.com does not host any model files.
What license does code Llama 2 13B use?
Hugging Face lists the license as llama2. Licenses can differ between the quantized files and the original model, so check the repository and the base model before commercial use.
Can I run Q4_K_M on 8 GB VRAM?
Yes, Q4_K_M requires about 15.1 GB of VRAM at 8‑k context, which fits within an 8‑GB VRAM budget when using efficient memory management.
Is the model suitable for text‑to‑SQL tasks?
The base model is fine‑tuned for text‑to‑SQL, but the provided GGUF files are general coding models and may need additional fine‑tuning for optimal SQL generation.
What license applies to this model?
The model is governed by the llama2 license, which allows commercial use under the specified terms.