Skip to main content

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

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. Use --ctx 32768 for a longer context, --dry-run to only print the command, and put extra llama-server flags after --.
dofit plan MODEL Prints the plan (memory, speed, maximum context) and the llama-server command.
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.
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

  1. 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.
  2. 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 -ngl and --n-cpu-moe split the model, following llama.cpp's own placement rules.
  3. 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.
  4. 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 probe on 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 --vram to plan and recommend.

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.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dofit 0.1.0
File Size Uploaded Provenance Actions
dofit-0.1.0.tar.gz 71.3 kB Without provenance Details for dofit-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dofit 0.1.0
File Interpreter ABI Platform Actions
dofit-0.1.0-py3-none-any.whl Python 3 none any Details for dofit-0.1.0-py3-none-any.whl

Total release size: 137.5 kB

Release files / dofit-0.1.0.tar.gz

Download URL dofit-0.1.0.tar.gz
Size 71.3 kB
Tags Source
SHA-256 checksum
How to use checksums
10ffe630e3bf4e37baedbeabe291aa47cd32e6776cb38aae47c2725ea3d9f495
BLAKE2b-256 checksum
How to use checksums
de85ed37c926131172da688768611b4f21c68592d0fb5b537d1c8701da3b79ba
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.0-py3-none-any.whl

Download URL dofit-0.1.0-py3-none-any.whl
Size 66.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b40268e882729916ba5a95fb9c9cd9bc6519eb7aa1c73bb5bd02b9abc3bd57cb
BLAKE2b-256 checksum
How to use checksums
abb90fa80b26f561ab2901890a1dc839d5af5c1677a3298edb951731ca147386
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.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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