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
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
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
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 Qwen3.6 prefill harness (tests/cuda/prefill_qwen36_test) runs the prompt
path on a synthetic GGUF with no pack directory: it uploads the tensors itself
and needs to hand the WeightRefs to the table. One public inserter; nothing
else changes.
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.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
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 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 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
`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
`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
read_model_geometry left n_vocab at Flash-Next's 248,320 on every file while generate.cpp samples over
output.weight's rows and loads the native embedding with g.n_vocab (the synthetic fixture has 128). The reader
now takes the vocabulary from whichever of output.weight's ne1, token_embd.weight's ne1 and
tokenizer.ggml.tokens' length the metadata shard carries (the array's `count`: the reader caps `items` at 64),
refuses when two disagree naming both ("output.weight says 100 tokens but token_embd.weight says 128"), and
keeps the default only when none is present (the metadata-only fixtures). model_geometry_text prints it.
model_geometry_test: toy.gguf reads 128; the real IQ3_XXS file 248,320 (so the default was right for the shipped
files; the Mac's Flash-Next Q2 file also 248,320); the disagreeing fixture is refused and output.weight alone sets 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
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
strata/plan/vram_plan.hpp: the 4.2 rule with no GPU in it - the fixed set at the requested context
(weights, drafter, KV per token, session, CUDA context, reserve, prompt buffers unless prefill
borrows), the context lowered toward 131,072 in steps of 4,096 when it does not fit, a refusal with
every number and the smaller file's name below the floor, the remainder as expert slots at the mean
blob, the RAM tier from the available RAM minus a headroom, the rest mapped from the file.
tests/core/vram_plan_test.cpp reproduces table 4.3 of docs/QWEN36-35B-A3B.md for 6, 8, 11 (decimal
and the 1080 Ti's 11,264 MiB), 12, 16, 24 and 32 GB at Q4 and IQ3, with and without borrowing: every
row equals floor((budget - fixed) / blob) exactly and is within the table's rounding of the printed
figure; the 24 GB spare (~1,090 MiB), the RAM tier at 9.5 GB (~4,950 / ~8,760), the disk tier on the
1080 Ti (~1,740 / ~2,780), the lowering branch, the refusal at 6 GB Q4 without borrowing.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
expert_layout_load(pack, n_layers, n_expert, n_embd, n_ff, err): each layer's NativeFmt is built with
the model file's widths instead of the compile-time 2560/640 (geometry-inventory.md row 108), and a
pack without native_experts.txt (the canonical Q2_0 form) is refused for any other geometry.
generate.cpp reads ModelGeometry from the --native file before the layout load, logs it for a
non-Flash-Next file, refuses the fused tensor forms by name, takes the router k and the embedding
dims from it, and reads the rope keys under the file's own architecture prefix.
tools/iq_pack.py: --layout-only writes native_experts.txt alone and prints the census; the draft
(nextn) block of an -MTP file is left out of the trunk layout; fused ffn_gate_up_exps refused;
FORM carries qwen35moe's attn_norm / post_attention_norm / output_norm (F32 as stored).
tests/data/native_experts/qwen36-{iq3_xxs,q4_k_xl}.txt from the real files (40 x 256; 10,594 and
18,726 MiB, mean blobs 1.035 and 1.829 MiB, as censused in docs/QWEN36-35B-A3B.md), and
expert_layout_test loads them at 2048 x 512 with every layer's types (IQ4_XS down on 34/38/39;
Q6_K down on 34/38/39, Q5_K gate/up on 39) and sees them refused at 2560 x 640.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
ModelGeometry gains the architecture, the draft block count, n_rot / rope sections / base / eps, the
shared-expert width, the router k and has_ple; derive() computes the conv channels and the value dim
from the head counts instead of storing Flash-Next's. strata/core/model_geometry.hpp reads every
field from the <arch>.* keys (hc = 1, no PLE, no indexer for qwen35moe), checks the derived quantities
against the file's own (ssm.inner_size), refuses the fused ffn_gate_up_exps and attention attn_qkv
forms by tensor name, and carries the step 2 gate message. check_architecture accepts qwen35moe with
the key set llama.cpp's loader requires (presence only; the file is the authority on sizes).
tests/core/model_geometry_test.cpp: every field of the toy geometry from tools/qwen36_synth_gguf.py,
the nextn block subtracted, both fused forms refused by name, a qwen4exp file keeping hc 4 and PLE,
'llama' refused by name, a contradictory ssm.inner_size refused; --real FILE asserts the real
Qwen3.6-35B-A3B values (checked on the IQ3_XXS and Q4_K_XL files).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
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>
Source: https://github.com/Niko1221/Strata, commit 6f32ec070f23ced9f50e704d854d775da52591ab
(engine 0.1.39, MIT). Every file is as upstream published it; later commits
show exactly what this fork changes.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>