Commit Graph
20 Commits
Author SHA1 Message Date
lotherk 7505a9d102 Front end: a hard thinking cap (--reasoning-budget-tokens / reasoning_budget_tokens)
Port upstream Strata's reasoning_budget_tokens to this fork's front end: when the thinking reaches the budget it is closed with a configurable message and the template's end-of-thinking tag, and the engine is asked again with prompt + generated + wrap-up, continuing from the prefix it already holds. Off unless thinking is on and a budget is set (a request's own value wins over the command line). The wrap-up tokens are charged to the response so the context fit is unchanged; usage reports completion_tokens_details.reasoning_tokens. --reasoning-budget-message sets the wrap-up wording (default: upstream's own line).
2026-10-14 07:31:17 +01:00
lotherk 81b2ad128d Merge upstream/main: the Qwen3.6-35B-A3B port (steps 2-5)
Brings in 139 upstream commits: the Qwen3.6-35B-A3B model (ModelGeometry from the file's own metadata, native experts IQ3_XXS/Q5_K/Q6_K, dense split-K attention, the GDN gate per model, the MTP drafter, native packs through the verify window), the VRAM/RAM planner with --vram-cap/--ram-cap, the fat-binary CUDA build, and the front-end fixes (content streaming, preserve_thinking, the engine's actual context, /health tiers).

Conflicts resolved:
- Makefile: kept upstream's CUDA_ARCHS default and the drop-unsupported-arch logic (fixes the compute_120 build on this toolkit) and kept the local PASCAL=1 override.
- README.md: kept both the local --fit-max-tokens row and upstream's engine-flag row.
- frontend/main.cpp: kept the local --fit-max-tokens option beside upstream's --vram-cap/--ram-cap.
2026-10-14 07:14:48 +01: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
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 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 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