Two days ago, PrismML released Ternary-Bonsai-2.5-27B, and it caught our eye. It stores every weight as -1, 0 or +1, which puts a 27-billion-parameter model in about 6 GB, small enough for a 16 GB T4. On cards like that, decode is a question of how fast the weights can be read, and ternary weights are a format no general engine was built around. PrismML ships its own llama.cpp fork to run the file on NVIDIA, and it is the only other engine that can. Since then we have written one from scratch in CUDA to see how much faster the format could go.
tritrun decodes 323.6 tokens per second on an RTX 5090 with 3 multi-token-prediction drafts, 1.34× the fork’s 241.4 at its best settings. It is faster on every card we tested, a T4, an L4, an A10 and an RTX 5090, with drafts and without, and it uses less memory doing it. Most of the gain comes from one idea: a block of ternary weights is decoded once and then used for every token in the step, so checking three drafts costs little more than generating one token.
Faster than PrismML’s llama.cpp fork on every card we tested. Ternary-Bonsai-2.5-27B, PTQ1_0 GGUF, both engines in the same container on the same GPU with the same prompt tokens, the fork at its best setting.
- +28%decode with MTP on a T4, the smallest card, 60.1 tokens per second against 46.8
- 5 to 7%less VRAM than the fork at its leanest setting, with MTP on
- 778 / 1,000MMLU questions right, against the fork’s 777, with the same model file
Decode with 3 MTP drafts
Tokens per second, higher is better
Bars are scaled within each group
- tritrun
- PrismML llama.cpp fork
- T4
- L4
- A10
- RTX 5090
Why does one read have to serve several tokens?
Each 128 weights of the model are packed as trits into a few bytes, and a decode step on a card this size spends most of its time
fetching those bytes. Unpacking them is cheap next to the fetch, so tritrun unpacks each block once into registers and
multiplies it, with the dp4a integer instruction, against the int8 activations of every token in the step. One read of the weights then serves all of them.
That is what makes multi-token prediction pay. The model’s MTP head drafts 3 tokens ahead, and the engine checks all of them with the real model in one step, keeping the prefix that agrees. A 4-token step costs 1.15× a 1-token step on an L4 and 1.4× on a T4, and about 2.8 tokens survive each step, so drafts gain us 13 to 34% over the fork’s own MTP, more than the 8 to 11% we gain without them.

When a draft is wrong, its effects have to be undone, and that includes the model’s recurrent layers, whose state changes with every token. Instead of saving a copy of that state per token, tritrun keeps one checkpoint and replays the recorded layer inputs up to the last accepted token.
What else does a step spend its time on?
Launches. A 1-token step is about 640 kernels, so the engine folds as much as it can into each one. The RMS norm factor is a scalar, so it is applied to the output of the matmul, which lets a single kernel do the residual add, the sum of squares, the Hadamard transform and the quantization of the next input. The whole step is then replayed as one CUDA graph per step width, which reads the position from device memory so the same graph is reused for every token.
The RTX 5090 had a cost of its own. Matmuls there split their columns into 34 partitions so that all 170 SMs have work, and the kernel that adds the partial sums was waiting on one load at a time. Fetching 8 partitions of 4 elements per thread at once was worth 7% of plain decode on that card, the largest single gain there, where the CUDA graphs were worth about 2%.
And prefill?
Prompts are long enough to keep tensor cores busy, so steps of more than 8 tokens decode 128 rows of trits into shared memory and run
them against up to 128 tokens with the INT8 mma.sync instruction. The limit we hit was not the tensor cores but shared memory, which
delivers about 64 bytes per clock on each SM of these cards. We rebuilt the tile around that number, so each warp owns 64 rows by 32 tokens, every fragment arrives in one wide load,
and the activations are written in the order the kernel reads them.
| GPU | 512 tokens, fork | 512 tokens, tritrun | 2,048 tokens, fork | 2,048 tokens, tritrun |
|---|---|---|---|---|
| T4 | 331 | 412 | 341 | 403 |
| L4 | 741 | 827 | 788 | 811 |
| A10 | 913 | 994 | 951 | 966 |
| RTX 5090 | 2,899 | 4,043 | 3,174 | 3,531 |
Our figure is the wall time of the whole prefill plus the first token, and the fork’s is its own reported rate at its default batch size. The first generated token agreed every time. Short prompts gain the most, from 1.7× on a T4 to 6.3× on the 5090 at 64 tokens, and at 2,048 tokens on an A10 the two engines are level.1
How was it measured?
Both engines ran in the same container on the same GPU with the same prompt token ids. The fork is PrismML’s
prism-b12178-03ec600 with flash attention, an FP16 KV cache, a 4,096-token context and one slot. We ran it at batch sizes 512 and 64 and, for MTP, at draft
cut-offs of 0.1 and 0, and each of its figures here is the best of those. Memory is the peak nvidia-smi reading against the fork at batch size 64,
its leanest setting.

Each card’s final numbers come from one machine, and machines of the same type differ by several percent. On an earlier A10, before the last two decode changes, our margin was 1 to 2% plain and 10 to 12% with drafts.
Does it give the same answers?
It does, within the fork’s own spread. We ran the same model file through both engines with the fork’s chat template and tokenizer, and added a control: the fork against itself at another batch size, which shows how far its own rounding moves the results.
| Test | GPU | Fork | Fork, control | tritrun |
|---|---|---|---|---|
| WikiText-2 perplexity, 10,200 tokens | T4 | 9.7154 | 9.7145 | 9.7150 |
| L4 | 9.7147 | 9.7167 | 9.7195 | |
| A10 | 9.7161 | 9.7170 | 9.7146 | |
| RTX 5090 | 9.7107 | 9.7167 | 9.7173 | |
| MMLU, 1,000 questions | A10 | 777 | 778 / 776 | 778 |
| RTX 5090 | 777 | 776 / 779 | 778 | |
| GSM8K, 300 questions | A10 | 282 | 283 | 280 |
| RTX 5090 | 282 | 282 | 284 |
The median KL divergence from the fork is 9e-5 for us and for the control, and our top token matches the fork’s 99.3 to 99.4% of the time, against 99.3 to 99.5% for the control. On the 1,000 MMLU questions we pick the fork’s answer on 998 and 996.
Inside the engine the checks are exact. Steps of 1, 2, 4 and 8 tokens give bit-identical logits, repeated runs are bit-identical, and speculative output is identical to plain greedy output, on all four cards.
What went wrong on the way?
The RTX 5090 failed the bit-identity check the first time it ran. Under --use_fast_math the 1/sqrtf in the RMS scale compiled to different
instruction sequences in two kernels, so steps of different widths rounded the same value differently. It now uses the correctly
rounded __frsqrt_rn, and the checks pass on every card.
The first version decoded trits through a lookup table, and the shared dp4a decode that replaced it is what lets one read serve several tokens.
We also looked for a way to read fewer bytes, but the trits are spread evenly over -1, 0 and +1, at 1.585 bits of entropy each, so they do not compress further.
Where it stands
A 27-billion-parameter model now decodes at 60 tokens per second on a T4 and at 324 on an RTX 5090, faster than the engine its own makers ship, with the same answers and less memory. It decodes greedily, one sequence at a time, on Linux and NVIDIA, and we have not yet run it on an H100, a B200 or consumer RTX 30 and 40 series cards.
The engine, the benchmarks and every raw log are at https://github.com/amw720386/tritrun.
Notes
-
At 2,048 tokens on an A10 tritrun is 2% ahead in this container and 6% behind in another, 1,060 against 1,127, which is within the spread between machines. ↑
