Local inference for open-weight models, in Go.
An OpenAI-compatible server and a library: MLX on Apple silicon, ggml on Linux and NVIDIA GPUs, pure Go anywhere. One binary, no Python.
Each row is one machine, one server at a time, 4-bit weights, versions and commands in bench/mlx.md and docs/backends.md:
| janis | llama.cpp | Ollama | |
|---|---|---|---|
| Qwen3-8B, M4 Mac 16 GB: prefill 600 tokens | 224.2 tok/s | 219.5 tok/s | 216.4 tok/s |
| Qwen3-8B, M4 Mac 16 GB: prefill 9,000 tokens | 195.0 tok/s | 174.4 tok/s | 154.5 tok/s |
| Qwen3-8B, M4 Mac 16 GB: decode | 22.8 tok/s | 19.9 tok/s | 20.3 tok/s |
| Qwen3.5-9B, M4 Mac 16 GB: decode | 19.9 tok/s | 18.5 tok/s | not measured |
| Qwen3-8B, GitHub runner, 4 vCPU: prefill / decode | 12 / 5.6 tok/s | not measured | 12.6 / 4.45 tok/s |
| Qwen3-8B, NVIDIA L4: decode | 43.2 tok/s | 47.0 tok/s | not measured |
| Qwen3.8-27B, NVIDIA A100: decode | 55.2 tok/s | 51.2 tok/s | not measured |
| Qwen3.8-27B, NVIDIA A100: prefill 1,500 tokens | 1,106 tok/s | 1,170 tok/s | not measured |
| Qwen3-8B, NVIDIA A100: decode | 146.0 tok/s | 138.5 tok/s | not measured |
| Inkling 2 Mini, RTX 5000 Ada 32 GB: decode | 62.0 tok/s | not measured | 58.3 tok/s |
| Inkling 2 Mini, RTX 5000 Ada 32 GB: decode after a 13,000-token prompt | 51.1 tok/s | not measured | 49.9 tok/s |
| Inkling 2 Mini, RTX 5000 Ada 32 GB: prefill 3,200 tokens | 1,041 tok/s | not measured | 1,219 tok/s |
| Inkling 2 Mini, RTX 5000 Ada 32 GB: prefill 13,000 tokens | 807 tok/s | not measured | 1,147 tok/s |
On the Mac, janis runs mlx-community's 4-bit weights (4.3 GB for the 8B)
and llama.cpp and Ollama the Q4_K_M GGUF (5.2 GB). Decode reads every weight
once per token, so part of the decode lead is the smaller file. On Inkling 2
Mini, janis runs mlx-community/Inkling-2-Mini-4bit (23.0 GB on the GPU) and
Ollama its own 4-bit GGUF with a 16k context (21.9 GB, all of it on the GPU).
What is different:
- MLX on a Mac. The Apple-silicon build runs on MLX, Apple's array
framework, with the
mlx-communityweights as published. No GGUF conversion. The same weights run on ggml and pure Go, repacked on load. - A Go module.
import "github.com/guregodevo/janis"loads a model in your process: no server beside your program, no Python. janis pullpicks the model. With no name it takes the largest model this machine's RAM runs well and its disk can hold. A model that does not fit is refused before the download.- Typed decisions.
POST /v1/systemoneanswers yes/no, choice and score questions with a probability read from one prefill, in tens of milliseconds (Decisions). No decoding, nothing to parse. - Installs without root. One file on Linux, into
~/.local/bin, sha256 checked.janis serve --detachreturns once the model has answered, so a CI job can start it and use it on the next line.
Use Ollama or llama.cpp instead for Windows, vision models, architectures janis does not load (Models), several models loaded at once, or the fastest decode of a small model on NVIDIA (Qwen3-8B on an L4: llama.cpp's 47.0 tok/s against 43.2), 8-bit weights there (the 27B on an A100: 39.6 against 33.3), or the fastest prompt reading of Inkling 2 Mini (Ollama's 1,219 tok/s against 1,041).
Linux (amd64, arm64) and macOS (Apple silicon), into ~/.local/bin, sha256
checked. On a Mac the MLX libraries go to ~/.local/lib/janis.
curl -fsSL https://github.com/guregodevo/janis/releases/latest/download/install.sh | sh
janis pull # the mlx-community model that fits this machine's RAM and disk
janis serve # http://127.0.0.1:8090/v1curl -s localhost:8090/v1/chat/completions -H 'Content-Type: application/json' \
-d '{"model": "Qwen3-8B-4bit", "messages": [{"role": "user", "content": "2+3?"}]}'Linux amd64 with an NVIDIA GPU: JANIS_CUDA=1 takes the build with ggml's
CUDA kernels, so nothing is compiled on the host. The ggml libraries go to
~/.local/lib/janis.
curl -fsSL https://github.com/guregodevo/janis/releases/latest/download/install.sh | JANIS_CUDA=1 sh
JANIS_GGML_DEVICE=gpu janis serve| The CUDA build | |
|---|---|
| Asset | janis-linux-amd64-cuda.tar.gz |
| GPU architectures | A100, RTX 30 and A6000, RTX 40 and Ada and L40S, H100, RTX 50 (compute capability 8.0, 8.6, 8.9, 9.0, 12.0) |
| The host brings | the CUDA 12 runtime (nvidia/cuda:12.x runtime or devel image), the NVIDIA driver, libgomp1 |
| Another GPU or CUDA version | build from source: scripts/fetch-ggml.sh --cuda |
janis start (or janis serve --detach) is for a CI job or a script: the
model is pulled when missing, the server runs in the background (its output
appended to janis-8090.log in the temp directory, or --log), and the
command returns once the model has answered a first request, so the first
client does not pay for loading it. A taken port or a server that dies fails
the command. JANIS_VERSION=v0.1.2 pins a release. make dist builds the
release asset for the machine it runs on (Build).
janis start [--port 8090] [--host 127.0.0.1] [--model NAME] [--log FILE]
janis status [--port 8090] # pid, version, model, uptime, GET /health within 2 s; exit 1 if it does not answer
janis version # the release this binary is
janis upgrade [VERSION] # replace this binary with the latest release, or the one named; --check only says
janis stop [--port 8090] # graceful; SIGKILL after 10 s
janis restart [--port 8090] # stop, then start on the same flags; --model X replaces the saved one; none running: startEvery server, foreground or background, writes its pid and flags to
~/.janis/run/PORT.json and removes it when it stops. stop and restart
act on the server that file names. A server started by janis v0.1.15 or
older has no file: stop, restart and status find its janis serve on
the port with ps and read its flags, so janis restart replaces it on the
same model. restart starts the server in the background, one first run
with janis serve included. With no janis on the port, restart starts one
as janis start does.
A server stops gracefully on janis stop, SIGTERM, Ctrl-C or its terminal
closing. It takes no new connection, and requests in flight get 5 s to
finish. Those still running are then cancelled: a generation ends at its
next token, a decision before its next question, a request waiting for the
engine leaves the queue. Each is answered 503; a stream cut short ends with
an error event and no [DONE]. The model is unloaded last.
Weights are MLX safetensors from huggingface.co/mlx-community, kept in
~/.cache/huggingface/hub ($HF_HOME/hub, or HF_HUB_CACHE when set).
janis pull checks the free space first: a model the disk cannot hold is
refused before the download, and with no name it takes the largest RAM tier
that fits the disk. janis list shows the installed models and whether each
fits.
| Family | Package |
|---|---|
| Qwen2.5, Qwen3 and Llama, dense; Qwen3 MoE (Qwen3-Coder-30B-A3B) | qwen |
| Qwen3.5 hybrid, Gated DeltaNet and attention (0.8B, 9B, Qwen3.8-27B) | qwen35 |
| Gemma 2 | gemma |
Inkling 2 Mini, text and images (Inkling-2-Mini-4bit, netprojects/Inkling-2-Mini-MLX-2.5bit): looped decoder, on MLX and on CUDA (Inkling-2-Mini-4bit, text, 24 GB of GPU memory; images were not tried there); on a host with less memory than the model the experts are read from disk |
inkling2 |
| Whisper (speech to text), BGE (embeddings), a reranker | whisper, bge, reranker, from Go only |
janis serve serves the installed models to any OpenAI-compatible client:
GET /v1/models and POST /v1/chat/completions, streamed or not, with tools.
The tool schemas are rendered into the system prompt the Hermes way, the
engine's grammar keeps every <tool_call> well-formed, and the call comes
back as OpenAI tool_calls. One model is loaded at a time. A request naming
another installed model swaps it. /v1/models carries each model's
context_length from its config. --host 0.0.0.0 opens it to the network.
Memdoor connects it with memdoor connect local --base http://localhost:8090/v1,
no key, on this machine or on a box reached over ssh.
reasoning_effort turns thinking on (any level) or off (none) for Qwen3 and
Qwen3.5. The thinking comes back as reasoning_content. For Qwen3.5 the
prompt opens the <think> block, as the model's own chat template does, so a
turn that is asked to think does. JANIS_OPEN_THINK=0 leaves the choice to
the model.
JANIS_PARALLEL=N decodes up to N requests together on a GPU. A step reads
the weights once for all of them, so the box's tokens a second grow with N
until the card's memory is full. One RTX 5090, ~1,400-token prompts, 1,024
tokens out, 2026-11-29 (docs/performance.md):
| Model | Streams | Box tok/s | $/M out | Cheapest OpenRouter host |
|---|---|---|---|---|
| Qwen3.8-27B 4-bit | 12 | 312.8 | 0.435 at $0.49/h | StreamLake, $1.05 |
Qwen3.8-27B 4-bit, JANIS_MOVE_ROWS=1 |
20 | 346.4 | 0.505 at $0.63/h | StreamLake, $1.05 |
| Inkling 2 Mini 4-bit | 40 | 462.5 | 0.378 at $0.63/h | Darkbloom, $0.105 |
The 27B's prompts were 1,135 tokens. On the box of the JANIS_MOVE_ROWS=1
row, 12 streams without it gave 309.9 tok/s ($0.565/M); without it 16
streams run out of memory (#95).
# Qwen3.8-27B: the defaults
JANIS_PARALLEL=12 JANIS_GGML_DEVICE=gpu janis serve --model Qwen3.8-27B-4bit
# Qwen3.8-27B: 20 streams, opt-in
JANIS_PARALLEL=20 JANIS_GGML_DEVICE=gpu JANIS_MOVE_ROWS=1 janis serve --model Qwen3.8-27B-4bit
# Inkling 2 Mini: the row above, its settings opt-in
JANIS_PARALLEL=40 JANIS_GGML_DEVICE=gpu JANIS_INKLING_ROWS=1 JANIS_FIXED_ROWS=1 \
JANIS_INKLING_HOST_MARKS=1 JANIS_GGML_FLATCONV=1 JANIS_PARALLEL_SAMPLE=1 \
JANIS_GGML_MXFP8=q8_0 JANIS_GGML_SHORTDOTS=1 janis serve --model Inkling-2-Mini-4bitThe same server answers typed questions the way a System One / Jev decision
model does, on the loaded model: POST /v1/systemone takes one piece of
state and questions about it, and answers each from a single prefill, the
probability read off the model's next-token distribution over the option
letters. No decoding, no prose to parse, a few tens of milliseconds a
question.
curl -s localhost:8090/v1/systemone -H 'Content-Type: application/json' -d '{
"state": "func add(a, b int) int { return a + b }",
"questions": {
"relevant": {"type": "noul", "instructions": "Is this about the add function?",
"criteria": {"true": "it is", "false": "it is about something else"}},
"kind": {"type": "choice", "instructions": "What kind of code is this?",
"criteria": {"test": "a test", "impl": "an implementation", "doc": "documentation"}},
"clarity": {"type": "score", "instructions": "How clear is it?",
"criteria": ["unclear", "fine", "clear"]}}}'{"model":"Qwen3-8B-4bit","answers":{
"relevant":{"type":"noul","noul":0.93,"confidence":0.93},
"kind":{"type":"choice","choice":"impl","probabilities":{"doc":0.02,"impl":0.95,"test":0.03},"confidence":0.95},
"clarity":{"type":"score","score":1.8,"probabilities":{"0":0.05,"1":0.1,"2":0.85},"confidence":0.85}}}Three question types: noul answers P(yes) (its criteria may spell out what
true and false mean); choice picks one of the labelled criteria and gives
the distribution; score places the state on an ordered rubric, score
being the expected zero-based level. A model in the request is honoured
when it names an installed model, otherwise the loaded one answers. The same
call from Go is engine.Decide(state, questions) (decide.go).
Memdoor uses this as its decision model: memdoor connect local on a janis
keeps local-decisions next to the chat provider, and from the next gateway
start the turn's effort, the tool routing, the judged reads and the stop
verdict are decided here, with no key. The numbers above are illustrative;
a 0.6B model answers the wire but judges poorly, an 8B is the sensible floor.
Requests run one at a time on the engine. A request whose client has gone
costs no more compute: it leaves the queue if it is waiting, or stops before
its next question. GET /v1/models and GET /health answer while a request
runs. engine.DecideContext(ctx, state, questions) is the Go call that stops
with ctx. GET /health names the server's release, {"status":"ok","version":"v0.1.20"};
a server from v0.1.19 or older answers without it.
janis serve --edit adds endpoints that read and replace the loaded model's
weights while it serves (the Qwen3.5 family, edit.go). They are off without
the flag. --edit refuses a host that is not loopback. start and restart
keep the flag.
| Call | Body | Does |
|---|---|---|
GET /v1/weights |
the editable weights: name, shape, dtype, group_size, bits, edited; and edits |
|
GET /v1/weights/{name} |
values, row major, a quantized matrix dequantized to shape |
|
POST /v1/weights/{name} |
{"values":[…],"bits":0} |
replaces the weight; a matrix is quantized again (bits 0 keeps its bits) |
POST /v1/weights/{name}/project |
{"u":[…],"alpha":1} |
W ← W − α·û·ûᵀ·W, u of the matrix's rows; alpha defaults to 1 |
POST /v1/weights/revert |
{} |
every weight back to the checkpoint |
POST /v1/weights/save |
{"path":"…"} |
the edits to a safetensors file |
POST /v1/weights/load |
{"path":"…"} |
an edits file applied, all of it or none |
POST /v1/hidden |
{"messages":[…],"reasoning_effort":"high","prefix":"…","layers":[8,16],"last":1} |
the residual stream after each of layers' blocks (0 is the first) at the prompt's last last tokens: tokens, width, layers, positions, states[layer][position]. prefix is the start of a reply, added after the chat template as it is. A forward pass of its own: no session is read or changed |
A call that changes weights answers {"edits":[…]}, the weights replaced
now. Every edit resets the sessions. A cached prefix of other weights is
never reused. An edit sent while the batch loop decodes replies gets 409.
A projection quantizes the whole matrix again, so even alpha 0 changes it
by the quantization error.
janis serve --edit --model Qwen3.5-0.8B-MLX-4bit
W=language_model.model.layers.0.linear_attn.dt_bias
curl -s localhost:8090/v1/weights/$W # {"name":…,"shape":[16],"values":[2.547,…]}
curl -s localhost:8090/v1/weights/revert -d '{}' # {"edits":[]}janis eval asks a running server every problem of a JSONL file
({"question","answer"}, the answer put in \boxed{}), problem i with seed
--seed+i, and writes a score: each problem's answer, whether it was right,
whether it ran out of tokens, and the weights the server had edited.
janis eval compare pairs two scores of the same file, seeds, cap and model
problem by problem, and refuses two that differ in any of them.
| Command | Does |
|---|---|
janis eval --problems P.jsonl --out S.json [--seed 1000] [--max-tokens 16384] [--parallel 1] [--effort high] [--repetition-penalty R] |
one score; prints correct 9/24 at cap 12/24 mean tokens 1396. Each result is kept in S.json.partial as it arrives: a run stopped by a failed request loses none, and the same command again asks only the problems that are missing |
janis eval compare [--alpha 0.05] BASE.json [CONTROL.json…] EDITED.json |
the last score against each one before it: gained, lost and a one-sided exact sign test; last line PASS (more gained than lost at p < alpha against every one) or FAIL |
janis eval failures [--each 10] [--chars 600] SCORE.json |
the wrong answers: how many ran out of tokens, how many finished wrong, and up to --each of either kind spread over the set, each with the end of its tail (the thinking's, for a reply that ran out before answering) |
janis eval curve [--budgets 2048,4096] SCORE.json |
from one score at a large cap, the share of replies finished and right at each smaller token budget (a reply that finished in T tokens finishes under any cap of at least T), and how many of the replies that finished between two budgets are right |
janis weights shift --match REGEXP --by D |
adds D to every weight whose name matches |
janis weights revert |
the checkpoint's weights |
janis weights save PATH, janis weights load PATH |
the edits to a file, a file's edits applied; PATH is made absolute here |
A control is the checkpoint asked another way, at the same cap and seeds:
--repetition-penalty 1.1, say. An edit that only stops answers looping
should not beat it. Requiring a PASS against each score at alpha is an
intersection-union test: no correction for the number of controls.
--repetition-penalty is ignored when the server runs with
JANIS_REPEAT_PENALTY set.
Every command takes --url (default http://127.0.0.1:8090). Sampling
defaults to temperature 0.6, top_p 0.95, top_k 20, thinking on: the
settings of arXiv:2611.21885. Set --parallel to the server's
JANIS_PARALLEL.
JANIS_PARALLEL=4 janis serve --edit --model Qwen3.5-4B-MLX-4bit
janis eval --problems dev.jsonl --out base.json --max-tokens 2048 --parallel 4
janis weights shift --match 'linear_attn\.dt_bias$' --by 0.5
janis eval --problems dev.jsonl --out edited.json --max-tokens 2048 --parallel 4
janis eval compare base.json edited.jsonOn Qwen3.5-4B, 24 problems, 2,048 tokens: the same seeds asked twice gave 23 of 24 replies identical with four requests batched; new seeds changed the answer to 8 of 24. A gain of a few points needs hundreds of problems. The checkpoint scored 9 of 24 on one server start and 11 of 24 on a later one, same seeds, the later binary rebased onto #69: pair scores from one start.
import (
llm "github.com/guregodevo/janis"
"github.com/guregodevo/janis/hostfit"
)
models, _ := hostfit.ListInstalled() // the snapshots in the Hugging Face cache
e, err := llm.Open(models[0].Path)
if err != nil {
return err
}
defer e.Close()
reply := e.Chat([]llm.Message{{Role: "user", Content: "2+3?"}}, llm.Options{MaxTokens: 64})ChatStream takes a callback per delta. Options carries temperature, top-p,
a seed, a cancel hook and the tool-call grammar.
| Package | What it is |
|---|---|
serve, cmd/janis |
the OpenAI endpoints over the engine (janis serve, start, stop, restart, status, list, pull) |
janis (the root package) |
load a model, chat, stream, decide, swap the loaded model live |
engine |
the tensor interface every backend implements |
qwen, qwen35, gemma, inkling2 |
model families |
whisper, bge, reranker |
speech to text, embeddings, reranking |
grammar |
constrained decoding for tool calls |
hostfit |
which model fits this host's RAM, and how well it will run |
mlxc, ggml, cpu |
the backends |
safetensors, gguf, tokenizer |
the loaders. gguf reads the container and the GGML quantization types and leaves the architecture to the caller. |
The model code is written against one tensor interface (engine.Backend,
about fifty ops). A backend is an implementation of it.
| Flavor | Backend | Where | How |
|---|---|---|---|
| janis | MLX | Apple Silicon | the default build (make build) |
| janis-cuda | ggml, llama.cpp's tensor library: CUDA, Metal or CPU kernels | Linux with an NVIDIA GPU; also Metal and CPU on a Mac | -tags ggml (JANIS_BACKEND=ggml on a Mac; the default on Linux), JANIS_GGML_DEVICE=gpu |
| janis-cpu | pure Go | anywhere | CGO_ENABLED=0, or JANIS_BACKEND=cpu |
docs/backends.md has how the ggml backend is built and how it repacks MLX's 4-bit weights, with the numbers on a Mac, a GitHub runner and an NVIDIA L4.
Apple Silicon with MLX:
brew install mlx mlx-c # mlx-c is linked from /opt/homebrew
make build # provisions lib/libtokenizers.a, then go build ./...
make testLinux, one file (ggml's CPU kernels and the tokenizer linked in, ggml the
backend unless JANIS_BACKEND=cpu): the release's install.sh (Install),
or scripts/fetch-ggml.sh --static and go build -tags ggml ./cmd/janis.
Anywhere, without MLX or cgo:
CGO_ENABLED=0 go build ./...lib/ holds the HuggingFace tokenizers static library per platform
(lib/libtokenizers.a on macOS, lib/linux-<arch>/ on Linux). It is
gitignored; make tokenizer-lib fetches or builds it. A program that imports
janis from Go's module cache has no lib/: make install-lib copies the
archive to /opt/homebrew/lib (macOS) or /usr/local/lib (Linux), which the
tokenizer also searches — the same place mlx-c comes from.
Memdoor, the terminal coding agent, behind
MEMDOOR_SHOW=local. Memdoor imports janis as a module (its make janis
runs install-lib); to edit both at once, a go.work in the Memdoor
checkout points at ../janis.