Commit Graph
9 Commits
Author SHA1 Message Date
lotherk d9dc03abdb Front end: shorten a request's max_tokens instead of refusing it (--fit-max-tokens)
The engine keeps 8 cells of the context for itself, so the earlier check
(prompt + 1 <= ctx) promised more room than the engine would accept.  A request
whose max_tokens would run past the room left is now shortened to fit, or
refused with --no-fit-max-tokens (default: fit).
2026-10-13 13:19:31 +01:00
Robert KarlandClaude Fable 5.1 121d23ac2e Front end: leave the engine's 8-slot reserve out of max_new
The engine refuses a request unless prompt + max_new + 8 <= context, but
the front end sized max_new as context - prompt, so any client asking for
more tokens than remained (pi sends max_tokens 32768 on a 64K card) was
refused with "prompt (N) + max_new (M) exceeds the context" on every
prompt longer than context - max_tokens. Seen on the 1080 Ti Coder right
after a pi compaction left a 48K prompt.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-12 19:27:36 -07:00
Robert KarlandClaude Fable 5.1 f07b81e08b Front end: SSE keepalive comment after 15 s without a delta; cancel the generation when the client is gone
Content and tool calls are published only once the message is complete, so a long answer is silent for minutes. pi's HTTP idle timeout (5 min) then dropped the stream, retried the same prompt, and the engine finished the orphaned generation first: a 21,826-token turn on the 1080 Ti ran twice. The per-token callback now writes ': keepalive' when 15 s pass without an emit; a failed write cancels the run.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-12 15:07:32 -07:00
Robert KarlandClaude Fable 5.1 46c46ecfc1 Front end: image input through the model's vision encoder; engine child supervision; tests
Images: --mmproj PATH loads the Qwen3.8 Flash-Next projector through llama.cpp's mtmd
library and encodes image_url parts on the CPU (frontend/vision.hpp). The embeddings go to
the engine as a GENI request, its existing vision path, with the prompt's <|image_pad|>
runs standing in for each image. --vision-tokens caps the tokens per image. GET /v1/models
lists "image" under input_modalities when the encoder is loaded. Checked on an RTX 4090:
screenshots, photos, several images in one message, and pi's file attachments and
clipboard paste.

Engine process: the engine is started and watched from frontend/engine.hpp; when it exits
or its stall watchdog fires, the front end exits too, for a supervisor to restart. Stall
reports add the current stage and thread wait channels. Reasoning streams; content and
tool calls are sent once the whole message is parsed, so partial JSON never changes
arguments already sent.

Tests: make test-frontend (child exit, protocol, backpressure; no model needed) and
make test-chat-parser MODEL=<gguf> (template and tool-call parsing against the real GGUF).

The image path and the supervision were written by a Codex session; this commit finishes,
documents and checks them.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-08 15:54:53 -07:00
Robert KarlandClaude Fable 5.1 8df8936dee Tool calls: accept arguments in any order; log a call the parser dropped
llama.cpp's Qwen3-Coder grammar takes a tool call's required arguments first and
the optional ones after. Qwen3.8 Flash-Next often writes the optional ones first
(limit, offset, path), and because the grammar's tool-call group is optional and
has no end anchor, such a call parsed as no call at all: no error, finish_reason
"stop", an empty answer. A coding agent sees its turn end after it announced the
call.

The grammar now accepts the arguments in any order; whether a required one is
missing is for the tool to report. The change is kept as a patch under patches/
that `make build` applies to the submodule. The front end logs the raw output
when it contains <tool_call> but no call was parsed, so the next case of this is
visible in the journal.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-08 15:54:15 -07:00
Robert KarlandClaude Fable 5.1 9a53e42de4 Load from slow or remote stores: retrying reads, n-gram table in its own memory, container thread default
A RunPod network volume (S3-backed FUSE) refuses reads now and then with
ENOMEM or EIO, which made the expert load fail at start.  The new
strata/platform/robust_read.hpp retries such reads, halves the number of
parallel readers while the store refuses and raises it again afterwards.
The expert loader reads through it, prints progress, and names the file,
offset and error on failure.  --ple-io ram now reads the n-gram table into
anonymous memory with 16 readers instead of locking the file mapping, which
needs ulimit -l and faulted pages back from the store.

The front end's default thread count comes from the container's CPU quota
when there is one: a pod showed 256 host CPUs with a 32-CPU quota.

Verified on a 3090 pod: the model loads in normal mode straight from the
volume in 12 minutes, through two refused reads; from local disk in 19 s.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-05 21:17:37 -07:00
Robert KarlandClaude Fable 5.1 8f18634c30 Front end: tool calling and reasoning through llama.cpp's chat parser
The model's output is parsed by llama.cpp's own chat parser after every
token, and the differences are sent as OpenAI deltas (reasoning_content,
content, tool_calls). This replaces the hand-written thinking splitter.

Checked on the RTX 3090 pod: a tool call is returned with
finish_reason tool_calls, and the pi coding agent completed a multi-step
task (write a file, run it, fix, report) against the server.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-04 15:11:47 -07:00
Robert KarlandClaude Fable 5.1 d2e2217663 Front end: refuse multi-GPU, vision and batch options; README: usage and status
The first end-to-end run answered streaming and non-streaming chat
requests correctly on an RTX 3090 pod. It ran in a slow fallback mode
because of that pod's network volume, so no speed is claimed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-04 15:01:14 -07:00
Robert KarlandClaude Fable 5.1 1db37aaa75 Add the C++ front end: one binary serves an OpenAI-style chat API
unbiased-strata is the engine plus a front end. Started normally it runs
the front end, which starts a copy of itself as the engine (--engine) and
talks to it over a pipe in the engine's own line protocol, as upstream's
Python server does. The engine source is included unchanged; only its
entry point is renamed at compile time.

Tokenizer, Jinja chat template and HTTP library come from the pinned
llama.cpp submodule. Endpoints: POST /v1/chat/completions (with
streaming and reasoning_content), GET /v1/models, GET /health.

Builds on the RTX 3090 pod. Not yet verified end to end.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-04 14:28:08 -07:00