# chonk

**Will it fit? Memory, speed and cost estimates for very large language models.**

Mistral's Large 4, nicknamed *Le Chonk*, has about one trillion parameters, of which 49 billion work on each token.
Its weights are due to be published at the end of October 2026. Before anyone downloads a terabyte, the useful
questions are simple: how much memory does it take, how many GPUs (or Macs) is that, how fast will it answer, and is
renting the hardware cheaper than the API? `chonk` answers them in one call, for Le Chonk and six other open models,
on seven kinds of hardware, or on your own numbers.

One file, zero dependencies, Node 18+ and the browser. MIT licence. Every result is an **estimate** with its
assumptions written down in `ASSUME`; it is not a benchmark.

```
npm test                                      # 13 tests
node bin/chonk.js fit mistral-large-4 --hw h200 --count 8
node bin/chonk.js rank mistral-large-4 --quant q4 --ctx 8k
node bin/chonk.js demo
```

## What it computes

- **Memory.** Weights = parameters x bits per weight / 8 (bf16, fp8, int8 and GGUF-style q6 to q2, scales included).
  KV cache = bytes per token x context x batch (2 x layers x KV heads x head size, or the latent size for MLA models;
  8-bit cache halves it). Runtime = 5 % of the weights + 1.5 GB per device. A device may use 92 % of its memory.
- **Devices.** The smallest count that holds it all, and whether your count does.
- **Speed.** A roofline estimate for decoding: each step reads the weights it touches and the KV cache and does
  2 x active parameters x batch operations, at 70 % of peak bandwidth and 50 % of peak arithmetic. Mixture-of-experts
  models touch about 1 - (1 - active/total)^batch of their weights per step. NVLink-class devices share the work
  inside an 8-device node (with a 15 % loss); PCIe cards and Thunderbolt-chained Macs work in turn, so they add
  memory but not speed. Each step also pays a fixed cost (2 ms, +6 ms when devices sync, +3 ms per extra stage).
- **Cost.** Your hourly rate x devices / tokens per hour, per million output tokens, against an API price
  (default: Le Chonk's preview price, $4.18 out and $1.36 in, with 3 input tokens per output token).

## Le Chonk on one page

```
Mistral Large 4 (Le Chonk), fp8, 32,768 tokens x 1

  hardware                     count    memory  tok/s/user   $/hour   $/M out  note
  Mac Studio M3 Ultra 512 GB       3   1.07 TB         8.8    $0.75    $23.77  memory-bound
  MI300X 192 GB                    7   1.07 TB        93.0   $17.50    $52.28  latency-bound
  B200 180 GB                      7   1.07 TB       101.8   $38.50      $105  latency-bound
  H200 141 GB                      9   1.08 TB        61.3   $31.50      $143  latency-bound
  H100 SXM 80 GB                  15   1.08 TB        53.7   $37.50      $194  latency-bound
  RTX 5090                        39   1.12 TB         6.1   $27.30    $1,247  too many devices to be practical
  RTX 4090                        52   1.14 TB         4.1   $20.80    $1,394  too many devices to be practical
```

One user at a time never beats the API on rented hardware. Batch the work and it can: with 64 users at once on
8 x B200, `chonk` estimates $7.29 per million output tokens against $8.26 through the API.

## Use it

```js
const C = require("chonk");            // or <script src="chonk.js"> -> window.Chonk

const p = C.plan("mistral-large-4", { hw: "h200", count: 8, quant: "fp8", ctx: 32768, batch: 1 });
p.total;            // 1074 GB
p.fits;             // false
p.needed;           // 9
C.verdict(p);       // "... It does not fit on 8 x H200 141 GB: it needs at least 9."

const s = C.speed(C.plan("mistral-large-4", { hw: "b200", quant: "fp8", ctx: 8192, batch: 64 }));
s.perUser; s.total; s.bound;           // tokens/s per user, for the batch, and what limits it

C.cost(p, { rate: 3.1, apiOut: 4.18, apiIn: 1.36 });   // $ per hour, $ per million out, API, which is cheaper
C.rank("deepseek-v3", { quant: "q4", ctx: 8192 });       // every device at its smallest fitting count
C.plan({ name: "My 70B", total: 70e9, kvBytes: 327680 }, { hw: { name: "Box", mem: 64, bw: 0.96, bf16: 150, fp8: 300, link: "pcie" } });
```

| Function | Returns |
|---|---|
| `plan(model, { quant, ctx, batch, kvBits, hw, count })` | weights, kv, runtime, total, perDevice, needed, count, fits, nodes, overCtx |
| `speed(plan)` | step time, perUser, total tokens/s, bound (memory, compute or latency), parts |
| `cost(plan, { rate, apiOut, apiIn, inPerOut })` | perHour, selfPerM, apiPerM, cheaper |
| `rank(model, opts)` | every device at its smallest fitting count, practical first, cheapest first |
| `weightsGB`, `kvGB`, `touched`, `verdict`, `model`, `hardware` | the pieces |
| `MODELS`, `HARDWARE`, `QUANT`, `ASSUME`, `LIMIT` | the built-in data and assumptions |

## Command line

```
chonk models | hardware
chonk fit  [model] [--hw h200] [--count 8] [--quant fp8] [--ctx 32k] [--batch 1] [--kv-bits 16]
chonk rank [model] [--quant q4] [--ctx 8k] [--batch 1]
chonk cost [model] --hw b200 --batch 64 [--rate 5.5] [--api-out 4.18] [--api-in 1.36]
chonk demo
```

`fit` exits with code 2 when the model does not fit, so it can guard a deploy script.

## Limits

- **Le Chonk's layout is not published.** Mistral gave 1T parameters (some reports say 1.05T) and 49B active
  (its French announcement says 52B active; at 52B every speed figure here would be a few per cent lower).
  Its KV-cache size is assumed equal to Mistral Large 2's and its context is reported as 500K or 1M tokens;
  both are marked `assumed`. Change them with a custom model when the config is out.
- These are roofline estimates. Real servers add scheduling, prefill, speculative decoding, expert parallelism and
  network effects; measured speed can be well above or below.
- Rental rates are examples. Prices for the same GPU vary several-fold between providers.
- gpt-oss-120b's KV figure ignores its sliding-window layers, so it is an upper bound.

## Examples

`examples/will-it-fit.js`, `examples/cheapest-rig.js`, `examples/break-even.js`.
