Local LLM Inference for Coding: The Complete 2025/2026 Guide
Running AI coding assistants locally has shifted from a hobbyist experiment to a genuinely competitive alternative to cloud-based tools. In 2025, models like Qwen2.5-Coder-32B match GPT-4o on HumanEval benchmarks, and the tooling — Ollama, LM Studio, llama.cpp — has matured to the point where setup takes minutes rather than days. This guide covers everything from model selection and hardware requirements to full editor integration with Continue.dev and Aider.
Part 1: The Best Local Models for Code Generation
The Benchmark Landscape
Three benchmarks matter most for evaluating coding models:
- HumanEval: 164 Python function-completion problems. A widely-used but increasingly criticized benchmark because models can be trained to game it.
- MBPP (Mostly Basic Python Problems): 500 crowd-sourced Python tasks. Broader coverage than HumanEval.
- SWE-bench: Real GitHub issues that must be resolved by modifying actual codebases. Far harder and more representative of real engineering work. Even frontier models struggle here.
- LiveCodeBench: Ongoing competitive programming problems with a time-cutoff to prevent data contamination.
Model-by-Model Breakdown
Qwen2.5-Coder (Alibaba) — The Current Leader
Alibaba’s Qwen2.5-Coder family dominates every size tier in 2025/2026. Trained on over 5.5 trillion tokens of code-heavy data, it supports 40+ programming languages and ships in six sizes (0.5B to 32B). Critically, all sizes support Fill-in-the-Middle (FIM), which is essential for IDE autocomplete.
| Model | HumanEval | Context Window | Notes |
|---|---|---|---|
| Qwen2.5-Coder-32B | 92.7% | 128K | Matches GPT-4o; fits 24GB VRAM at Q4_K_M |
| Qwen2.5-Coder-14B | ~89% | 128K | Strong mid-range option |
| Qwen2.5-Coder-7B | 88.4% | 128K | Beats models 3-5x its size |
| Qwen2.5-Coder-1.5B | ~75% | 32K | Excellent autocomplete model |
The 32B model at Q4_K_M quantization fits in approximately 20GB of VRAM, making it viable on a single RTX 3090 or 4090. For autocomplete, the 1.5B model runs on almost any hardware and has low enough latency to feel instant.
DeepSeek-Coder-V2 — MoE Architecture and 128K Context
DeepSeek-Coder-V2 uses a Mixture-of-Experts architecture and was the first open-source model to break 10% on SWE-bench, which represents a genuine milestone for real-world coding tasks.
| Variant | Parameters (Total/Active) | HumanEval | MBPP+ | SWE-bench | Context |
|---|---|---|---|---|---|
| DeepSeek-Coder-V2 | 236B / 21B | 90.2% | 76.2% | 12.7% | 128K |
| DeepSeek-Coder-V2-Lite | 16B / 2.4B | 81.1% | ~65% | — | 128K |
The Lite variant is the practical local choice: because only 2.4B parameters activate per inference, it is fast and memory-efficient while delivering strong results. The full 236B model is impractical for single-GPU consumer hardware but can be used via API.
Training data was 10.2 trillion tokens: roughly 60% source code across 338 programming languages, 10% mathematics, and 30% natural language.
CodeLlama (Meta) — Aging But Accessible
CodeLlama is based on Llama 2 and continues pre-training on 500–1,000 billion code tokens. It comes in four sizes: 7B, 13B, 34B, and 70B. While it was a dominant model in 2023, it has been significantly outpaced by Qwen2.5-Coder and DeepSeek.
| Model | HumanEval | MBPP |
|---|---|---|
| CodeLlama-34B | 53.7% | 56.2% |
| CodeLlama-7B | ~30% | ~35% |
CodeLlama is still useful when VRAM is severely constrained, since it is widely available in GGUF format at many quantization levels. Its instruction-following variants (CodeLlama-Instruct) are better for chat-style use.
StarCoder2 (BigCode / Hugging Face) — Open Training Data
StarCoder2 was trained on The Stack v2 dataset covering 619 programming languages. Its key advantage is a fully transparent, open training data provenance — important for organizations with compliance requirements.
| Model | Benchmark Notes |
|---|---|
| StarCoder2-3B | Outperforms most same-size models; best tiny model for FIM |
| StarCoder2-7B | Competitive mid-range |
| StarCoder2-15B | Matches or beats CodeLlama-34B on most tasks |
StarCoder2-15B at Q4_K_M is roughly 10GB and is a strong autocomplete model. It was not trained to game HumanEval specifically, meaning its CRUXEval (code execution reasoning) scores are more correlated with its HumanEval scores — a sign of genuine capability rather than benchmark overfitting.
WizardCoder — Instruction Tuning via Evol-Instruct
WizardCoder applies the Evol-Instruct method to StarCoder and CodeLlama base models, iteratively transforming training instructions to be more complex and diverse.
| Model | Base | HumanEval+ |
|---|---|---|
| WizardCoder-15B | StarCoder-15B | 59.8% |
| WizardCoder-34B | CodeLlama-34B | 73.2% (from 53.7%) |
WizardCoder-34B surpassed GPT-3.5 on HumanEval+ (73.2% vs 63.4%). However, like many instruction-tuned models, it may not generalize as broadly as its benchmark scores suggest, and it has largely been superseded by Qwen2.5-Coder.
Mistral and Mixtral for Coding
Mistral’s Codestral-22B is purpose-built for code, scoring 81.1% on HumanEval and including strong FIM support. The Mixtral MoE variants (8x7B, 8x22B) are capable general-purpose models that handle coding reasonably well, though they are outperformed by Qwen2.5-Coder at equivalent compute budgets. Mixtral 8x7B activates about 12B parameters per inference, fitting in roughly 24GB of VRAM for the Q4 variant.
Comprehensive Benchmark Comparison Table
| Model | Size | HumanEval | MBPP | SWE-bench | Context | Local Viable? |
|---|---|---|---|---|---|---|
| Qwen2.5-Coder-32B | 32B | 92.7% | ~80% | — | 128K | Yes (24GB GPU) |
| DeepSeek-Coder-V2 | 236B / 21B active | 90.2% | 76.2% | 12.7% | 128K | Via API or multi-GPU |
| Qwen2.5-Coder-7B | 7B | 88.4% | ~73% | — | 128K | Yes (8GB GPU) |
| DeepSeek-Coder-V2-Lite | 16B / 2.4B active | 81.1% | ~65% | — | 128K | Yes (8GB GPU) |
| Codestral-22B | 22B | 81.1% | — | — | 32K | Yes (16GB GPU) |
| WizardCoder-34B | 34B | 73.2% | — | — | 16K | Yes (24GB GPU) |
| StarCoder2-15B | 15B | ~70% | — | — | 16K | Yes (12GB GPU) |
| CodeLlama-34B | 34B | 53.7% | 56.2% | Very low | 100K | Yes (24GB GPU) |
| CodeLlama-7B | 7B | ~30% | ~35% | Very low | 100K | Yes (4-6GB GPU) |
Part 2: Ollama
Ollama is the simplest way to run LLMs locally. It handles model downloads, quantization selection, server lifecycle, and exposes both a native REST API and an OpenAI-compatible API at http://localhost:11434.
Installation
|
|
Verify the installation and start the service:
|
|
Pulling Coding Models
|
|
Ollama REST API
Ollama exposes two API flavors. Use the native API for full control, or the OpenAI-compatible API to drop into any existing OpenAI client.
Native Chat API (POST /api/chat):
|
|
Native Generate API (POST /api/generate):
|
|
List local models (GET /api/tags):
|
|
OpenAI-Compatible Chat Completions (POST /v1/chat/completions):
|
|
This OpenAI-compatible endpoint lets you point any OpenAI SDK client at Ollama by changing base_url:
|
|
Model Library
Ollama’s model library at ollama.com/library lists all available models. Key coding models available as of early 2026:
qwen2.5-coder— 0.5b, 1.5b, 3b, 7b, 14b, 32bdeepseek-coder-v2— 16b, 236bstarcoder2— 3b, 7b, 15bcodellama— 7b, 13b, 34b, 70bdeepseek-r1— 1.5b, 7b, 8b, 14b, 32b, 70b, 671bllama3.1,llama3.2,llama3.3— general-purpose with strong codingmistral,mixtral— capable general-purpose models
VS Code Integration
Ollama has a first-class VS Code integration page at docs.ollama.com/integrations/vscode, and is the recommended backend for the Continue.dev extension (see Part 6).
For a remote Ollama server, set the host environment variable before starting the service:
|
|
Then connect clients to http://your-server-ip:11434.
Part 3: LM Studio
LM Studio is a polished desktop GUI application that handles local model management, inference, and serves an OpenAI-compatible API. It targets both developers and non-technical users, and is available for macOS, Windows, and Linux.
Key Features
- Model Browser: Search and download models directly from Hugging Face within the app. Filter by size, architecture, and quantization level.
- OpenAI-Compatible Server: Exposes
http://localhost:1234/v1with chat completions, embeddings, and — as of v0.3.29 — the OpenAI Responses API including stateful interactions (previous_response_id), function tool calling, remote MCP server connections, reasoning effort controls, and streaming. - Multiple Inference Engines: Ships with both llama.cpp (for GGUF models) and Apple MLX (for Apple Silicon Macs). The engine is selected automatically based on hardware.
- Hardware Detection: Automatically detects GPU capabilities and configures layer offloading. Supports Vulkan for integrated Intel/AMD GPUs.
- Intelligent Memory Management: Can split models across GPU VRAM and system RAM. Note: overflowing to RAM reduces speed by approximately 30x.
- Headless Daemon (
llmster): LM Studio’s core packaged as a standalone daemon for server/CI deployment without the GUI. - MCP Client: Connect external tool servers (Model Context Protocol) for agent workflows.
OpenAI-Compatible API Usage
|
|
Best Models to Use in LM Studio
LM Studio’s model browser makes it easy to search Hugging Face. For coding, prioritize:
- Qwen2.5-Coder-32B-Instruct-GGUF (Q4_K_M ~20GB): Best overall local coding model
- Qwen2.5-Coder-7B-Instruct-GGUF (Q4_K_M ~5GB): Fast and capable for 8GB VRAM
- DeepSeek-Coder-V2-Lite-Instruct-GGUF (Q4_K_M ~10GB): Strong MoE reasoning
- StarCoder2-15B-GGUF (Q4_K_M ~10GB): Excellent for FIM/autocomplete
Search for models with “GGUF” in the name and filter by “instruct” variants for chat-style use.
Part 4: llama.cpp
llama.cpp is the foundational C/C++ inference library that powers Ollama, LM Studio, and many other tools. It requires no dependencies, runs on virtually any hardware, and is the reference implementation for GGUF format inference.
Compilation
|
|
The GGUF Format
GGUF (GGML Unified Format) is llama.cpp’s native model format. It stores all model metadata — tokenizer, architecture config, special tokens, RoPE scaling parameters — in a single self-contained file. Models from Hugging Face in safetensors or PyTorch format can be converted:
|
|
Quantization Levels
Quantization reduces model size and speeds up inference at the cost of some quality. The K_M suffix indicates “medium quality K-quant” — these use higher precision for the most important layers.
| Type | 7B Size | Perplexity Loss | Recommendation |
|---|---|---|---|
| F16 | ~14 GB | Baseline | Reference quality, high VRAM |
| Q8_0 | ~7.96 GB | +0.0004 | Near-lossless, rarely worth it |
| Q6_K | ~6.14 GB | +0.0044 | Near-lossless, quality-critical work |
| Q5_K_M | ~5.33 GB | +0.0142 | High quality, recommended for production |
| Q4_K_M | ~4.58 GB | +0.0535 | Best balance — the standard default |
| Q3_K_M | ~3.74 GB | +0.1453 | Noticeable quality drop |
| Q2_K | ~2.96 GB | +0.6717 | Severe degradation — avoid |
Q4_K_M is the community standard default. Q5_K_M is recommended when you have the VRAM headroom and care about code correctness. Below Q3, quality degrades noticeably on complex coding tasks.
Quantizing a Model
|
|
GPU Offloading
Use the -ngl flag (number of GPU layers) to offload model layers to VRAM. More layers = faster inference, up to the model’s total layer count.
|
|
Partial offloading is useful when the model doesn’t fully fit in VRAM. Offloading even 50% of layers provides significant speed gains over pure CPU inference.
Server Mode
llama.cpp ships with llama-server, an OpenAI-compatible HTTP server:
|
|
Connect any OpenAI client to http://localhost:8080/v1.
|
|
Benchmarking
|
|
Part 5: Hardware Requirements
VRAM Requirements by Model Size
The formula for estimating VRAM requirements is approximately:
VRAM (GB) = (Parameters in billions) × (bits per weight / 8) × 1.1
The 1.1 factor accounts for KV cache and other overhead.
| Model Size | Q4_K_M VRAM | Q5_K_M VRAM | Q8_0 VRAM | F16 VRAM |
|---|---|---|---|---|
| 3B | ~2 GB | ~2.5 GB | ~3.5 GB | ~6 GB |
| 7B | ~5 GB | ~6 GB | ~8 GB | ~14 GB |
| 13B | ~8 GB | ~10 GB | ~14 GB | ~26 GB |
| 32B | ~20 GB | ~24 GB | ~34 GB | ~64 GB |
| 70B | ~42 GB | ~50 GB | ~74 GB | ~140 GB |
Note: Larger context windows increase KV cache usage. A 32K context window on a 7B model adds roughly 1-2GB extra VRAM compared to 4K context.
Consumer GPU Recommendations
| GPU | VRAM | Best Model Size | Approximate Speed (7B Q4) |
|---|---|---|---|
| RTX 3060 / 4060 | 12 GB | Up to 7B comfortably, tight 13B | 20–35 tok/s |
| RTX 4060 Ti | 16 GB | 7B–13B, squeeze 30B with Q3 | 25–40 tok/s |
| RTX 3090 | 24 GB | 30–32B comfortably, 70B with aggressive quant | 40–60 tok/s |
| RTX 4090 | 24 GB | 30–32B comfortably, 70B with aggressive quant | 60–90 tok/s |
| RTX 5090 | 32 GB | Up to 70B at Q4; some 405B with heavy quant | 80–120 tok/s (7B) |
| Dual RTX 3090 | 48 GB | 70B at Q4 comfortably | 50–70 tok/s (70B) |
For coding specifically: an RTX 4060 Ti (16GB) at roughly $400-500 USD is the best value entry point for running Qwen2.5-Coder-7B or 14B. An RTX 3090 (24GB, used at $600-900 USD) lets you run Qwen2.5-Coder-32B, which is where local coding becomes genuinely competitive with Copilot.
CPU-Only Inference
CPU inference via llama.cpp is viable for occasional use but significantly slower than GPU:
| Hardware | Model | Speed |
|---|---|---|
| Intel i5 (6 cores) | 7B Q8 | ~5 tok/s |
| Intel i7-14700K | ~7B Q4 | ~10 tok/s |
| AMD Threadripper (tuned build) | Mixed | 90+ tok/s |
Key insight: CPU inference is bottlenecked by memory bandwidth, not core count. Running in dual-channel RAM mode and disabling hyperthreading can improve speeds by 50-100%. High-core-count server CPUs (EPYC, Threadripper) with many memory channels dramatically outperform consumer CPUs.
For CPU-only setups, stick to 7B models at Q4_K_M (fits in ~5GB of RAM beyond OS usage). 13B models at Q4 (~8GB) are usable but slow.
Apple Silicon and the MLX Framework
Apple Silicon’s unified memory architecture gives Macs a unique advantage: the GPU and CPU share the same memory pool, so a Mac with 64GB of unified RAM can hold a 70B Q4 model entirely in “VRAM” — something impossible on a single consumer NVIDIA GPU.
MLX is Apple’s open-source ML framework optimized for Apple Silicon. Both Ollama and LM Studio ship MLX backends.
Performance benchmarks:
| Chip | Unified RAM | Best Model | Speed |
|---|---|---|---|
| M3 Pro / M4 Pro | 18–24 GB | Up to 13B Q4 | 25–40 tok/s |
| M3 Max / M4 Max | 36–128 GB | Up to 70B | 30–50 tok/s (7B), 8-15 tok/s (70B) |
| M2 Ultra / M3 Ultra | 96–192 GB | 70B comfortably | 15–25 tok/s (70B) |
MLX advantages over llama.cpp on Apple Silicon:
- Models load 3x faster
- 26-30% higher token generation throughput
- Lower memory usage due to unified memory optimization
- Near-silent operation at ~50W vs ~300W+ for an RTX 4090
The M4 Pro with 24GB is the recommended minimum for serious local coding work on Apple Silicon. The M4 Max at 64GB is the sweet spot for running Qwen2.5-Coder-32B at full quality.
To use MLX with Ollama on Apple Silicon, Ollama auto-detects and uses Metal/MLX. No configuration needed.
|
|
Part 6: Continue.dev with Local Models
Continue is a VS Code and JetBrains extension that provides chat, inline editing, and tab autocomplete using any LLM backend. It’s the most mature open-source Copilot alternative.
Install from the VS Code marketplace (search “Continue”) or continue.dev.
Configuration File
Continue is configured via ~/.continue/config.yaml (or the hub-based config in newer versions). The roles array controls what each model is used for.
Full Configuration Example
|
|
Alternative: Autodetect All Installed Ollama Models
|
|
This scans your local Ollama installation and populates the model list dynamically from ollama list.
Separate Chat vs Autocomplete Models
The important design decision in Continue is to use different models for chat and autocomplete:
- Chat models (7B–32B): Handle questions, debugging sessions, and code edits. Larger is better here.
- Autocomplete models (1.5B–3B): Must respond within 300-500ms to feel instant. Qwen2.5-Coder-1.5B and StarCoder2-3B are ideal.
|
|
Using a Remote Ollama Server
If you run Ollama on a more powerful server and connect from a laptop:
|
|
Disabling Thinking Mode for Autocomplete (Qwen3)
If using a reasoning model like Qwen3 for autocomplete, disable thinking mode to keep latency low:
|
|
Part 7: Aider with Local Models
Aider is an AI pair programming tool that works directly in your terminal. It reads your codebase, understands context, and makes targeted edits across multiple files. It integrates with git and creates commits automatically.
Installation
|
|
Using Aider with Ollama
|
|
Important: Ollama silently truncates context that exceeds its window. Aider automatically sets the context window large enough for each request plus 8K tokens for the reply, but starting Ollama with OLLAMA_CONTEXT_LENGTH=8192 (or higher) ensures this works correctly.
Custom Context Window Configuration
For models that need specific context settings, create an Aider model metadata file (.aider.model.metadata.json):
|
|
Or via .aider.conf.yml:
|
|
Using Aider with Any OpenAI-Compatible Endpoint (LM Studio, llama.cpp Server)
|
|
Which Models Work Best with Aider
Aider maintains a public LLM leaderboard at aider.chat/docs/leaderboards that measures actual code editing performance. Check this resource for up-to-date rankings.
Based on community experience and the leaderboard as of early 2026:
| Model | Notes |
|---|---|
qwen2.5-coder:32b |
Best local option; strong instruction following for multi-file edits |
qwen2.5-coder:14b |
Good balance for 16GB VRAM setups |
qwen2.5-coder:7b |
Acceptable for simpler tasks, limited context |
deepseek-coder-v2:16b |
Strong reasoning, good at complex refactors |
llama3.3:70b |
Strong general model; good for architecture discussions |
codellama:34b |
Acceptable but outperformed by Qwen2.5 family |
Aider works best with models that have strong instruction-following — the model must respond in a specific diff format. Smaller models under 7B frequently fail to adhere to the required output format, making them unreliable for Aider.
Aider Workflow Example
|
|
Aider reads the specified files, sends them as context, and writes the changes directly — then stages them for git commit. Use aider --no-auto-commits to review changes before committing.
Quick Reference: Picking the Right Stack
By VRAM / Budget
| Situation | Chat Model | Autocomplete | Tooling |
|---|---|---|---|
| 6-8 GB VRAM (RTX 3060 12GB tight) | qwen2.5-coder:7b | qwen2.5-coder:1.5b | Ollama + Continue.dev |
| 16 GB VRAM (RTX 4060 Ti) | qwen2.5-coder:14b | starcoder2:3b | Ollama + Continue.dev |
| 24 GB VRAM (RTX 3090/4090) | qwen2.5-coder:32b | qwen2.5-coder:1.5b | Ollama + Continue.dev + Aider |
| CPU only (16+ GB RAM) | qwen2.5-coder:7b Q4_K_M | starcoder2:3b Q4_K_M | llama.cpp server + Continue.dev |
| Apple Silicon M4 Pro (24GB) | qwen2.5-coder:14b | qwen2.5-coder:1.5b | Ollama (MLX) + Continue.dev |
| Apple Silicon M4 Max (64GB+) | qwen2.5-coder:32b | qwen2.5-coder:1.5b | Ollama (MLX) + Continue.dev + Aider |
Recommended Starting Point (Most Users)
|
|
From there, upgrade the chat model as your hardware allows, and consider LM Studio if you want a GUI for model management, or llama.cpp directly for maximum performance tuning.
Sources
- 5 Open-Source Coding LLMs You Can Run Locally in 2026 — Labellerr
- Best Models for Coding Locally in 2026 — InsiderLLM
- Comparing Top 7 LLMs/Systems for Coding in 2025 — MarkTechPost
- Codestral 22B, Qwen 2.5 Coder, and DeepSeek V2 Coder: Which AI Coder? — Deepgram
- Best LLM for Coding — Vellum
- Using Ollama with Continue: A Developer’s Guide — Continue Docs
- VS Code — Ollama Docs
- An Entirely Open-Source AI Code Assistant — Ollama Blog
- LM Studio Developer Docs
- OpenAI Compatibility Endpoints — LM Studio Docs
- Use OpenAI’s Responses API with Local Models — LM Studio Blog
- Local LLM Hosting Complete 2025 Guide — Medium
- Quantize Llama Models with GGUF and llama.cpp — Towards Data Science
- AI Model Quantization 2025 Guide — Local AI Zone
- llama.cpp GitHub Repository
- How Much GPU VRAM Do You Need for 7B, 33B, or 70B Models? — DatabaseMart
- Full Local LLM Setup Guide: CPU vs GPU vs Apple Silicon — ML Journey
- VRAM for 70B Models — SitePoint
- Apple Silicon vs NVIDIA CUDA: AI Comparison 2025 — Scalastic
- DeepSeek-Coder-V2 GitHub
- DeepSeek-Coder-V2 arXiv Paper
- StarCoder2 and The Stack v2 — arXiv
- WizardCoder — arXiv ICLR 2024
- Connecting to LLMs — Aider Docs
- Ollama — Aider Docs
- OpenAI Compatible APIs — Aider Docs
- Aider LLM Leaderboards
- config.yaml Reference — Continue Docs
- Continue Autocomplete Setup — Continue Docs
- Ollama REST API — GitHub
- OpenAI Compatibility — Ollama Blog
- CPU-Only LLM Inference Benchmarks — Challenging GPU Dominance, arXiv
- LLM Inference Speed Comparison — Ajit Singh
- I installed, quantized, and benchmarked top open-source Code LLMs — Medium
Comments