canfit Benchmark: Simulating Real GGUF and AWQ VRAM Fit Before Downloading Gigabytes of Weights

Evaluating how Rust CLI tool canfit predicts large language model memory requirements without downloading model weights. Deconstructing static weights, KV Cache scaling, and desktop OS overhead across 8GB, 12GB, and 16GB consumer graphics cards.

Leaving a massive weight download running overnight, only to wake up to a CUDA out-of-memory error the following morning. Anyone who tinkers with local LLM deployments has run headfirst into this frustration.

Earlier this week in the lab, an engineering intern attempted to run a coding model on an RTX 4070 12GB rig. He spent over three hours downloading a 20GB quantized 32B model. The second he hit Enter on his first prompt, the terminal crashed. VRAM saturated completely, the driver dumped computation into system RAM, and generation velocity collapsed to 1.2 tokens per second. Spending hours downloading a payload that fails on the very first prompt is untenable.

A persistent trap in local deployment is judging hardware fit exclusively by static weight file size. The naive assumption is that if a 12GB card can accommodate a 10GB binary, the remaining 2GB will easily handle daily chat. That math is fatally flawed. Today we examine canfit [v0.2.1, GitHub: federicolaterra/canfit], a lightweight open-source Rust CLI that eliminates this trial-and-error cycle entirely.


1. Why Static File Sizes Lead to Immediate OOM

Where does physical memory actually go during inference? We must break down the true VRAM balance sheet.

In a running inference pipeline, memory allocation is never a single unified block, but rather four rigid competing requirements:

+-------------------------------------------------------------+
|                 GPU Physical VRAM Structure [e.g. 12GB]     |
+-------------------------------------------------------------+
|  1. Operating System and Desktop Window Compositor [600M-1G]|
+-------------------------------------------------------------+
|  2. CUDA Context and Runtime Foundation [300MB - 600MB]     |
+-------------------------------------------------------------+
|  3. Model Static Read-Only Weights [GGUF / AWQ / EXL2 Data] |
+-------------------------------------------------------------+
|  4. Dynamic KV Cache Pool [Scales Linearly with Context]    |
+-------------------------------------------------------------+
|  5. Forward Pass Scratch Buffer [Activation Lifetime Reuse] |
+-------------------------------------------------------------+

Developers routinely overlook items one and four. Under Windows, the Desktop Window Manager DWM and hardware-accelerated background browser tabs silently claim nearly 1GB of dedicated VRAM. Under Linux desktop sessions, X11 or Wayland compositors reserve hundreds of megabytes.

Dynamic KV cache expansion is even more unforgiving. Consider a standard 32B architecture: 64 attention layers, 8 Grouped-Query Attention pairs, and head dimension 128. Running standard fp16 precision demands 256MB of physical VRAM per 1024 context tokens.

You might assume 2GB of headroom is plenty. Expanding context out to 8k tokens consumes that entire 2GB buffer for KV cache alone. Layer in CUDA driver overhead, and memory breaches physical capacity instantly. The process has no choice but to abort.


2. How canfit Operates: Ahead-of-Time Metadata Evaluation

The conventional approach requires downloading multi-gigabyte binaries before discovering allocation outcomes in runtime logs. When memory overflows, hours of network bandwidth are wasted.

canfit bypasses this via an intuitive approach: it queries the Hugging Face API to read exclusively config.json and model metadata, bypassing weight downloads entirely.

It parses core architectural metrics:

[canfit Execution Pipeline]
Specify Model Identifier and Quantization Tier
   ↓
Fetch Remote config.json [Consumes Only a Few Kilobytes]
   ↓
Parse Layers, Key-Value Heads, Hidden Dims, and GQA Ratio
   ↓
Apply Target Context Bounds [e.g. 4096 / 8192 / 16384]
   ↓
Map Against Local GPU Bounds and Generate Telemetry Report

Testing canfit v0.2.1 under Ubuntu 24.04 on an RTX 4070 12GB [Driver 560.35.03, CUDA 12.8], the network exchange took only a few kilobytes. Benchmarking with time logged real 0.31s, user 0.04s, sys 0.02s. The terminal provided the exact answer: full GPU offloading feasibility, maximum context headroom, and offloading layer boundaries.


3. Practical Walkthrough: Evaluating GGUF and AWQ Profiles

Compiled in Rust, canfit ships as a standalone binary without external runtime dependencies.

Installation and System Diagnostics

On workstations with the Rust toolchain installed:

cargo install canfit

Alternatively, download prebuilt binaries from the project release page.

Begin by probing local GPU hardware capacity:

canfit list-gpus

The terminal outputs total VRAM alongside current baseline allocations. Running this check first is essential to reveal baseline desktop compositor overhead.

GGUF Evaluation: Hitting the 32B Ceiling

We simulated deploying Qwen2.5-Coder-32B-Instruct in GGUF format on a 12GB card:

# Simulating a 12GB GPU running Q4_K_M with 8k context
canfit eval \
    --model Qwen/Qwen2.5-Coder-32B-Instruct \
    --quant q4_k_m \
    --context 8192 \
    --vram 12

The tool returned an evaluation report in 0.3 seconds:

+-----------------------+--------------------+
| Parameter             | Value              |
+-----------------------+--------------------+
| Model Weights         | 19.85 GiB          |
| KV Cache [8k ctx]     | 2.00 GiB           |
| CUDA Overhead         | 0.55 GiB           |
| Total Required        | 22.40 GiB          |
| Available VRAM        | 12.00 GiB          |
| Fit Status            | FAILED [OOM]       |
| Max Layers on GPU     | 34 / 64            |
| Projected Decode      | 3.8 tokens/s       |
+-----------------------+--------------------+

The outcome is definitive. A 12GB card cannot host 32B Q4 weights, offloading only 34 layers to the GPU while 30 layers spill into system RAM. Projected decoding collapses to 3.8 tokens per second. Who can tolerate interactive code completion at 3 tokens per second? Seeing this report saves hours of fruitless downloading.

AWQ Evaluation: Fitting 14B Models with Full Context

If 32B exceeds bounds, can a 14B AWQ model fit comfortably on a 12GB card with a 16k context window? We evaluated the AWQ target:

# Evaluating 14B AWQ with 16k context on a 12GB card
canfit eval \
    --model Qwen/Qwen2.5-14B-Instruct-AWQ \
    --quant awq \
    --context 16384 \
    --vram 12

Terminal output:

+-----------------------+--------------------+
| Parameter             | Value              |
+-----------------------+--------------------+
| Model Weights         | 8.25 GiB           |
| KV Cache [16k ctx]    | 2.00 GiB           |
| CUDA Overhead         | 0.55 GiB           |
| Total Required        | 10.80 GiB          |
| Available VRAM        | 12.00 GiB          |
| Fit Status            | PASSED [100% GPU]  |
| Max Layers on GPU     | 48 / 48            |
| Projected Decode      | 32.5 tokens/s      |
+-----------------------+--------------------+

AWQ weights consume 8.25 GiB, 16k context KV cache requires 2.0 GiB, and driver overhead adds 0.55 GiB, totaling 10.80 GiB. This fits squarely within 12GB VRAM while sustaining an estimated 32.5 tokens per second decode velocity.


4. Hardware Tiers and Quantization Planning

To establish reliable baselines across hardware tiers, we compiled this deployment reference based on repeated simulations:

Hardware TierRecommended Model ScaleRecommended Quant ProfileSafe Context BoundaryEmpirical Notes [llama.cpp CUDA]
8GB VRAM [RTX 4060 / 3060Ti]7B / 8B ModelsQ4_K_M or Q5_K_M8,192 ContextSustains 45-55 t/s at batch=1 512 ctx; baseline workhorse
12GB VRAM [RTX 4070 / 3060]14B ModelsQ4_K_M or AWQ16,384 ContextSustains 28-36 t/s at batch=1; multi-slot needs 2GB headroom
16GB VRAM [RTX 4080 / 4070TiS]14B Uncut or 27B PrunedQ5_K_M or Q4_K_M32,768 ContextHandles long technical docs at 22-28 t/s without quality loss
24GB VRAM [RTX 4090 / 3090]32B ModelsQ4_K_M8,192 ContextReaches 40-42 t/s at 8k ctx; forcing 32k context triggers OOM

Note the 24GB tier: running 32B models on a single 24GB card requires capping context near 8k tokens. Pushing context out to 16k or 32k breaches the 24GB line. Simulating the math in advance clarifies these hard boundaries.


5. Deployment Boundaries and Production Constraints

While canfit eliminates the vast majority of local sizing pitfalls, production serving requires factoring in additional constraints:

  1. Multi-slot continuous batching demands headroom: canfit defaults to single-stream static estimation. Enabling concurrency in llama-server or vLLM multiplies KV cache allocation per slot. Maintain a 1.5GB to 2GB buffer above static estimates.
  2. KV Cache quantization provides an emergency valve: If evaluations overshoot by roughly 1GB, passing -ctk q8_0 -ctv q8_0 compresses the KV cache to 8-bit precision, halving cache overhead.
  3. Desktop overhead fluctuates: Running IDEs alongside heavy browser sessions consumes 1.5GB of VRAM. Pass --os-reserved 1024 during evaluation to subtract desktop noise beforehand.

This tool does not manufacture compute capacity; its utility is calculating exact memory boundaries before you waste hours downloading unviable weights. Before queueing another download, run canfit list-gpus and measure your actual available headroom first.

💬 Discussion

GitHub Powered