Dofit
Run big AI language models on the computer you already have.
You can run a 30-billion-parameter model on a laptop with a 6 GB graphics card and 15 GB of RAM, at a usable 16-19 tokens (word pieces) per second. You just have to place it right: the right layers on the GPU, the rest in RAM, the right cache settings and the right compression level. Getting that right by hand means trial, error and out-of-memory crashes.
Dofit does it for you. It reads a model file's header (never the whole model), looks at your hardware, and works out how to run the model with llama.cpp:
- how much fits where: GPU, RAM, or streamed from disk, to within about 1% of what llama.cpp actually allocates;
- how fast it will be, at the start of a chat and deep into one;
- which models and compression levels from Hugging Face your machine can run at all;
- and it starts the model for you, backing off automatically if the GPU runs out of memory.
It is a single Python package with no dependencies. It is developed and measured on Linux; macOS and Windows are supported (RAM, CPU cores incl. Intel P/E cores, NVIDIA GPUs, disk speed) but not yet tested on real machines: reports welcome.
Install
Dofit was called modelfit until December 2026. The first run moves your saved settings
(~/.config/modelfit, ~/.cache/modelfit) to the dofit folders; MODELFIT_LLAMA_SERVER still works.
pipx install dofit # Python 3.9+, no other dependencies (or: pip install dofit)
# from a copy of this repository instead:
pipx install .
With Jan, Ollama or LM Studio you need nothing else: dofit jan, dofit ollama and
dofit lmstudio tune the app you already have. To run models with dofit run you also
need llama-server from llama.cpp. Install
it from the llama.cpp releases,
your package manager (brew install llama.cpp on macOS, winget install llama.cpp
on Windows), or build it yourself. Dofit finds it on your PATH, in ~/llama.cpp
(a release zip unpacked there), or you can set
DOFIT_LLAMA_SERVER=/path/to/llama-server. Planning and recommending work without it.
On Windows, use PowerShell. bench --cold cannot drop a model from the file cache on
macOS or Windows (it says so and measures a warm start).
Quick start
dofit recommend # which popular models fit this machine, and how fast
dofit recommend --search coder # search Hugging Face
dofit run hf:Qwen/Qwen3-8B-GGUF:Q4_K_M # download (once), plan, start
# -> open http://localhost:8080 to chat, or use the OpenAI-compatible API at /v1
Example recommend output (shortened) on a laptop with a 6 GB RTX 4050 and 15 GB RAM,
6.6 GB of it free:
# model (repo:quant) params size tok/s setup
1 ornith-ai/Ornith-1.5-35B-A3B-GGUF:Q4_K_M 35B/4A 21.7G 16 GPU+RAM experts
4 prism-ml/Ternary-Bonsai-2-27B-gguf:Q2_0 27B 7.6G 14 GPU+CPU (heavily compressed)
9 AtomicChat/LFM2.5-24B-A2B-Uncensored-GGUF:Q5_K_M 24B/3A 17.3G 22 GPU+RAM experts
11 ornith-ai/Ornith-1.5-9B-GGUF:Q6_K 9.0B 7.6G 18 GPU+CPU
13 XHToken/Spark-X2.6-4B-GGUF:Q4_K_M 4.4B 3.5G 53 GPU
Too big for this machine (5): ornith-ai/Ornith-1.5-397B-GGUF (smallest 244 GB), ...
35B/4A means a mixture-of-experts model: 35 billion parameters in total, but
only about 4 billion are used for each token. These models are the best fit for
small machines: dofit keeps the always-used parts on the GPU and the rarely-used
"experts" in RAM.
Commands
Sizes are in decimal GB (10^9 bytes), as on Hugging Face, Ollama and LM Studio; an "8 GB" GPU shows as 8.59 GB. Dofit warns when the laptop runs on battery or in a power-saving mode, or when the GPU is held below its usual power: models then run much slower than planned.
| command | what it does |
|---|---|
dofit recommend |
Ranks Hugging Face GGUF models for your machine. It reads only headers (a few MB per model, cached) and picks the best-quality compression up to Q6_K that fits and reaches --min-speed (default 10 tok/s). Use --repo user/name-GGUF to check specific repos. |
dofit run MODEL |
Plans and starts llama-server (llama.cpp by default; --engine ik uses ik_llama.cpp if installed). Models with MTP heads get speculative decoding automatically (--mtp off to disable). MODEL can be a .gguf file, an Ollama model name (e.g. qwen3:8b), or hf:user/repo:QUANT (downloaded once into ~/.cache/dofit/models with progress; Ctrl+C and the same command again resumes; a copy already in the Hugging Face cache is reused). Use --ctx 32768 for a longer context, --dry-run to only print the command, and put extra llama-server flags after --. Only this computer can use the server, and web pages open in your browser cannot (--cors-origins localhost); --host 0.0.0.0 opens it to your network, then also add -- --api-key SECRET. |
dofit plan MODEL |
Prints the plan (memory, speed, maximum context) and the llama-server command. MODEL can be a GGUF file, an Ollama name, or a Hugging Face model as hf:<repo>:<quant> (e.g. hf:Qwen/Qwen3-4B-GGUF:Q4_K_M): only its header is read, nothing is downloaded. |
dofit ollama [MODEL] |
Plans each installed Ollama model. dofit ollama --apply MODEL gives Ollama a tuned copy (MODEL-dofit, sharing the same file, no extra disk space): a larger context (Ollama's default 4096 tokens refuses a few-page document) and bigger prompt batches for MoE models that do not fit on the GPU. Measured with Qwen3.6-35B-A3B on an 8 GB GPU: long prompts read 2.3x faster, context 32k instead of 4k. --undo MODEL deletes the copy. |
dofit probe |
Measures this machine's real speeds once (~70 s, needs a small local model) and saves them; estimates for this machine then use your numbers instead of defaults. Run it plugged in and in the normal or performance power mode: results from battery, a power-saving mode or that vary between repeats are not saved (--save-anyway keeps them). Without llama-server it measures only the disk. |
dofit hw |
Shows the detected RAM, GPU and CPU. |
dofit jan [--apply MODEL | --all] [--add FILE.gguf] [--undo MODEL] |
Uses dofit's plan in the Jan chat app. Jan's defaults put every layer on the GPU, so a model bigger than the GPU fails to load; this writes GPU layers, MoE experts in RAM, batch size, KV type and MTP into Jan's per-model settings (a backup is kept). --add gives Jan a GGUF already on disk without copying it. Restart Jan afterwards, and run it again if you change a model's context size in Jan. Measured: Qwen3.6-35B-A3B on an 8 GB GPU, Jan's defaults fail, with this it answers at ~25-32 tok/s. |
dofit lmstudio [--apply MODEL | --all] [--undo MODEL] |
Uses dofit's plan in LM Studio. LM Studio lets llama.cpp place a big model itself, with 4 parallel slots, 512-token prompt batches and flash attention off; this writes GPU layers, MoE experts in RAM, batch size, KV type, context and MTP into LM Studio's per-model load settings (a backup is kept), used by the app's Load button and by lms load. Eject and load the model again afterwards. Measured: Qwen3.6-35B-A3B on an 8 GB GPU, 16-22 → 30-32 tok/s, long prompts read 2.7x faster. |
dofit bench MODEL |
Runs a plan for real and compares predicted with measured memory and speed (for developers). |
Planning for someone else's computer: plan and recommend accept
--ram GB --vram GB. For example, dofit recommend --ram 8 answers "what can
an 8 GB laptop without a GPU run?".
Translating PDFs
PDF translation that keeps the layout moved to its own project,
pdftranslate. It uses the server that
dofit run starts: pdftranslate FILE.pdf --to French.
How it works
- Read the header. A GGUF file starts with its metadata and a table of every tensor. Dofit reads only that part, from disk or with HTTP range requests from Hugging Face, so it gets exact per-layer sizes without downloading the model.
- Model llama.cpp's memory use. Weights per layer, the KV cache (including
sliding-window layers, which cache only a window, and hybrid recurrent layers,
which keep a small fixed state), compute buffers, and how
-ngland--n-cpu-moesplit the model, following llama.cpp's own placement rules. - Estimate speed. Generating one token reads the active weights once, so speed comes mostly from memory bandwidth: GPU memory, system RAM and disk, plus fixed per-token and per-layer costs and the cost of reading a growing KV cache. For mixture-of-experts models with experts in RAM, it estimates the share of experts actually touched and slows the estimate down when that share no longer fits in free RAM.
- Search. It tries every GPU/RAM split and KV-cache type, keeps the ones that fit, and picks the fastest. It slightly prefers better cache quality (q8_0 must win clearly over f16, and q4_0 by more than 15%).
How accurate is it?
Measured against llama.cpp on one laptop (RTX 4050 6 GB, Core Ultra 7 155H,
15 GB RAM). The raw data is in results/ and the test suite checks it on every run.
| accuracy | |
|---|---|
| Memory (11 configurations: 4B-30B, dense, sliding-window, MoE, contexts up to 128k) | within 1% for weights and KV cache; compute buffers within ~30 MiB |
Speed, model fully on the GPU (with dofit probe) |
within ±6% |
| Speed, mixture-of-experts with experts in RAM | within ~5% |
| Speed, model split between GPU and CPU | 11-35% optimistic |
Known limits:
- Speeds have been measured on one machine so far. The memory model doesn't
depend on the hardware, but speed does: run
dofit probeon yours. Measurements from other machines are the most useful contribution right now (see below). - Estimates for CPU-heavy plans are optimistic, partly because this laptop's CPU speed varies by about ±20% from run to run.
- Speed for newer hybrid architectures (recurrent and attention layers mixed) is estimated, not yet measured.
- Very small models (under 1B) run faster than predicted.
- NVIDIA GPUs are detected automatically (through
nvidia-smi). For other GPUs, pass--vramtoplanandrecommend.
Contributing measurements
The best way to make dofit accurate for everyone is to measure more machines:
dofit probe # ~70 s, saves your machine's speeds
dofit bench qwen3:8b --out my-machine.jsonl
bench starts llama-server with dofit's plan, reads llama.cpp's actual buffer
sizes and the generation speed, prints predicted vs measured, and appends a JSON
record. Sharing that file, together with your CPU, GPU and RAM, helps tune the model.
Development
python3 -m unittest discover -s tests -t . # 32 tests, ~3 s, no network or GPU needed
The tests replay the real measurements (tests/data/measured.json) through the
planner using stored model profiles, so they run anywhere without model files.
tests/make_fixtures.py regenerates that data from results/*.jsonl and local
models.
License
MIT
Metadata
Release files for dofit 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dofit-0.1.1.tar.gz | 81.7 kB | Without provenance | Details for dofit-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dofit-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for dofit-0.1.1-py3-none-any.whl |
Total release size: 154.4 kB
Release files / dofit-0.1.1.tar.gz
| Download URL | dofit-0.1.1.tar.gz |
|---|---|
| Size | 81.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a8aa89f2cf69da4fe7837e3590a529c016a68665942bd519fd20d46dc345014f
|
|
BLAKE2b-256 checksum How to use checksums |
ac08b16ce6f31ec3857e5d49ce79e97ac52f3539cd4fc635cee1271c8d0b4e36
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Release files / dofit-0.1.1-py3-none-any.whl
| Download URL | dofit-0.1.1-py3-none-any.whl |
|---|---|
| Size | 72.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
811ece1f3a09c9917d3eeaf51d408da649f6c0921c8aacb27bf68faaee1c5825
|
|
BLAKE2b-256 checksum How to use checksums |
b070a208f1a9d1b398b7b9abd2284c464ba5d4104e9198f61a42985a8a43efcc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Security for dofit 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.