Skip to main content

Ruff docs vetted License

vramfit

Selective per-layer quantization to fit large open models on a single GPU.

What is this?

The problem. A model's weights are billions of numbers, normally stored at 16 bits each — Nemotron Super 49B is ~98 GB at full precision, and an RTX 4090 has 24 GiB. Quantization stores those numbers with fewer bits (8, 4, even 2), trading a little accuracy for a lot of memory. But even uniform 4-bit puts 49B parameters at ~26 GB — still doesn't fit — and uniform 3-bit wrecks quality, because some parts of a transformer get badly stupid when you crush them.

The insight. Not all layers are equally fragile. Some tolerate 2–3 bits with barely a ripple; others (attention projections, first/last blocks) fall apart below 6–8 bits. Most published quantized models pick precision by crude heuristic. vramfit measures which layers are which, then solves for the best mixed-precision recipe that fits a specific model into a specific VRAM budget:

  1. Scan — quantize one layer group at a time at candidate precisions and measure output divergence against the full-precision reference. Output: a sensitivity map of which layers can survive being crushed.
  2. Plan — a budget problem: given the map and a hard VRAM constraint (minus KV-cache headroom), spend bits where the scan says they matter and crush where it says they don't. Bits are cost, quality is value.
  3. Validate — replay the whole recipe in one pass and measure real recipe damage against the solver's prediction (ADR-0006).
  4. Pack — apply the recipe and emit a checkpoint the target runtime can actually serve. GGUF covers the sub-4-bit benchmark path, per ADR-0010. A vLLM backend for ≥4-bit recipes is planned.

The goal: NVIDIA Nemotron Super 49B running on a 24 GiB RTX 4090 — a model that does not fit at full precision, made to fit selectively, with measured (not vibes-based) damage versus running a smaller model instead. The Status section records the result.

Philosophy borrowed from antirez/ds4: depth over breadth. One model profiled properly beats a generic recipe applied to a hundred.

Docs live in docs/ (Diátaxis layout, every page carries a maturity status). Design decisions are recorded as ADRs.

Status

The full pipeline is implemented: scan, plan, validate, pack, plus budget for the VRAM arithmetic. Pack quantizes with an importance matrix (ADR-0016), guards protected packs with a per-tensor reconstruction check (ADR-0022), and smoke-tests every artifact before trusting it (ADR-0017). Seventeen data points span 2026-07-28 to 2026-08-11. Every packed model fits the card first try.

The pipeline wins the head-to-head on the ruling window. On 2026-08-09 an end-to-end pack beat the size-matched community imatrix quant on full-window KL divergence: 0.2873 vs 0.2959, 7.8σ paired. The same artifact holds the best nominal perplexity in the lane (8.517 vs 8.532) at 112 MiB under budget. The baseline keeps a half-point lead on full-window top-token agreement. On 2026-08-10 tier 3 certified the pack: five task benchmarks, five statistical ties against the baseline, none past 0.8σ (ADR-0024). The publication gate ruled GO on this evidence.

The road there ran through measured eliminations. Importance-weighted rounding was worth 0.86 of the original 1.39-perplexity gap. 2-bit group membership decides whether damages add: super-additive by 11.9× on one 2-bit set, sub-additive by 1.6× on another. 2-bit stays out of the solve until runtime-frame prices exist — current practice plans on a map copy without the 2-bit column (ADR-0021). Within-layer protections plus imatrix exclusions (ADR-0022, ADR-0023) closed the fit-collapse gap.

The evidence page records all seventeen data points. Publication #1 is live on Hugging Face: the packed model and the sensitivity-map dataset. See Issues for the roadmap.

Requirements

  • Python 3.12+
  • CUDA GPU (developed against an RTX 4090 / 24 GiB)
  • uv

Installation

git clone https://github.com/Alberto-Codes/vramfit.git
cd vramfit
uv sync

Quick Start

# Show the CLI
uv run vramfit --help

# The pipeline (heavy steps need the extras: uv sync --extra scan --extra pack)
vramfit scan MODEL --calibration calib.txt --out sensitivity.json
vramfit plan sensitivity.json --vram 24GiB --out recipe.json
vramfit validate recipe.json --calibration calib.txt
vramfit pack recipe.json --llama-cpp ~/llama.cpp --out packed.gguf

Development

uv sync --dev
uv run ruff check .     # Lint
uv run ty check         # Types
uv run pytest           # Tests
uv run docvet check --all  # Docstring quality

See CONTRIBUTING.md for the full workflow.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vramfit-0.2.0.tar.gz (147.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vramfit-0.2.0-py3-none-any.whl (181.3 kB view details)

Uploaded Python 3

File details

Details for the file vramfit-0.2.0.tar.gz.

File metadata

  • Download URL: vramfit-0.2.0.tar.gz
  • Upload date:
  • Size: 147.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for vramfit-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d5f34ed30b9b7c0f4ac0059472380e539f7811b2d9a4713ebcfb8d550723115d
MD5 bcf2f62f62dcff8ed2d45053b2ac3180
BLAKE2b-256 89a0aa58e28812c2c2d1ca7608f3d7b837914fffe6bad85b39d159505e24e3d6

See more details on using hashes here.

File details

Details for the file vramfit-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: vramfit-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 181.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for vramfit-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d54248dd323ab5a8e7067c345cb1bb2cafc56beff7367e25c099223e1482b2d0
MD5 cab99548a88bdf454249b27826c4052f
BLAKE2b-256 d78d72e620565a8b2dccc1ba74f497337aab58713c8641b910ddc958ca3f6a78

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.0

2 files

This release

0.2.0 This release

2 files

0.1.0

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page