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
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
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
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
Both commit graphs restored every attention layer's indexer key tail and
re-appended the accepted keys, which needs blk.N.indexer.k_norm.weight: the
first Qwen3.6 window on the real pack stopped there ("blk.3.indexer.k_norm.weight
is missing") after the window itself had run. A dense model has no tail to
restore; its K/V cells past the accepted prefix are overwritten when those
positions run again, as the header says.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
The qwen35moe start no longer stops after the VRAM plan: it proceeds through
the native pack's load order (pack_load_check's, with check_all after the
dense projections, which generate never called), the session at hc = 1 with
no PLE and no indexer, the expert tiers the plan sized, the prompt path and
the decode windows. The drafter is not wired yet (qwen36-step4-drafter):
without --mtp the windows hold one token each (a window padded with token 0
verified a draft nobody made), and --spec below 2 becomes the verifier's
smallest window instead of the native pack's refusal.
--teacher-force (with --spec-oracle FILE) holds the engine to a reference
continuation position by position: every window row commits, the next window
starts from the oracle's token, --dump-logits writes one row of head logits
per position (the window path wrote none), and the run reports the top-1
agreement. That is how the real files are compared with llama.cpp's greedy
text (docs/qwen36-port/step4-runner.md).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
Flash-Next keeps the canonical MTP head's geometry (512 experts); Qwen3.6's drafter is the -MTP file's nextn block,
cut for the trunk it serves, and MtpDrafter::load refuses a mismatch by name.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
Prefill::draft_kv takes the nextn block too: the prompt's cells through this path's GEMMs (MMQ q8_1 x the pack's
native type, else the FP16 GEMM) in the drafter's own order, rows of 64 and up as for Flash-Next.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
A second path chosen by the geometry's architecture: concat(rms_norm(emb) * enorm, rms_norm(h) * hnorm) through
eh_proj, one plain attention + MoE block over the drafter's own dense KV (the routed experts through the native GPU
expert kernels on the resident blobs, the gated shared expert), shared_head_norm, the main head. h is the trunk's
output-normed hidden state, so the drafter applies output_norm to the residual rows it is handed, as llama.cpp's
h_nextn. The pack is checked against the trunk's geometry by name. debug_row runs one row outside any graph and
hands every seam to the harness by llama.cpp's cb() names, with the rival readings as its negative controls. The
Flash-Next path is untouched.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
A -MTP file's draft block (blk.40) carries the attention and shared-expert projection names; it is the drafter's,
not in the trunk's pack, and NativeDense::load would refuse it as absent from the canonical table. The bound is a
no-op for Flash-Next (no block past the trunk).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
Qwen3.6's attention is dense: the file and the pack have no indexer.q_proj / k_proj / q_norm / k_norm, and
qsa_layer and the verify window ask for them only under g.has_indexer() (step3-attn.md); the shape check demanded
them of every attention layer at hc = 1 (idx_q_heads 0: a 2048 x 0 tensor by name) and would have refused every
Qwen3.6 pack.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
The MTP drafter's ring runs qsa_decode_attn_batch at its --mtp-window (32,768 by default: 512 blocks), so the 128-block cap had moved Flash-Next's drafter onto the online-rescale kernel with another summation order and a smaller scratch. qsa_decode_attn_chunks(cap, s) and the scratch take the shape: sparse keeps ceil(cap / 64) blocks and the old formula, dense is bounded at 128; below sm_75 every sparse shape runs the single-chunk kernel, so Flash-Next's path is the previous kernel, grid and scratch bit for bit at every capacity. The test holds sparse 32,768 -> 512 blocks and the old scratch; the notes state the drafter's case.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
verify.cpp's and mtp.cpp's hand-written builders copied the geometry's two zeros and kept qsa_real_shapes()'s idx_top_k 2048, a shape that was neither sparse nor dense: qsa_dense said dense, the kernels' guard said "not set up" and exited at the window's first kv_append. The builder is now one inline function used by layer, verify and mtp (session and prefill follow in [shared] commits), qsa_dense tests all three widths, and qsa_shapes_valid (non-exiting, what validate() prints and exits on) refuses a half-set shape by name. The parity test builds the shape through the builder for a qwen35moe and a qwen4exp geometry and holds the half-set one as the negative.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
GPU against the float reference: 2e-2 (oracle-crosscheck.md: the Q8 oracle's ffn_moe_out max 5.3e-3 with the 4x
margin; Qwen3.6's five pairs measure 9.7e-3 to 1.3e-2), 3e-2 only for a pair with a Q5_0 role (q4_K/q5_0 measures
2.7e-2 at 2560 x 640, the pair the CMake note already describes). CPU against the reference stays at 3e-2: ggml-cpu
rounds the activations to Q8_K, one scale per 256 values against the GPU's q8_1 per 32 (measured up to 2.2e-2).
CPU against GPU, printed but never gated before, gets 4e-2 (both roundings, measured up to 2.4e-2). Each line prints
its bound. RTX 4090: 15 of 15 ctests, both real files at layers 0 / 34 / 39, q4_K/q5_0 and q5_0/q8_0 pass.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
GdnGeom::gate is kernels::GdnGate (the GDN branch's enum, cherry-picked with
its geometry accessor); Geom::of reads g.gdn_gate(), so the prompt path and
the decode path pick the gate from the same place. 4090: gdn_rec_parity,
gdn_parity and both harness cases pass.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
The attention layer of a model without an indexer takes the cherry-picked
kernels as the attention branch defines them: the shapes zero the three indexer
widths (qsa_dense), the capacity is qsa_selection_cap (every cell), no ids are
carved or passed (a null is the identity), the group G comes from the geometry
and any other ratio is refused by name before a launch. The own dense_ids
kernel goes (qsa_identity_ids is the explicit form). A model with no attention
layer at all (the harness's gdn3 fixture) has no primary attention state: the
reads of it are guarded. STRATA_PREFILL_ALLOC_TRACE=1 names the allocation
that did not fit.
tests/python/qwen36_prefill_fixture.py writes the synthetic model at the real
per-layer widths (gdn3: three DeltaNet layers; full4: plus the attention layer;
Q8_0 projections and experts, BF16-exact routers) and the oracle's dumps for 40
tokens, faithful, --act-quant q8, and the rival readings.
tests/cuda/prefill_qwen36_test.cpp runs the prompt path on them as one chunk
and in chunks of 7 with every layer's input teacher-forced to the oracle's
l_out, holds each seam to the dumps, checks the router's top-k, the negative
controls and the geometry refusals; CTest: prefill_qwen36_fixtures,
prefill_qwen36_test, prefill_qwen36_attn_test.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
The copied kernel variants become templates on <HV, HK, C>; the bit checks run
at 48/16/10240 and 32/16/8192. New: a double-precision transcription of the
recurrence (decay before the rank-1 update, v-head h paired with k-head h % HK,
the gated RMS-normed output) that the engine's own gdn_recurrence and gdn_conv
are held to (FP16 output 2e-3, FP32 state 1e-4 relative L1), with the rival
readings the oracle names - the other model's gate, the interleaved pairing -
required to sit more than 5 % away; and the geometry refusals (a third value
head per key head on 32 heads, 4 per key head). Links strata_prefill.
4090 (sm_89): 0 failures; the rivals 0.86 to 1.33 relative L1 away.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
The file-wide constants N, HC, D, LR, K, NE, C, ZV, HV become a Geom built from
the ModelGeometry (Geom::of), used by every buffer count and launch; init
accepts Flash-Next's geometry as before and qwen35moe at hc 1 with the GDN
geometries the kernels are built for, and refuses top-k beyond n_expert. At
hc 1 the layer loop is x = rms_norm(R, attn_norm) -> mixer -> R += out;
x = rms_norm(R, post_attention_norm) -> MoE -> R += out, with none of the
hyper-connection buffers carved. The attention layer of a model without an
indexer skips the indexer and writes the dense selection (cap = max_cells,
behind a TODO for the attention branch's bounded scratch); the G = 12 kernels
refuse 16 heads, so that layer returns an error until the G = 8 kernels land.
The MTP draft_kv pass stays Flash-Next's (step 4). on_seam: a test's view of
the layer loop by llama.cpp's seam names, and its teacher-forcing seam (l_in).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
GU_ROWS_K 2560 / D_ROWS_K 640 and the 1280 / 2560 weight-row counts become the
geometry's n_embd / n_ff (2048 / 512 for Qwen3.6), loop bounds rather than
constants; a width that does not tile the work item is refused by name.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
The GDN kernels (gates, conv, l2, the three recurrences, the output norm) become
templates on <HV, HK, C> with the output gate (sigmoid for Flash-Next, SiLU for
Qwen3.6) a bool parameter, dispatched from a GdnGeom through gdn_dispatch at the
two geometries 48/16/10240 and 32/16/8192 (any other stops the process, and
gdn_geometry_supported lets Prefill::init refuse it first). route() takes k,
moe_combine the width and k, the SwiGLU kernels n_ff, split_q and gate_attn
n_head. New: rms_norm_images and residual_add (the plain block at hc = 1),
dense_ids (every cell up to the query's own, for the dense model).
Study section 3.6 and 6 (step 3, the prefill bullet).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
qsa_kv_streaming_applies (the attention branch) is called right after the geometry is read, so a Qwen3.6 start
with --kv-resident fails with the reason instead of reaching qsa_state_init's backstop.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
On sm_61 the looped kernel costs 16-28 registers over PR #540's body (80-92 at G 12 against 63-64) and 13-17% on the Q4_0 pool at short widths; a register cap spilled and cost every format more. So a capacity under kMaxChunks x 64 runs attn_chunk_kernel_pre75_single, the old body with G and the null-ids identity: every Flash-Next state (cap 2,051) is the old kernel to the instruction (interleaved A/B on the 1080 Ti: 42.0 vs 41.0-41.7 us fp16, 38.9 vs 38.9 INT8, 40.8 vs 41.0 Q4_0), and the looped form runs only for the dense model's long-context states, where it is ahead (419 vs 493 us at 32,768). The notes carry the layout, the harness, the tolerances and both cards' numbers.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
qsa.cu's geometry guard demanded indexer widths; a dense shape (idx_n_head, idx_dim, idx_top_k all 0) passes it for the KV, gather, attend and gate kernels, and the indexer's own entry points refuse it by name (validate_indexer). The MMA prompt kernels wrote accumulator rows 0..7 unconditionally, which at G = 2 overwrote the next KV head's output; the rows are guarded by G. The scratch bound is 528,448 floats (2.02 MiB) at 16 heads, not the 2,080,832 the first wording said.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
qsa_prompt_attn_batch refuses cc < 70 by design (no mma.sync) and prefill takes the batched decode kernel there, which case [4/4] already holds to the same reference; the Pascal pass counted that refusal as a failure.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
The fixtures (cmake/qwen36_attn_fixtures.cmake) are the synthetic qwen35moe GGUFs at head_dim 256 for 16/2, 24/2 and 4/2 with ref/qwen36.py's dumps on 40 tokens; the test runs the dumped q/k/v through the engine's norm, RoPE table, fp16 append, decode kernel and gate and holds them to Qcur-3, Kcur-3#2, kq_soft_max-3, kqv-3, attn_gated-3. Negatives: the gate skipped, adjacent-pair RoPE, the GQA map h % n_kv, G = 12 on 16 heads, the sparse width 2,051 on 3,000 cells. qsa_attn_bench uses only the pre-step-3 entry points so it builds against the old kernel too.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
The dense geometry needs no indexer tensors, raw keys, scores or top-k per row: the batched split-K kernel reads every cell with a null ids and each row's own width; cap is the state's max_cells; the scores and selection buffers are not carved.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
For a geometry without an indexer (has_indexer() false) the shapes carry idx_n_head 0 (the kernels' dense signal), the state's pooled rows are the ring's 2 (0 bytes at idx_dim 0), the buffers carve no cell scores, no ids and no gather scratch (1 + 1 + 512 MiB at 262,144 cells), and qsa_layer skips the raw key, the append, the indexer query, the scores and the top-k: the split-K kernel reads every cell with a null ids. The gather path and the short flash adapter are refused for the dense model (sized for 2,051 and 256 cells). KV streaming does not apply to dense attention (every block resident every token): qsa_kv_streaming_applies says why for the CLI, and qsa_state_init refuses as the backstop.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
The MMA tiles are 16 query rows, so every G <= 16 pads with zero rows as 12 did; the host picks G from the geometry and falls back to the decode kernel (which refuses by name) for any other ratio.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
The decode kernel gathers through ids and the page table, so dense attention (no indexer) is the identity selection: a null ids is it, with the width n_kv from the step (qsa_dense: idx_n_head == 0; qsa_selection_width returns n_kv, qsa_selection_cap the state's max_cells instead of the 2,051 every caller spelled out). G, the query heads per KV head, was a literal 12; it is a template parameter now, picked by qsa_attn_group from the geometry and refused by name for any other ratio (qsa_attn_group_check: G = 12 asked of 16 heads is a message, not a mis-indexed run). The split-K partials grew with the capacity (64.5 MiB per query row at 262,144 cells): the grid is capped at 128 blocks per KV head and a block walks its span in 64-cell sub-chunks with the running (m, l, acc) rescale; the span comes from the token's width on the device, so up to 8,192 cells it is the old grid and the old arithmetic bit for bit.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
The sign flip of one 32-value block in a 640-wide down row moved the row by 8e-3 to 1.4e-2 relative on the RTX 4090
(one of 20 blocks), under the 1e-2 the brief states for Qwen3.6's 256-value blocks of a 512-wide row. The gate is
now 1e-2 x (block values / 256) x (512 / n_ff), printed with the measurement; the locality half (no other row moves
by any bit) is unchanged. The corrupted blob is copied back before the decode-once and dequantizer checks, which
read the device blob (they compared the corrupted gate row and failed every pair).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
The grouped down kernels were generic in Fmt<T> but STRATA_D_FMTS listed only the 32- and 64-value types plus IQ4_XS,
so native_expert_supported refused every layer of both Qwen3.6 files: UD-IQ3_XXS's IQ3_XXS down (37 layers) and
UD-Q4_K_XL's Q5_K (37) and Q6_K (34, 38, 39). IQ3_XXS and Q5_K join the down list; Q6_K gets llama.cpp's
vec_dot_q6_K_q8_1 (VDR 1, dp4a) and dequantize_q6_K transcribed, Fmt<14>, and a place on all three lists plus is_iq
and iq_row_bytes (the prompt path's fp16 dequantizer). A 256-value down type needs n_ff % 256 == 0, which
native_expert_supported already checks: Qwen3.6's 512 passes, Flash-Next's 640 is still refused.
Harness: native_expert_parity takes --geom HxFF and gains the negative control (e): the sign byte of one block's fp16
scale flipped in one down row must move that row's GPU output by more than 1e-2 relative and no other row by any
bit, and the same in one gate row must move the output by more than 1e-4. Five Qwen3.6 pairs run as ctests at
2048x512, q6_K/q8_0 at 2560x640, and q4_K/q6_K at 2560x640 is the refusal (WILL_FAIL). native_grouped_parity adds
Q6_K and the three down types to its bitwise v1 sweep, the five pairs at 2048x512, and --bench-down (the down kernel
alone per expert, the step-5 budget). iq_multi_parity adds the IQ3_XXS down pair at 1024x512.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
llama.cpp's MMQ has a Q6_K tile (mmq-instance-q6_k.cu); it joins the K-quant list beside Q4_K, Q5_K and Q5_1 so a
prompt through the Q4_K_XL file's three Q6_K layers takes the int8 tiles rather than the fp16 GEMM over
dequantized weights. The screen test adds Q5_K and Q6_K down products at the model's 2048 x 512; its "not covered"
negative moves from Q6_K to Q3_K. Type tables only; the prefill geometry is the prefill agent's.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
The router harness runs its five fixtures at both 512/10 and 256/8 (random, all-equal,
12-way tie wider than k, a tie of exactly k scattered through the range, dominant expert)
and asserts the 2^-14 clamp unreachable at both (8/256 is 512x the clamp).
The shared-expert harness adds Qwen3.6's shape: 2048 x 512, Q8_0 projections through
native_mmvq with Q8_1 activations and the native BF16 scalar gate, against a host reference
written from the block layouts (9.6e-8 relative); the silu-on-up reading and the skipped
gate as negatives (83%, 272%); shared_expert_multi bitwise the per-token call; and the
output moved by rounding the F32 gate weight to BF16 reported (2.5e-4), not asserted.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
cmake/qwen36_oracle_dumps.cmake writes k.gguf (2 k-heads / 4 v-heads of 128, 256 experts
top-8, shared expert 512 in Q8_0, BF16-exact gate weights) and runs ref/qwen36.py on the
11-token "hello world" sequence in F32 and --act-quant q8 modes; qwen36_seam_parity reads the
fixture and the dumps and holds, by llama.cpp's cb() names:
- conv_output_silu-0, new_state-0, final_output-0 through the legacy, pinned native and
fused decode paths token by token with the state carried, and through the verify window's
multi-token kernels over two windows (8 + 3) with commits; the fused path also at
q/k_conv_predelta-0, gate-0, beta_sigmoid-0. Worst 2.3e-7 against 8e-5 (gdn_out class).
- ffn_moe_topk-0 identical and ffn_moe_weights_norm-0 at 6e-8 from the oracle's logits.
- ffn_shexp_gated-0 on the native Q8_0 path with the 1-D BF16 scalar gate at 3.5e-7 against
the Q8 oracle (1.2e-2 against the F32 oracle: the activation rounding); shared_expert_multi
bitwise the per-token call.
Negatives through the kernels: the sigmoid gate (126% at final_output-0), the un-normalised
router weights (24%), the shared gate skipped (52%). Exits 77 without the fixture.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
`ModelGeometry::gdn_gate()` is SiLU for qwen35moe and sigmoid for qwen4exp, decided by the
architecture like `hc` and the indexer. layer.cpp's three output-norm calls and verify.cpp's
four `gdn_step_norm_multi` calls pass it; nothing else in either file changes. The
parameter is required (no default) so a call site the block agent rewrites cannot silently
keep sigmoid for Qwen3.6.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
Qwen3.6 closes the GDN layer with rms_norm(o) * ssm_norm * SiLU(z) where Flash-Next uses
sigmoid(z) (study 3.2, inventory row 39; the oracle's negative control puts the two 1.07
relative L1 apart). `kernels::GdnGate` names the choice and every decode output kernel
takes it as an argument: `gdn_out_norm` (legacy), `fused_gdn_step_norm` (the default native
decode), `native_gdn_out_norm` (pinned unfused), and the verify window's
`gdn_step_norm_multi`, which must stay bitwise the fused kernel. The sigmoid arithmetic is
unchanged; SiLU is ggml's op_silu form z / (1 + exp(-z)). No global: the layer passes
`ModelGeometry::gdn_gate()` (next commit).
gdn_parity now runs the recurrence at both geometries, 16/48 (VPK 3, sigmoid) and 16/32
(VPK 2, SiLU), through all four implementations, checks the verify kernel bitwise against
the fused one (verify, commit and split-commit paths), and makes the wrong gate a negative
case through each kernel itself (86-125% apart), beside the existing four traps. The
harness uses a blocking stream: its first version raced its own pageable memcpy resets on
a non-blocking stream and reported the native kernels 7.5x off at one geometry.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
Verifier::record_window branches on g.hc == 1 in pre (plain_norm_rows for attn_norm, the residual add then
plain_norm_rows for post_attention_norm over the group's rows), post (R += ffn out in place, then the control
vector) and the head (output_norm over the T rows; the canonical head goes through lm_head, which branches the
same way). The hc_* tensors are resolved only at hc > 1, no pending write is folded, STRATA_FUSE_HEAD_GR
applies only there, and a wired PLE is refused. The init refusal `ss.k == 10 && fused_gr_supported && ...`
becomes verify_geometry_supported(g, k, why): the fused GR shape only at hc > 1, k == expert_used_count from
the file (8 for Qwen3.6, 10 for Flash-Next), state 128 / conv 4; a free function so the negative case
(top-10 on an 8-expert file) is a unit test and the message names both numbers. Rows 141, 142.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
check_one demanded the eight hyper-connection tensors on every layer (row 22); a qwen35moe pack has none and
carries the two plain norms instead, which the block reads as const float* and so must be engine form F32.
At hc > 1 the two plain names are skipped. The indexer rows are left to the attention branch.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
`ModelGeometry::hc == 1` (qwen35moe) selects llama.cpp's pre-norm residual block in block_layer_pre /
block_layer_post / lm_head_mix: rms_norm(R) * attn_norm -> mixer -> R += out -> rms_norm(R) *
post_attention_norm -> MoE -> R += out, head rms_norm(R) * output_norm. Two row-count helpers
(plain_norm_rows, plain_residual_rows) carry it, so the verify window's T-row calls are the single-token
kernels per row by construction. No pending write: the add is applied where the reference adds it. The
GR kernels are never entered at hc = 1 (one stream through gr_read is not a plain norm: the harness shows
it). layer_verify_compatible gains a geometry overload that drops the fused-GR and indexer requirements
where the model has neither; the no-argument form keeps its Flash-Next meaning.
docs/QWEN36-35B-A3B.md section 3.5; geometry-inventory.md rows 4, 22, 23.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
On the 1080 Ti both real files never reached the step 2 gate: generate.cpp checked native_expert_supported()
per layer right after the layout load, and the grouped kernels' down types (STRATA_D_FMTS: IQ4_NL, IQ4_XS,
Q5_0, Q5_1, Q8_0) do not include IQ3_XXS (the IQ3_XXS file, 37 layers), Q5_K or Q6_K (the Q4_K_XL file):
strata generate: layer 0's experts are IQ2_S/IQ3_XXS (ggml types 22/18), which this engine has no GPU kernels for
The gate now comes first for a qwen35moe file: the geometry, the VRAM plan, then one line per gate-up/down pair
without a kernel with its layers ("step 3 also needs GPU expert kernels for ..."), then qwen35moe_not_yet. The
whitelist loop is unchanged and still runs before anything is allocated for every other file.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
generate.cpp's two trace sites kept the literal 48 (outside 0..47) from Flash-Next; Drive carries the trunk
layer count from ModelGeometry now (review finding 6). tools/make_profile.py's N_LAYER = 48 is step 4's
(docs/qwen36-port/step2-notes.md).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
With --ram-cap and the automatic --resident-experts the line set resident_budget = cap, which flipped
pin_cache_complement into explicit-budget mode (lending off, the file tier unbuffered, the budget warning on
every run; review finding 3). The automatic path is bounded by set_host_ram_cap's clamp of
host_available_memory already; only a budget the user gave above the cap is lowered to it.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
in.budget_bytes is cudaMemGetInfo's free figure, read after this process's context exists, and the engine
subtracted a 300 MiB context on top of it: ~290 (IQ3) / ~160 (Q4) expert slots under table 4.3 (review
finding 2). The engine passes 0; vram_plan_test keeps the study's 300 MiB because its budgets are the cards'
sizes. Said in vram_plan.hpp's field comment.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
vram_info computed used = total - free after the blocker of total - cap had been allocated, so the blocker
was in `used` AND already out of `free`: room = cap - used = 2*cap - total - used_other, negative at
--vram-cap 5722 on the 1080 Ti and ~4,800 instead of ~7,900 MiB at 8192 (review finding 1). The blocker's
bytes are remembered and taken out of `used`. The cap line now also prints what a card of the cap would show
free (cap - used_before), and the start refuses if the clamped figure is above it or more than 64 MiB below
(the driver rounds the blocker up by a few MiB).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr