The engine reports progress (PP) and tokens (T) over its stdout, but the
front end logged only the start and end of a request. A 154k-token prompt
is minutes of silence that reads as a hung request. Now a line every
STRATA_PROGRESS seconds (default 5, 0 = off): prompt processing from the
engine's own PP lines, and decoding from the token count.
cudaGraphInstantiate allocates device memory for each window size's exec and the
exec is never freed (measured ~22-26 MiB per size on a GTX 1070 Ti, 2026-10-15).
serve captured each size lazily, on the first request that used it, so that
memory came out of - and could outrun - the reserve the auto-cache had been sized
against. A serve planned down to its last ~150 MiB therefore captured the sizes
its first requests asked for and then failed the next
strata serve: verify: instantiate: out of memory
mid-request, which took the engine and the front end down with it (the container
restarted). This is not the sampler or the Qwen3.6 port: the DRY work adds ~4 KB
of device arrays and a 128 KB history row, and the lazy capture predates both.
Every size 1..max_t the serve path can ask for is now captured right after the
verifier is bound (after set_split / set_pcie_mode, which the recorded graph
depends on). That makes the cost part of what the serve free-VRAM check sees and
bounds it before any request runs: a size that does not fit is reported at
startup, naming the knobs that make room, instead of killing a request.
Seen on kontron.local: a GTX 1070 Ti (sm_61) serving Flash-Next Coder IQ1_M with
--ctx 131072 --vram-cap 7680. There the window graphs need ~135 MiB and the plan
left 135 MiB free; --vram-reserve-mib 700 (which skips #496's lowering to 300)
leaves ~630 MiB and all six fit. The cap itself is honoured: the blocker held
back the 424 MiB it should.
The sampler chain gains llama.cpp's dry stage (penalties -> DRY -> top_k -> ...): a token that would extend a
repeat longer than dry_allowed_length over the last dry_penalty_last_n history tokens loses
dry_multiplier * dry_base^(repeat - allowed_length), with tokenized restart sequences capping the scan.
- kernels/cuda/sampler.cu: dry_window/dry_build/apply_dry in the greedy, old, one-block, split and coupled
penalize kernels; the DRY window is the same history row the penalties count, clamped to kDryWindowCap=512;
the membership bitmap spans the wider of the two windows and gates both. Off (the default) the neutral path
is unchanged: shmem 0, the cluster argmax still runs, the parity fixtures pin every path against a host
reference (sampler_parity, 19 fixtures).
- include/strata/kernels/sampler.hpp: the dry_* fields, DryBreakers (device flat/off), dry_enabled.
- verify / mtp: Verifier::set_breakers and MtpDrafter::set_draft_breakers thread the tokenized breakers to the
head sampling and the captured coupled-draft graph (stable device arrays).
- generate.cpp (engine): dry_multiplier / dry_base / dry_allowed_length / dry_penalty_last_n / dry_breakers GEN
keys; the breaker arrays are allocated once at the cap on the head device, the request refills them; a
DRY-only request still stages history (the wider of the two windows).
- front end: --dry-multiplier / --dry-base / --dry-allowed-length / --dry-penalty-last-n / --dry-breakers
defaults and dry_* / dry_sequence_breakers request fields; the front end tokenizes the restart sequences
(the engine has no tokenizer) and sends them as ids. The defaults are llama.cpp's: multiplier 0.8, base
1.75, allowed length 2, window 256, breakers newline, colon, quote, asterisk when unset.
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).
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.
The branch took f07b81e from main but not 121d23a, so a build of the branch
answered 500 "prompt (N tokens) + max_new (M) exceeds the context" to every
request without max_tokens, and to any with max_tokens at or above
context - prompt - 7, on Flash-Next and on Qwen3.6 alike. The hunk in
frontend/main.cpp is main's, unchanged.
tests/python/serve_max_tokens_check.py (make test-serve PORT=...) sends five
such requests to a running server: 0 of 5 before, 5 of 5 after, on
Flash-Next at 196,608 and on Qwen3.6 Q4_K_XL at 262,144 (RTX 4090).
REGINA-112.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
No engine change. The '2000, DMA' runs were not GPU-only: the window stages
16 blobs and the rest of a layer's misses run on the CPU. Without overflow
the 1080 Ti's GPU path gives the same bytes at either cache size, as the 4090
does. llama.cpp on a second back end misses the rule against its own 4090
run on both fixtures; against the F32 oracle the engine is inside it on both
cards.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
Multi-stage Dockerfile: build (nvidia/cuda 12.8.1 devel, PASCAL=1) then a
runtime stage (nvidia/cuda 12.8.1 runtime), one binary (build/unbiased-strata),
a /health check. examples/compose/p40.yml shows a one-card Tesla P40 service
with the model, pack and MTP mounted read-only.
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).
Compiles CMAKE_CUDA_ARCHITECTURES=61 and passes -DSTRATA_EXPERIMENTAL_SM60=ON,
with an early error when nvcc is 13+ (which dropped sm_60/sm_70). Default
build is unchanged.
Two causes, both a choice between numerically different correct paths: a missed expert computed on the CPU
against the same expert on the GPU once the adaptive tier has brought it in, and a prompt state built by the
verify windows against the batched prompt path. Every single-path configuration repeats bit for bit; every
state scored against llama.cpp teacher-forced along its own tokens passes the rule.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
STRATA_SERVE_LOGIT_TRACE=FILE writes, per emitted token, the head's five largest logits, the window's shape and
the experts it missed; STRATA_SERVE_LOGIT_DUMP=PREFIX the whole row per request. Off by default; with neither
set the final binary gives the tokens of the one before it on the same request sequence.
tools/qwen36_teacher_llama.cpp: --prompt-ids and --force-ids, so llama.cpp scores every position of a run the
engine made, with the path that run took.
--teacher-force with --mtp filled the window with the drafter's guesses and committed them as the oracle's
tokens (70 of 400 top-1 on a run that scores 394 without --mtp): refused.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
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
REGINA-106 (step5-1080ti): on the 1080 Ti host every expert miss computed
by the CPU pool degraded the logits (iq3-test20 at --expert-cache 2000
--pcie-frac 0: 51/64 top-1, mean KL 0.84; Q4 54/64, KL 0.23), DMA misses
were correct, one worker reproduced it bit for bit, --spec 1 changed it.
expert_pool_dispatch_multi (expert_source.cpp) pulled in the canonical
widths and read token t's activation at t * H (2560) and wrote its output
row at i * H, while the verify window publishes both at the layer's width
(2048): every token after the first of a group used another token's
activation and landed in another row. The dispatch now takes the width
from the layer's NativeFmt (the canonical pack keeps H), refuses a layer
the pack lacks or a width above the compiled buffers. After the fix on
VM 211 (Pascal, Zen 1): iq3-test20 / prime / psim with CPU misses 64/64,
64/64, 64/64, mean KL 1.4e-3 / 4.8e-3 / 2.0e-3; q4-test20 62/64 KL 6e-3,
q4-prime 64/64 KL 8e-4. The Codex review of 22d72e6 named this spot
(the pool test covers the pool phases, not this dispatcher).
The VRAM planner (generate.cpp), also from that review: without a
draft_vocab.bin the drafter scores with the target's head and allocates no
copy (mtp.cpp), so only its logits are charged (515 MiB returned to the
expert cache at Q4); under --kv k8v4 the drafter keeps plain INT8 K/V and
is charged as such; a context the plan lowered is now the context the
engine allocates for, said in the log.
The RAM tier: when the resident arena exceeds the host's memory limit or
available RAM (the plan's 12 GiB rung: the 4090 sweep's --ram-cap 12
points died in ArenaExpertSource), the engine takes the mapped mode with
the hottest experts copied into RAM by profile rank (--resident-experts)
itself, which is the split its plan line already assumed. The multi-GPU
expert helpers (--peer-device, --remote-expert-opt) keep the canonical
width and are refused for this model with a message.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
The README names both models and their hardware, the build's new
CUDA_ARCHS default, the Qwen3.6 serve command and engine flags, the files
with sizes and checksums (the plain Q4_K_XL file's hash is still to be
taken: QWEN36_Q4_PLAIN_SHA), the sizing rule in words with the planner's
figures per budget, what was checked on the 4090 and on the 1080 Ti, and
the known problems. UPSTREAM.md gets the pack and draft-pack commands
and every prepared file's SHA-256; the patch note says it is applied at
configure time.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
CUDA_ARCHS defaults to 61;70;75;86;89;120 (STRATA_EXPERIMENTAL_SM60 follows
from the 61 / 70 as before). The list is filtered against `nvcc
--list-gpu-arch` with a note for what is dropped, so the default builds on
CUDA 12.4 (no 120: VM 221 built 61;70;75;86;89 in 6 min 17 s at -j 14) and
on CUDA 13 (no 61 / 70) alike; without nvcc on the PATH the list is kept
as given. `make build CUDA_ARCHS=61` is unchanged.
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 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>
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
REGINA-104 (a Qwen3.6 tool call dropped when its required parameter is not
written first) was upstream's required-first rule running unpatched: the
any-argument-order patch was applied only by `make build`, and every VM tree
of the port was configured with cmake directly, on a copied submodule.
Qwen3.6's template routes to the Qwen3-Coder parser the patch covers, so
CMake now applies it when third_party/llama.cpp is configured (patch -p1 -N,
a reverse dry run first so an applied tree is a no-op; a tree the patch does
not fit fails the configure instead of building the wrong parser). Verified:
a fresh submodule checkout reports the patch applied and a second configure
says nothing; on VM 221 the rebuilt libllama-common parses `limit offset
path`, `offset path limit`, `path limit offset` and `path` on
Qwen3.6-35B-A3B-UD-IQ3_XXS.gguf (make test-chat-parser PASS).
`make build` also passes -DSTRATA_MMQ_KQUANTS=ON: the Q4_K_XL file's Q6_K
down experts take the MMQ prompt path (docs/qwen36-port/step3-experts.md),
which that option builds.
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>
The step-2 line (the draft block's weights + 16 MiB "ring KV and logits")
undercounted Qwen3.6's drafter (step4-drafter.md section 7): its K/V is the
whole context, not a ring (dense attention has no --kv-resident), in the --kv
format over its one attention layer (512 MiB fp16 / 144 MiB q4_0 at 262,144
cells); the draft head is the pack's vocabulary subset at the head's row bytes
(221 MiB on the Q8_0 head) plus 8 x n_vocab logits; the identity ids are T x
cells x 4. The planner takes them as inputs (the per-token ones lower with the
context), prints the breakdown, and counts no drafter without --mtp, which the
plan says. generate.cpp fills them from the file's census and the draft pack's
draft_vocab.bin; vram_plan_test checks the share, the derivation, the lowering
and the no-drafter line.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
What the engine now does with a Qwen3.6 pack, the hunks (file:line) in the
shared generate.cpp and verify.cpp, the three tests and their tolerances, and
the results: the window and runner tests pass on the 4090; IQ3_XXS and Q4_K_XL
teacher-force to llama.cpp at 61-64/64 top-1 with no rising drift; the step-3
parity suite is 100% of 33 after the gate lift. The 1080 Ti pass and the Q4
11 GB fit are the remaining items, blocked on the card's lock; the chat template
finding is REGINA-104.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr