Estimate whether a Hugging Face model fits and fine-tunes on your local GPU.
Estimate whether a Hugging Face model fits and fine-tunes on your local GPU.
Estimate, benchmark, and generate fine-tuning recipes for LLMs on consumer GPUs.
You have one consumer-grade NVIDIA GPU. You want to fine-tune an open-weight LLM with LoRA or QLoRA, but you do not want to download 14 GB of weights just to discover that your 12 GB / 16 GB / 24 GB card OOMs on step 1.
canifinetune answers, before you spend the disk space and the time:
It is a single Python package with a CLI:
…What canifinetune estimate actually prints:
…On a real RTX 4080 this exact config peaks at 7.10 GB reserved — the
estimate lands ~1.3 GB above it, on the safe side, instead of promising
3 GB and OOM-ing. Two terms most static estimators miss do the work here:
the logits / cross-entropy chain (seq × vocab × ~14 B; 4.1 GB for
Qwen's 152k vocab at seq 2048, and gradient checkpointing does not remove
it) and the fp32 upcast of embeddings/norms that
prepare_model_for_kbit_training performs under QLoRA. Every coefficient
was fitted against measured torch.cuda peaks — see
docs/rtx4080_baselines.md — and canifinetune bench / calibrate can
still ground the estimate on your machine.
canifinetune runs in two layers:
| Layer | Install | What you get |
|---|---|---|
| Core (estimate / recommend / recipe / report) | pip install canifinetune |
All CLI commands. No PyTorch required. |
| Training (bench / real fine-tuning) | pip install canifinetune[train] |
Adds torch, transformers, peft, bitsandbytes, trl, datasets. |
| Reporting extras | pip install canifinetune[report] |
Pandas/tabulate for prettier tables. |
| Development | pip install canifinetune[dev] |
pytest, ruff, mypy. |
If you use uv:
uv venv
uv pip install -e ".[dev,report]"
# Add training deps when you want to run benchmarks:
uv pip install -e ".[dev,train,report]"PyTorch should generally be installed with the CUDA wheel that matches your driver, e.g.
uv pip install torch --index-url https://download.pytorch.org/whl/cu124See docs/troubleshooting.md for Windows / WSL / bitsandbytes specifics.
…accelerate estimate-memory?accelerate estimate-memory tells you how much memory loading a model takes.
That is not enough to know whether you can train it.
This project tries to answer the harder question. It models:
prepare_model_for_kbit_training (4 GB on an untied 7B!)seq × batch × vocab × ~14 B) — the
single biggest training buffer for modern 128k–152k-vocab models, and
one that gradient checkpointing does not touchtarget_modulesseq_len, batch_size, hidden_size,
intermediate_size, num_layers, with and without gradient checkpointing,
with coefficients fitted to measured peaks on real hardwarenum_local_experts vs num_experts_per_tok)Estimates are always marked with an assumptions block and a confidence
level, because activation memory in particular is hard to predict statically.
Run canifinetune bench and canifinetune calibrate to ground them in real
measurements on your machine.
docs/rtx4080_baselines.md contains real measurements collected on a single
RTX 4080 (16 GB). These are not synthetic. If a configuration was not run, the
table says "not run", not a guessed number. The same runs are pinned as
regression fixtures in tests/test_estimator_accuracy.py, so the estimator
cannot silently drift away from measured reality.
Highlights (more in the doc):
| model | method | seq_len | estimated | measured peak | tok/sec |
|---|---|---|---|---|---|
Qwen/Qwen2.5-0.5B-Instruct |
qlora | 1024 | 5.01 GB | 3.30 GB | 3337 |
Qwen/Qwen2.5-1.5B-Instruct |
qlora | 1024 | 6.05 GB | 4.36 GB | 2483 |
Qwen/Qwen2.5-1.5B-Instruct |
qlora | 2048 | 8.42 GB | 7.10 GB | 2327 |
Qwen/Qwen2.5-1.5B-Instruct |
qlora | 4096 | 13.16 GB | 13.56 GB | 1662 |
Qwen/Qwen2.5-1.5B-Instruct |
qlora (no ckpt) | 1024 | 10.75 GB | 9.55 GB | 3003 |
Qwen/Qwen2.5-3B-Instruct |
qlora | 1024 | 7.26 GB | 5.54 GB | 1303 |
Qwen/Qwen2.5-7B-Instruct |
qlora | 1024 | 12.43 GB | 11.23 GB | 923 |
src/canifinetune/ # package code (estimator, bench, recipes, reports, cli)
benchmarks/ # configs/, results/ (JSON), calibration/
docs/ # design, memory model, troubleshooting
examples/ # end-to-end recipe folders
tests/ # pytest tests (CPU-only, no large downloads)
scripts/ # helper scripts for collecting baselines
.github/workflows/ # CI (ruff + pytest on CPU)The current scope is "single consumer GPU, single node, LoRA / QLoRA, causal LM, Hugging Face stack". Possible directions, none committed:
gradient_accumulation_steps for a target effective batch sizeGenerated recipes can opt into current TRL Liger kernels with --liger; the
static estimate remains conservative and continues to model the stock
logits/loss path.
Contributions welcome.
See CHANGELOG.md for release notes.
MIT. See LICENSE.
No open issues yet, or sync has not completed.