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
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
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
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
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
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>
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
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
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>
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>
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>
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>
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>
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>