Metadata-Version: 2.1
Name: justfit-llm
Version: 2.8.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.8.0 native distribution

**Half a million tokens of context on a 24 GB Mac.**

JustFit serves Inkling 2 Mini, a language-and-vision model, on Apple silicon
Macs with 24 GB of unified memory or more; `--model` switches back to
Qwen3.8-27B, and 16 GB Macs serve Bonsai 2 27B. 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.8.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 and downloads, from Hugging Face
and pinned to fixed revisions, the Inkling 2 Mini IQ4_NL GGUF
(`ggml-org/Inkling-2-Mini-GGUF`), its DFlash2 draft
(`incoai/Inkling-2-Mini-DFlash2`) and the vision tower from the MLX checkpoint
(`mlx-community/Inkling-2-Mini-4bit`, one shard): about 20.6 GB in all. 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).

| Memory | Default model | Default context |
| --- | --- | ---: |
| 16 GB (M6, `--node m6-16`) | Bonsai 2 27B | 221,169 |
| 24 GB or more | Inkling 2 Mini | about 491,000 (491,505) |

`--max-context` lowers the default (a token count). For the full context on a
24 GB Mac, see [Long context on a 24 GB Mac](#long-context-on-a-24-gb-mac).
About 21 GB of disk for the model, draft and
vision tower, plus the SSD cache (64 GB quota by default; `--max-cache-disk`
changes it, 0 turns it off). `--language-only` serves text only.

Vision: Inkling 2 Mini encodes images (and PDF pages) on the GPU. It does not
use the Neural Engine, so it downloads no ANE programs, and the ANE options
below do not apply to it.

### Qwen3.8-27B and Bonsai 2

```bash
~/.justfit/bin/justfit serve --model mlx-community/Qwen3.8-27B-4bit   # Qwen3.8-27B as in 2.7.0
~/.justfit/bin/justfit serve --model inkling                          # back to Inkling 2 Mini
```

Qwen3.8-27B downloads the original `mlx-community/Qwen3.8-27B-4bit`
checkpoint and its DFlash2 draft, and the ANE vision programs for this chip
(about 2.8 GB) from a pinned, hash-checked index. These options apply to
Qwen3.8-27B (and Bonsai 2) only: `--no-ane-vision` uses GPU vision and skips
the ANE download. 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` keeps the text prefill FFN on the GPU (Inkling 2
Mini always runs it on the GPU).

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; Inkling 2 Mini needs 24 GB, and the other chips
have no 16 GB preset.

## 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 Inkling-2-Mini
```

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 (on Inkling 2 Mini it may still think briefly; see the
release notes), or send `"thinking_budget": 0`. See
[docs/clients.md](https://github.com/YuhuaBillChen/justfit-llm/blob/main/docs/clients.md) for per-client settings and what a local
server does with hosted tools such as web search.

## New in 2.8.0

- Inkling 2 Mini is the default model on Macs with 24 GB or more, with the
  DFlash2 draft by default and DSpark as the fallback
  (`--draft-model thinkingmachines/Inkling-2-Mini`), and vision.
- A default context of 491,505 tokens (about half a million) on Macs with 24 GB or
  more; for the full context on a 24 GB Mac, see
  [Long context on a 24 GB Mac](#long-context-on-a-24-gb-mac).
- Draft trees for Inkling 2 Mini: several requests verified in one batch,
  sampled requests and JSON-schema constrained output.
- `thinking_budget` caps the thinking tokens; an explicit `0` answers without
  thinking.
- Thinking stays out of the answer text on every API.
- `--model mlx-community/Qwen3.8-27B-4bit` serves Qwen3.8-27B as in 2.7.0.

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

## Performance

Inkling 2 Mini with the shipped presets on macOS 27.2.1. Full protocol in
[docs/RESULTS.md](https://github.com/YuhuaBillChen/justfit-llm/blob/main/docs/RESULTS.md).

| | M4 Pro 24 GB | M5 Pro 24 GB | M6 32 GB¹ |
| --- | ---: | ---: | ---: |
| Decode, one request, 1K / 16K prompt (tok/s) | 82 / 73 | 101 / 85 | 61 / 51 |
| Prefill, 1K / 16K prompt (tok/s) | 535 / 549 | 1,040 / 1,155 | 784 / 829 |
| Time to first token, 1K / 16K prompt | 2.5 s / 40 s | 1.3 s / 19 s | 1.7 s / 27 s |
| Decode, 1 / 2 / 4 requests at 8K (tok/s, total) | 59 / 70 / 78 | 68 / 87 / 106 | 48 / 59 / 75 |
| Decode, chat with tools and history, temperature 1 (tok/s) | 40 | 47 | 32 |
| Peak memory, 2 requests at 8K | 18.2 GiB | 18.2 GiB | 18.1 GiB |
| 16K prefill / decode vs 2.7.0 | 2.9× / 1.6× | 2.3× / 1.5× | 1.8× / 1.5× |

¹ With 8 GB locked so it behaves like a 24 GB Mac.

The first three rows are SPEED-Bench: greedy, 512 output tokens. Everyday chat
is slower than that. At temperature 1, with tool definitions and a long
history, the draft guesses right less often. 2.7.0 served Qwen3.8-27B by
default, so the last row compares the two default models, not one model.

On 24 GB Macs, several long conversations in turn can push each other out of
the prompt cache (see Known limits in the release notes).


## Long context on a 24 GB Mac

A full 491K-token prompt needs nearly all the memory a 24 GB Mac lets you
wire. If the whole system goes over the kernel's wired-memory limit, macOS
kills the process holding the most, which is the server.

- Our M5 Pro (24 GB, no display) ran the full 491,505 tokens. The first token
  came after 21.5 minutes.
- Our M4 Pro MacBook (24 GB, display asleep, Apple Intelligence off) got to
  about 459K tokens, 0.5 GB under the limit, before our test's safety margin
  stopped it. We have not finished a full-length request on it.

On a MacBook two things wire extra memory while the server runs. The display:
about 0.45 GB each time the lock-screen clock redraws, and 0.7 GB for a moving
wallpaper. And Apple Intelligence: with the screen off it runs its on-device
model in the background and briefly takes about 1.6 GB.

To use the full context on a 24 GB Mac, let the display sleep, use a still
wallpaper, close GPU-heavy apps and turn off Apple Intelligence (System
Settings → Apple Intelligence & Siri). Or start the server with a lower
`--max-context`. Normal-length requests don't need any of this.


## 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 checkpoints from Hugging Face on first start, with their draft
  models: Qwen3.8-27B since 2.6.0, Bonsai 2 since 2.7.0, Inkling 2 Mini since
  2.8.0.
- Draft-tree decode: the draft proposes a small tree of continuations and the
  model checks the whole tree in one pass, for greedy, sampled and JSON-schema
  requests (on Qwen3.8-27B, sampled trees run on M5 Pro and M6).
- 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.
- 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).

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

Draft-tree decoding does not always give byte-identical text to verifying a
single draft chain; sampled requests keep the same distribution. A
multi-turn request that resumes a kept state can likewise differ slightly
from a full recompute.

## More

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