Metadata-Version: 2.1
Name: justfit-llm
Version: 2.7.0
Summary: JustFit: long-context 27B language-and-vision serving on 16 GB and 24 GB Apple silicon Macs (native, no Python at runtime)
Home-page: https://github.com/YuhuaBillChen/justfit-llm
License: Apache-2.0
Platform: macOS
Classifier: Operating System :: MacOS
Classifier: License :: OSI Approved :: Apache Software License
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# JustFit 2.7.0 native distribution

JustFit serves a 27B language-and-vision model (Qwen3.8-27B) on Apple silicon
Macs with 24 GB of unified memory, and Bonsai 2 27B on 16 GB Macs. The `justfit` command and everything it
starts are native (Rust, C++/Metal, Swift); no Python runs at inference time.

## Install

```bash
python3 -m venv ~/.justfit && ~/.justfit/bin/pip install justfit-llm==2.7.0
~/.justfit/bin/justfit doctor
~/.justfit/bin/justfit serve
```

pip only places the files: `justfit` is a native executable. The first
`justfit serve` installs the bundled runtime, downloads the original
`mlx-community/Qwen3.8-27B-4bit` checkpoint and its DFlash2 draft from Hugging
Face, and downloads the ANE vision programs for this chip (about 2.8 GB) from a
pinned, hash-checked index. Later starts reuse them.

Requirements: macOS 27.0 or later on Apple silicon; presets for M4 Pro, M5 Pro
and M6 (`--node m4|m5|m6`, chosen from the chip; at least 24 GB of memory).
On a 16 GB M6, `--node m6-16` (chosen automatically) serves Bonsai 2 27B
(`prism-ml/Ternary-Bonsai-2-27B-gguf`) in a 12.1 GiB budget with up to
221,169 tokens of context; the other chips have no 16 GB preset.
About 22 GB of disk for the model, draft and ANE programs, plus the SSD cache
(64 GB quota by default; `--max-cache-disk` changes it, 0 turns it off).
`--no-ane-vision` uses GPU vision and skips the ANE download; `--language-only`
serves text only. Precompiled ANE programs are published for macOS 27.2.1
(build 26B131); on other macOS builds images run on the GPU, and
`--ane-compile` compiles the ANE programs on this Mac instead (30 minutes to
over an hour of background work in our tests, once; vision stays on the GPU
meanwhile). `--disable-ane` is separate: it keeps the text prefill FFN on the
GPU.

## Use it with your tools

`justfit serve` speaks the OpenAI (Chat Completions, Responses), Anthropic
(Messages) and Ollama APIs on one port, so most clients only need its address:

```bash
justfit launch claude          # Claude Code on the local model
justfit launch codex           # Codex CLI on the local model
OLLAMA_HOST=http://127.0.0.1:8000 ollama run mlx-community/Qwen3.8-27B-4bit
```

Other clients (Open WebUI, Continue, Cline, Jan, …) use
`http://127.0.0.1:8000/v1` as an OpenAI-compatible endpoint, or the same
address as an Ollama server. Append `:instant` to the model name to answer
without thinking. See [docs/clients.md](docs/clients.md) for
per-client settings and what a local server does with hosted tools such as
web search.

## New in 2.7.0

- 16 GB Macs: `--node m6-16` serves Bonsai 2 27B in a 12.1 GiB budget with up
  to 221,169 tokens of context and vision.
- GDN state compression based on LeapQuant: about 490–500 MiB less peak memory
  with two requests on M5 Pro and M6.
- TQ4 KV cache keeps the first and the most recent pages in BF16 and stores
  norm-corrected 4-bit codes for the rest.
- Draft trees also serve requests with repetition, presence or frequency
  penalties and JSON-schema output.
- M4 Pro runs part of the text prefill on the Neural Engine again: time to
  first token on a 16K prompt is 29% shorter than in 2.6.0.

Numbers and limits are in the [2.7.0 release notes](https://github.com/YuhuaBillChen/justfit-llm/blob/main/.github/release-notes-2.7.0.md)
and the [changelog](https://github.com/YuhuaBillChen/justfit-llm/blob/main/CHANGELOG.md).

## What changed since 2.3.1

- All native: the `justfit` command is a native executable and nothing at
  inference time runs Python. pip only places the files; no runtime manifest
  or ANE manifest flags are needed, and `justfit serve` sets up everything on
  first start.
- Original checkpoint: serves `mlx-community/Qwen3.8-27B-4bit` with the
  DFlash2 draft, both downloaded from Hugging Face on first start, instead of
  the `incoai/Qwen3.8-27B-Splash` model pack.
- Draft-tree decode: the draft proposes a small tree of continuations and the
  model checks the whole tree in one pass. It applies to greedy requests on
  all presets and to sampled requests on M5 Pro and M6, including requests
  with repetition, presence or frequency penalties and JSON-schema output
  (since 2.7). On SPEED-Bench with greedy
  decoding (512 output tokens) decode is 4-14% faster than verifying a single
  draft chain with 1K-token prompts, and 4-7% faster with 16K-token prompts,
  depending on the chip.
- Memory safety: a request in service never takes the host's memory reserve,
  so the system keeps room under full load.
- Fewer SSD writes: progress checkpoints taken while decoding stay in memory;
  the long-prompt recovery point is written only when memory runs short, at
  most once per 16K prompt tokens.
- Multi-turn reuse: a finished request keeps its exact state for the next turn
  that extends it, so agent and chat turns prefill only the new tail.
- `return_token_ids` (vLLM/SGLang-compatible token-in/token-out), crash-request
  quarantine (`400 request_quarantined`), and a sandbox applied by `justfit`
  itself to the engine and native workers (no outbound network).
- ANE vision programs for the chip are found and downloaded automatically on
  first use.

The binaries are signed with a Developer ID; they are not notarized.

With greedy decoding in 2.6.0, tree verification almost always gave the same
text as verifying a single draft chain. Since 2.7.0, with GDN compression on,
the two no longer give byte-identical text; answers on our math set match or
improve. Sampled requests keep the same distribution. A multi-turn request that resumes a kept
state can likewise differ slightly from a full recompute.

## Two 160K requests on a MacBook

Two 160K requests at once need almost all the memory a 24 GB Mac can wire
(keep non-swappable). macOS stops the process that holds the most wired memory
when the system-wide total reaches a kernel limit, so what else is wired
decides whether both requests fit.

On Macs without a display attached (our M5 Pro and M6 test machines) this
workload completed in every run of this release. On a 24 GB M4 Pro MacBook
with macOS 27.2.1 it stays close to the edge: it completed in our 2.7.0 run,
while with 2.6.0, of five runs, one completed, in two JustFit paused one
request near the end to stay within memory, and in two, both with the display
on, macOS stopped the server. With the display on,
macOS 27 wires GPU memory again each time the screen redraws; we measured
about 0.45 GB for a few seconds every minute from the lock screen clock, and
about 0.7 GB held by a moving (Aerial) wallpaper.

For this workload on a MacBook, let the display sleep, use a still wallpaper
and leave GPU-heavy apps closed; that removes the redraw spikes, though a
request may still be paused near the end. A single request up to 256K is not
affected, and shorter pairs leave more room.

## More

`bin/justfit --help`, `justfit serve --help`. Source, license and attribution:
LICENSE, NOTICE, ORIGIN.json; `package-manifest.json` pins every file.
