33 Commits
Author SHA1 Message Date
Robert KarlandClaude Fable 5.1 698b02e1a2 frontend: a picture encoded once is a picture encoded once (USTRAT-15)
A chat client resends the whole conversation every turn, pictures included, and the vision encoder is the slow part
of a request: 6 s a screenshot on 16 CPU threads, 18 s on 6, every turn, while the engine reuses the prompt's KV
prefix in a fraction of a second. Upstream's Python server kept the encoder's output per picture in an LRU of 64
files keyed by the SHA-256 of the picture's bytes (serve/server.py, class Vision); this is that cache for the C++
front end, in memory.

frontend/picture_cache.hpp (header-only, no llama.cpp): PictureCache keeps PictureRows (the projector's output,
n_tok rows of the embedding width) under mtmd's chunk id, which is the SHA-256 of the bitmap's bytes. Shared
pointers, so a request keeps the rows it is writing when the cache lets go of them; two limits, entries and bytes,
the newest entry always kept. engine_key() turns the id into the 64-bit key the engine's conversation cache takes
(img_keys= on the GENI line, #2228), so a picture encoded again with other bits still matches its KV prefix.

encode_pictures is now six short functions: open the file, fill it, find the chunk, its id, its rows (cache or
encoder), its grid, write the record. --picture-cache N (default 64, 1 GiB) sets the size; 0 turns it off.

frontend/tests/picture_cache_test.cpp: hit/miss and counters, LRU order and the entry limit, the byte limit and the
oversize newest entry, a held entry outliving its eviction and a key replaced, off and an empty key, the engine
keys, eight threads at once. In make test.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-20 10:33:30 -07:00
Robert KarlandClaude Fable 5.1 b4e28c767a e2e: the literal oracle splits only the literals themselves, as tokenize_plain does
An ordinary one-token text such as "<th" is not split by the server (its attribute is not CONTROL or USER_DEFINED);
the oracle split it and was one token off against the Flash-Next vocabulary.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-19 23:40:54 -07:00
Robert KarlandClaude Fable 5.1 cd3be94f42 frontend: a control token's text inside a message is text (USTRAT-14)
The rendered prompt was tokenized whole with specials parsed, so "<|image_pad|>" in a
document an agent read became the image pad token and the engine refused the request
("the prompt has more images than the embeddings file"); "<|im_end|>" in a tool
result ended a turn. Upstream's Python server marked these literals before the template
rendered (#537, #554); the C++ front end lost that with the server's removal.

frontend/literals.hpp: the texts of the vocabulary's control tokens and marker-like
added tokens (<think>, <tool_call>, [gMASK]) are swapped for private-use marks in the
messages and tools before oaicompat_chat_params_parse renders the template, swapped
back after, and the spans they covered are tokenized as text: parse_special off, and an
added token the tokenizer matches regardless is split until none is left. Media parts
are not scanned. An assistant message keeps a leading whole <think>...</think> block
as the model's markers (clients that send reasoning inline), as upstream did. A mark
that a template's tojson(ensure_ascii=True) escaped as a surrogate pair is read too.
A request without literals renders and tokenizes exactly as before.

mtmd's logger wrote every level to stderr, its debug line add_text() among them: the
whole rendered prompt once per request into the journal. It now goes through the
common log, where debug lines need the server's verbosity raised.

Tests: frontend/tests/literals_test.cpp (no model; nlohmann json, the interface
common_json copies) in make test; e2e.sh runs a third fake-engine server with upstream's
Qwen3 template (frontend/tests/data/qwen3-chat-template.jinja) and checks
usage.prompt_tokens against the prompt tokenized by hand with the literals as text, for
user content, a tool description and an assistant history message.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-19 23:35:32 -07:00
Robert KarlandClaude Fable 5.1 a8469d55b5 step 13: acceptance harness (pi in Docker, four tasks, judges), API-only acceptance script, GLM vocabulary load fix
tools/acceptance/: Dockerfile (pi 0.85.1 image), run-task.sh / run-all.sh / judge.sh / pretty.py, tasks md-toc,
kvstore, bugfix (seeded), minesweeper with hidden tests / black-box judges, models.tsv, README. Runs go to
runs/ (ignored); curated results land under bench/unbiased/ when the campaign closes.

frontend/tests/acceptance-real-engine.sh: PLAN.md step 13 (c): sampled checks, seeded repeat, tool call, decode and
prompt-reading speed against an expected figure with a 15 % band.

frontend/strata_context.cpp: the vocabulary-only load is retried with general.architecture overridden to "llama"
when llama.cpp does not know the file's architecture; GLM 5.3 Flash's file says glm5-next (neurall's fork) and
the front end refused to start (USTRAT-6). Verified on the 2x B200 pod: GLM starts, template renders, answers.

tools/pod/README.md: pod-to-pod tree copy (90 s against hours from the laptop), bringup must wait for the tree.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-18 19:19:36 -07:00
Robert KarlandClaude Fable 5.1 17e2721354 frontend: picture row budget as upstream's installer set it (300 on the CPU, 1024 on the GPU); --mmproj-gpu refused without a GPU backend
An uncapped 1920x1080 screenshot is 2040 rows and took 146 s on the A6000 VM's
Ryzen 7 1700. Upstream's setup.py gave strata-vision --max-tokens 300 on the CPU
and 1024 on the GPU; the same defaults here, --image-max-tokens overrides. The
front end's ggml has no GPU backend (the engines bring their own CUDA), so
--mmproj-gpu now fails at start instead of running on the CPU under a GPU label.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-18 00:33:59 -07:00
Robert KarlandClaude Fable 5.1 1026afb266 frontend: --mmproj-gpu runs the vision encoder on the card; the CPU stays the default
The first picture on the A6000 VM (Ryzen 7 1700, 12 vCPUs, AVX2) took 146 s to
encode a 1920x1080 screenshot (2040 rows) on the CPU against 0.85 s of engine
time. The card had 29 GB free beside the engine. --mmproj-gpu (a front-end
option, not llama-server's, whose default is the GPU) puts the encoder there with
mtmd's warm-up so the work buffers exist before the first request.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-18 00:29:31 -07:00
Robert KarlandClaude Fable 5.1 d0bc0d868d frontend: the vision encoder looks for the request parser's media marker
server-common replaces an image_url part by a marker that is random per process;
mtmd was left at its default marker, so the first picture request on the A6000
failed with 'number of media markers in text (0) does not match number of bitmaps
(1)'. Set mtmd's marker to get_media_marker(), as llama-server does.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-18 00:24:56 -07:00
Robert KarlandClaude Fable 5.1 71886db022 Step 8: pictures through the front end, encoded in-process on the CPU, handed to the engine as GENI
--mmproj FILE loads the model's vision projector with llama.cpp's mtmd in the server
process (CPU, --threads or half the cores; the card is the engine's), after checking
that the projector's output width (clip.vision.projection_dim) equals the model's
embedding width from the GGUF metadata and that the vocabulary has <|image_pad|>.
A request's image_url parts come through llama.cpp's own parser as media chunks;
launch() encodes each chunk, writes strata-vision records ('SVE1', rows, nx, ny,
width, float32 rows) to a per-request temp file removed with the slot, replaces the
chunk's placeholders by image_pad ids, and sends GENI <max_new> ... image_pad=<id>
<file> <ids>, which strata-poly (take_pictures) and strata read. Without --mmproj
the parser refuses images with llama.cpp's message; e2e.sh checks that.

Reference: upstream tools/vision/strata_vision.cpp (same records, a child process)
and UnbiasedStrata 1's frontend/vision.hpp. Qwen family only (the pad token);
tiled encoders (MiniCPM-V canvases) are refused. Gate on a real engine follows.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-18 00:21:28 -07:00
Robert KarlandClaude Fable 5.1 96f4ef1fbb frontend: always send usage in the final streamed chunk; fix e2e checks
Upstream PolyStrata's server reports usage on every streamed reply, and its
tools/strata_bench.py reads prompt_tokens from it without sending
stream_options.include_usage. llama.cpp only adds the usage chunk on request,
so the fork's step-9 Flash-Next arm recorded prompt_tokens = null. Set
include_usage on every task result: the last chunk has usage, timings and an
empty choices array (OpenAI's documented shape).

e2e.sh: the health check from 453d3015 compared the json boolean to 'True'
instead of 'true'; the stream checks now skip the empty-choices chunk and
assert usage on it.

Verified: make test under sandbox-exec (engine_test 7 cases, e2e all checks).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-17 23:36:52 -07:00
Robert KarlandClaude Fable 5.1 453d301599 frontend: /health advertises service=strata and loaded=true for upstream clients
Upstream's tools/strata_bench.py (is_strata, wait_ready) only talks to a server
whose /health has service == "strata" and loaded; the fork answered llama.cpp's
{status, busy} only, so the step-9 fork arms never left the readiness wait
(fork-flash-next on the pod sat ready for 30 min, then was killed as 'failed
to start'). Add service, loaded, model, max_context; keep status and busy.
e2e.sh checks the two required fields.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-17 23:28:24 -07:00
Robert KarlandClaude Fable 5.1 2f9004ba5c Step 7: the request shapes a coding agent sends, and pi's task, on both engines; Qwen3.6 UD-Q3_K_M on the A6000
frontend/tests/shapes-real-engine.sh runs seven request shapes against a live server (PLAN.md section 9, step 7): no
max_tokens; max_tokens 32768; a prior assistant message with reasoning_content and tool_calls followed by a tool
result; two tool calls asked for in one turn; a call with its optional arguments before the required one; a client
that disconnects two seconds into a stream, then a clean request; an 18k-token prompt streamed, timing the first byte
and counting SSE pings. Records: bench/unbiased/2026-10-17-{a6000-qwen36-ud-iq4xs-mtp,3090pod-flash-next-iq3xxs}-step7-
shapes/ and -step7-pi/, plus the A6000's Qwen3.6 UD-Q3_K_M smoke (…-a6000-qwen36-ud-q3km-mtp-step6/). docs/MODEL-FILES.md
describes the checks and the SSE ping default.

Verified 2026-10-17:
- Qwen3.6 UD-IQ4_XS on the A6000 and Flash-Next IQ3_XXS on the 3090 pod answer all seven shapes. Without max_tokens the
  front end fills the context (n_predict 32,747); max_tokens 32,768 beyond the context is clamped, not refused; the
  reasoning_content history is accepted and answered from the tool result; the optional-arguments-first call parses
  ("limit", "offset", then "path"); the disconnected stream is cancelled at the engine (finish=cancel after 387 and 172
  tokens) and the next request answers in 0.09 s and 0.24 s; the 18,589-token prompt streams its first byte after 5.2 s
  (Qwen3.6, A6000) and 8.0 s (Flash-Next, pod). Qwen3.6 issued the two parallel calls asked for; Flash-Next chose one
  bash call instead, which is the model's choice, not a parsing fault. No ping was seen because the pinned server pings
  after 30 s of silence (--sse-ping-interval); the run lines will set it lower for long prompts.
- pi 0.85.1 against Flash-Next on the pod completed the same multi-step task as against Qwen3.6: read, --json flag, 7
  unittest tests, all passing, one commit (it also noticed and untracked __pycache__). 17 requests, 16 finish=stop and
  the one cancel from the shapes run, prompts up to 4,644 tokens, max_tokens 32,768 passed through, no parse failure.
- Qwen3.6 UD-Q3_K_M (8966dd0c...) on the A6000: all six smoke checks, 214 to 235 tokens/s decode on short prompts.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-17 22:28:14 -07:00
Robert KarlandClaude Fable 5.1 ef1ee031c7 Step 6: first end-to-end chats through the front end on both engines, equal to upstream; the model-file table
Records under bench/unbiased/, one directory per box and model: the exact launch script, the fork commit, the engine's
info lines and the raw responses of frontend/tests/smoke-real-engine.sh (health, /v1/models, a greedy chat without
thinking, a sampled chat with thinking, a stream, a tool call). docs/MODEL-FILES.md tracks every model file tried, by
source repository, size and SHA-256, with its status; the same quantization from two Unsloth repositories is two rows,
because only the Qwen3.6-35B-A3B-MTP-GGUF files carry the draft block. Upstream's docs/MODELS.md is unchanged.

Verified 2026-10-17:
- Flash-Next GSQ-RCO IQ3_XXS on `strata`, with the pack, the expert profile, spec 4 and MTP exactly as upstream
  PolyStrata v0.1.45-poly.1 ran it on the RTX 3090 pod on 2026-10-17: the front end serves all six checks on the pod
  and on the A6000 VM. The greedy answer ("101\n103\n107", 12 completion tokens) is the same on both boxes and the same
  as upstream PolyStrata's Python server on the same engine binary and files on the pod (upstream-compare/), which is
  the step-6 gate of PLAN.md section 9.
- Qwen3.6-35B-A3B UD-IQ4_XS (MTP repository, SHA-256 df27a780...) on `strata-poly` with upstream setup.py's flags for
  the family: all six checks on the A6000, 207 to 215 tokens/s decode on short prompts, 83% of drafts accepted. The
  stream check ended by max_tokens with thinking on, as expected for a 200-token cap.
- Through an SSH tunnel, pi 0.85.1 with an openai-completions provider pointed at the Qwen3.6 server completed a
  multi-step task in one run: read two files, added a --json flag, wrote 11 unittest tests, ran them, fixed nothing,
  committed. pi sent no max_tokens cap below 28,229 and no min_p; the front end passed both through.
- The pod's /workspace is a geesefs FUSE volume that stalls to a few MB/s when the engine fills its expert cache from
  it while anything writes; the engine then never becomes ready. bench/unbiased/*3090pod*/stage.sh stages the files
  on the container disk (hashes of pack and MTP checked against the pod's artifacts.sha256, shard sizes equal).

Not yet: a speed comparison (the pod's fork decode on the two short smoke prompts was 64 tok/s against upstream's
112 tok/s sustained benchmark; step 9 measures both the same way), Qwen3.6 UD-Q3_K_M (downloaded and hashed, not run).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-17 22:22:10 -07:00
Robert KarlandClaude Fable 5.1 4c25aa6f6a Front end: llama.cpp's server files with the Strata engine behind them (design C), with fake-engine tests
frontend/strata_context.cpp replaces tools/server/server-context.cpp. The other seven server files
(server-http, -queue, -task, -common, -chat, -schema, -stream) compile unmodified from the submodule into
the static library strata_llama_server; frontend/ui_stub/ supplies the empty web-UI asset table that
server-http.cpp references. The context runs one slot: the engine is a child process spoken to over its
line protocol (docs/BACKENDS.md), a vocab-only llama_model provides tokenizing, the chat template and the
reasoning and tool-call parsers, and the server's own task and result types carry the OpenAI JSON, SSE
framing and client-disconnect cancel. Routes kept: /health, /v1/models, /v1/chat/completions, /tokenize,
/detokenize. The strata engine's 8-token reserve is kept out of max_new. A supervisor thread ends the
process with exit code 1 when the engine dies, for a unit with Restart=on-failure.

frontend/engine.hpp is the child adapter: fork+exec, READY/INFO, GEN/GENI, T/PP/RESUME/DONE/ERR/FATAL,
STOP with drain to DONE, non-blocking reap. quit() and the supervisor's reap_exit() share the pid through
an atomic that quit() takes over by exchange, and only a positive local copy ever reaches kill(). The
first draft kept a plain pid_t and the supervisor set it to -1 on reaping, so a SIGTERM during shutdown
raced into kill(-1, SIGKILL), which killed every process of the user; it did so twice on 2026-10-17.

Build: STRATA_FRONTEND (default on) gates the llama.cpp libraries and the front end, not CUDA, so they
build on a machine without a GPU. Makefile: unbiased-strata joins `make build`; `make frontend` builds it
alone without CUDA into build-frontend/; `make test` builds engine_test there and runs it and
frontend/tests/e2e.sh against a fake engine (frontend/tests/fake-engine.py). The nvcc probes run only
when there is an nvcc and only the build and configure goals demand one. UPSTREAM.md records all of it.

Verified on macOS arm64 without CUDA: `make frontend` and `make test` pass. engine_test, 7 cases: READY,
a request, STOP mid-request with drain and a clean next request, a 100k-token burst the caller abandons,
ERR leaves the adapter usable, the engine dying mid-request is diagnosed, a DONE with the wrong prompt
size is visible. e2e.sh, 12 checks: /health, /v1/models, a non-streaming chat with content, finish and
usage, a stream whose deltas join to the content and end with finish_reason and [DONE], a client that
disconnects mid-stream (the server logs the cancel and the next request completes), an oversize prompt
refused with 400, a tokenize/detokenize round trip. Zero new patch lines to llama.cpp, so the step-4
gate of PLAN.md section 5 passes and design C stands. Not yet run against a real engine.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-17 21:31:05 -07:00
Robert Karl d1022a66f0 Empty the tree: UnbiasedStrata 2 starts over from PolyStrata
Every tracked file, .gitignore, .gitmodules and both submodules (llama.cpp at
3cf03257, llama-muse at 335916a) are removed so the next commit can import
PolyStrata v0.1.45-poly.1 unmodified and be the diff baseline of the fork.
UnbiasedStrata 1 remains at tags unbiasedstrata-1 (main, b124b59) and
unbiasedstrata-1-muse-spark-native (4c824e6).

Verified: git ls-files is empty; the working directory holds only .git.
2026-10-17 19:34:05 -07:00
Robert KarlandClaude Opus 5.5 b124b59ce4 Front end: the vision projector's width is checked against the model's, so Qwen3.6-35B-A3B takes images (CPU encoder)
Checked on the GTX 1080 Ti with Q4_K_XL at 262,144 context: six of six facts read from a 1920x1080 screenshot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
2026-10-13 13:26:18 -07:00
Robert Karl 21b2aa2acb Merge qwen36-step4: Qwen3.6-35B-A3B on a single GPU from 6 to 24 GB, beside Qwen3.8-Flash-Next
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr

# Conflicts:
#	docs/PLAN-qwen36-35b-a3b.md
#	frontend/main.cpp
2026-10-13 11:16:04 -07:00
Robert KarlandClaude Opus 5.5 3aa9eed522 Front end: chat_template_kwargs.preserve_thinking reaches the template
A plain two-turn chat reused only the first prompt up to its assistant
header (27 of 278 tokens in step5-serve.md; 18 of 128 here).  The cause is
the template, not the checkpoints: Qwen3.6's template renders a reply that
stands before the last user message without its <think> block (and, with
thinking off, without the empty block the generation prompt carried), so
the next request's tokens leave the generated ones right after the header
and the engine falls back to the checkpoint it keeps there.  A reply after
the last user message (a tool loop) keeps its reasoning and is reused
whole: pi's second and third requests reused 1,867 of 1,948 and 2,047 of
2,118 tokens.

The template has a switch for the plain-chat case, preserve_thinking; the
front end now passes it through.  With it and reasoning_content sent back,
Q4_K_XL on the 4090 reuses 551 of 569, 1,010 of 1,027 and 1,365 of 1,382
prompt tokens over four turns (18 / 110 / 123-of-171 without).  It is opt-in:
the earlier reasoning then stays in the context the model reads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
2026-10-13 02:34:33 -07:00
Robert KarlandClaude Opus 5.5 c3b41cc46a Front end: the answer's content streams as it is written (REGINA-110)
With "stream": true the front end sent reasoning_content per token and the
answer as one delta before the final chunk.  The cause was in run(): every
partial parse had its content cleared together with its tool calls, a rule
added with the image commit (46c46ec) so that partial tool-call JSON, which
the parser closes and normalizes on each token, could never change text
already sent.  That reason holds for tool-call arguments, not for the
answer: the Qwen3-Coder parser's partial content only grows.

The parse of a growing response is now StreamParse: reasoning and content
are published as they arrive, tool calls once from the complete parse.  A
partial parse whose content does not extend what was sent publishes nothing
for the content until it does, and the complete parse cannot take back
streamed text.  A non-streaming request is parsed once, at the end, instead
of after every token.

make test-chat-parser feeds seven responses a character at a time (reasoning
on and off, tools declared and not called, text before a call, one and two
calls) and requires the streamed pieces to add up to the whole parse, the
content to arrive in many deltas, and each call in one.

Checked on the RTX 4090 (VM 221), Q4_K_XL: 212 content deltas for the
ticket's 213-token request, first at 76 ms, largest gap 11.5 ms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
2026-10-13 02:17:55 -07:00
Robert KarlandClaude Fable 5.1 7ebc9e53c5 front end: the served context is the engine's; the automatic mapped tier skips a shared arena and the helpers
From the second Codex review of fa69e82.  The engine's READY line carries
the context it allocated (`READY <max_context> stop`); when its VRAM plan
lowered the request, the front end kept validating prompts against --ctx
and announcing it.  It now reads the figure, bounds requests by it and
says so.  The automatic mapped-experts choice is not taken with an
explicit --shared-expert-arena or with the multi-GPU helpers.  The plan's
session term keeps the RoPE table sized at the requested context when
lowering (at most 32 MiB conservative from 262,144 to 131,072): noted in
docs/qwen36-port/step5-serve.md, not threaded through the plan.
main.cpp syntax-checked on the Mac; the CUDA build follows when a card is
between measurements.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
2026-10-12 21:33:11 -07:00
Robert KarlandClaude Fable 5.1 22d72e69e7 pool: the native-pack rows at the layer's widths, not the canonical FF / H; the served model's name from its file
Every verify window with an expert miss computed on the CPU decoded to
token 0 ("!!!!") on both Qwen3.6 files: the first serve of the Q4_K_XL
pack at 262,144 context (9,980 of 10,240 experts resident) and IQ3_XXS
under any --vram-cap.  Found by elimination on the 4090: all-resident runs
were correct at every context and KV format, --pcie-frac 1.0 (misses by
DMA, computed on the GPU) was correct, --pcie-frac 0 (misses on the CPU)
was wrong with ggml's plain dot products, with one pool worker and on the
IQ3 file alike.

ExpertPool::run_split_multi_native split its gate/up and down phases over
FF (640) and H (2560) rows per expert, the canonical Q2_0 pack's widths
compiled into expert.hpp, while a native layer's NativeFmt carries its own
n_ff / n_embd (512 / 2048 here): the down phase wrote 512 rows past every
output row into the next token's, the gate/up phase read 128 rows past
each expert's block.  The phases now take the layer's widths; native_fmt
refuses a layer wider than the pool's SplitBufMulti buffers (H x FF).

tests/core/pool_native_widths_test: three Q8_0 experts at 2048 x 512, four
tokens, the pool's rows against the kernels called directly, bitwise
equal, and a guard after every output row.  It fails on the old row
counts (the guard) and passes now.  After the fix on VM 221: Q4 at 8K with
forced CPU misses 328 tok/s correct, Q4 at 262,144 by default 322 tok/s
correct, IQ3 at 262,144 under --vram-cap 11264 (5,762 slots, 56%) correct
at 169 tok/s; the Qwen3.6 and native-expert ctest subset 32 of 32.

The front end reported every model as "qwen3.8-flash-next-iq3_xxs"; the
id is now the GGUF's base name without a shard suffix.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
2026-10-12 19:42:41 -07: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 3a806b5af2 serve: the conversation checkpoint and snapshot carry a dense, plain-residual model; draft_vocab.bin optional
The first request through the HTTP front end on the 4090 generated 220
tokens and then failed with "saving a conversation checkpoint failed":
conversation_state.cpp rejected Qwen3.6's geometry key (idx_q_heads,
idx_key_dim and hc_lr are 0 without an indexer and without
hyper-connections), demanded the indexer's tail, dead-row, block-position
and pooled buffers per attention layer, and sized a block position per
layer; conversation_snapshot.cpp's K/V layout refused idx_key_dim 0.  Those
zeros are now the geometry: the key check allows them where has_indexer()
is false (hc_lr where hc is 1), the running-state targets keep only the
cell bound for dense attention, the block position and pooled rows are 0
without an indexer.  Verified on VM 221 at 262,144 context with the IQ3
pack: a two-turn conversation saves 1 then 2 checkpoints and the second
prompt reuses its prefix (27 of 278 tokens; the reuse granularity is a
step-5 measurement), 319 and 359 tok/s decode.

The front end required draft_vocab.bin in the --mtp directory; a Qwen3.6
draft pack built with the full head has none and the engine already treats
the file as optional, so the front end does too.

qwen36_verify_test: the 40-position argmax gate skips near ties, both where
the F32 and Q8 oracles disagree and where the Q8 oracle's top-two margin
is below the engine row's own rel L2 error (position 4 of the fixture
flips between runs on the 4090 with a 0.4% margin under a 1.4% row error).
35 of 35 discriminating positions agree; the ties are reported with their
margins.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
2026-10-12 19:23:09 -07:00
Robert KarlandClaude Fable 5.1 85d5d1234f 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 18:31:26 -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 84794ce79b frontend: /health's last tier reading under its own mutex
last_stats was written under engine.mu and read without it on the busy branch; httplib serves /health from
several threads (review finding 4).  A dedicated mutex guards it and every reader takes a copy under it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
2026-10-11 11:20:30 -07:00
Robert KarlandClaude Fable 5.1 8b7525e705 frontend: the Engine's STATS command covered by engine_test (reply by prefix, ERR as the error, the next request unharmed)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
2026-10-11 09:59:41 -07:00
Robert KarlandClaude Fable 5.1 a44b0953f2 Qwen3.6 step 2: --vram-cap / --ram-cap, the Qwen3.6 plan and gate, PLE optional at the CLI, the STATS command and /health tiers
generate.cpp: every cudaMemGetInfo the planners read goes through vram_info, which clamps the free
figure to cap - used under --vram-cap MIB; a blocker of total - cap is allocated before the weight
arena.  --ram-cap GIB bounds the RAM tier (host_available_memory is clamped, the resident budget
too) and the pinned arena.  A model whose architecture has no per-layer token embedding starts
without --ple-gguf (no PLE kernels selected, and session.cpp carves no PLE history for it).  For a
qwen35moe file the start reads the geometry, checks the pack's layout against it, makes the 4.2
plan from this card's free VRAM and the file's own census (non-expert weights, the draft block,
KV per token in the chosen format, the session, the reserve, the prompt buffers unless prefill
borrows), prints the three tiers, and stops at the step 2 gate naming the steps not done.  The
serve loop answers STATS with one JSON line: experts, VRAM slots and how many hold an expert, RAM
copies, mapped experts, tokens served, VRAM hits of lookups, RAM-copy and file reads, warm hints,
and the major page faults since start (the disk-read proxy); the same line is logged at start.

frontend: /health carries that line as "tiers" (the last reading, marked stale, during a request);
--vram-cap and --ram-cap pass through; a one-file model needs no second shard.  Makefile: any
CUDA_ARCHS entry below 75 switches STRATA_EXPERIMENTAL_SM60 on (make build CUDA_ARCHS=61).

Not compiled yet: the CUDA translation units need the VM (its sweep is running); this commit is
checked on the VM in the Pascal build commit that follows.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
2026-10-11 09:56:49 -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