12 Commits
Author SHA1 Message Date
lotherk 3de4779696 Sampler: declare the DRY fields in SamplerParams
The DRY kernel and sampler_parity.cpp already referenced dry_multiplier,
dry_base, dry_allowed_length and dry_penalty_last_n, but the struct never
declared them - the tree did not build. Adds the fields plus the
kDryWindowCap / DryBreakers / dry_enabled helpers they need.
2026-11-17 17:35:37 +00:00
Robert KarlandClaude Fable 5.1 bd2dbb92f1 Import Strata v0.2.4's DeepSeek-V4.1 engine (strata-dsv41) and the CPU kernels it needs
From Niko1221/Strata tag v0.2.4 (commit 96ca4383, 2026-10-24), unmodified: src/dsv41/ (the engine and its vendored
EXL3 / sampler / window kernels), include/strata/dsv41/, tests/dsv41/, tools/dsv41/{pack_gguf,smoke,tune}.py,
data/dsv41/ (the shipped hot-expert profiles), tools/trellis/tqenc.{cpp,hpp} (the tests' encoder),
third_party/project-maya/ (the MIT notice: the engine is a port of Project Maya's maya-ds4),
third_party/ggml/ggml-common-tq.h, docs/DEEPSEEK41.md (upstream's text, to be rewritten for this fork).

src/kernels/cpu: upstream's iq_avx2.{cpp,hpp}, iq_avx2_rows.inl, iq_avx512.{cpp,hpp} replace this fork's
(v0.1.45-poly.1) copies - they add the engine's CPU lane rows iq256x_rows / iq512x_rows and leave the main engine's
iq256_* / iq512_* as they were (upstream's statement; iq_avx2_parity is the check) - and the trellis CPU lane
tq_cpu.{hpp,cpp}, tq_avx2.cpp, tq_avx512.cpp, tq_states.hpp, tq_computed.hpp is new.  expert_layout.hpp stays at
layout version 4 (upstream's 5 adds Hadamard-folded packs this fork has no use for yet).

CMakeLists.txt: upstream's strata-dsv41 block, with ggml.h / ggml-cpu.h coming through strata_kernels_cpu's ggml-cpu
link from the submodule (no FetchContent), the tq sources and flags in strata_kernels_cpu, and iq_avx512.cpp built
with -mavx512vpopcntdq -mbmi2 as upstream does (iq512x_rows uses them).  Makefile: STRATA_BUILD_DSV41=ON and
strata-dsv41 among the targets `make build` produces.

Target: ISTA-DASLab/DeepSeek-V4.1-Flash-1017-GSQ-RCO-GGUF (IQ1_M / IQ2_XXS + the IQ4_NL Engram) on the A6000 VM.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-23 20:14:35 -07:00
Robert Karl 0197ae86eb Import PolyStrata v0.1.45-poly.1 (d0cd84dc) unmodified
The upstream release tree, every tracked file byte for byte, from
https://github.com/VecSzn/PolyStrata at tag v0.1.45-poly.1, commit
d0cd84dc6bd009d1d9e2191e4e28cc76b80f1ee3. Nothing added, removed or edited;
git diff against this commit is the whole story of the fork.

Verified: the commit's tree hash equals the upstream commit's tree hash.
2026-10-17 19:34:32 -07:00
Robert Karl d1022a66f0 Empty the tree: UnbiasedStrata 2 starts over from PolyStrata
Every tracked file, .gitignore, .gitmodules and both submodules (llama.cpp at
3cf03257, llama-muse at 335916a) are removed so the next commit can import
PolyStrata v0.1.45-poly.1 unmodified and be the diff baseline of the fork.
UnbiasedStrata 1 remains at tags unbiasedstrata-1 (main, b124b59) and
unbiasedstrata-1-muse-spark-native (4c824e6).

Verified: git ls-files is empty; the working directory holds only .git.
2026-10-17 19:34:05 -07:00
Robert KarlandClaude Fable 5.1 c77631ebba Qwen3.6 step 3: the split-K bound applies to dense shapes only; a sparse shape keeps one block per 64 cells at any capacity
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
2026-10-11 13:50:45 -07:00
Robert KarlandClaude Fable 5.1 99c7614a01 Qwen3.6 step 3: one QsaShapes builder (strata/core/qsa_shapes.hpp); dense = the three indexer widths zero, in qsa_dense and the kernels' guard alike
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
2026-10-11 13:50:26 -07:00
Robert KarlandClaude Fable 5.1 a711e8d6b3 Qwen3.6 step 3: the KV kernels accept the dense shape, the prompt kernels write only G rows, the parity test reads the oracle's #2 names
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
2026-10-11 12:54:17 -07:00
Robert KarlandClaude Fable 5.1 aab15eea39 Qwen3.6 step 3: dense decode attention - G templated at 2/8/12, a null ids as the identity, the split-K scratch bounded at 128 blocks per KV head
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
2026-10-11 12:54:17 -07:00
Robert KarlandClaude Fable 5.1 0d13f41287 native experts: IQ3_XXS, Q5_K and Q6_K down projections, Q6_K gate/up (Qwen3.6-35B-A3B's expert formats)
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
2026-10-11 12:27:10 -07:00
Robert KarlandClaude Fable 5.1 5c6eb91ca8 GDN output gate selectable per model: SiLU(z) for qwen35moe, sigmoid(z) kept for qwen4exp
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
2026-10-11 12:18:08 -07:00
Robert KarlandClaude Fable 5.1 1d2e400920 Qwen3.6 step 2: the native expert layout takes the model's widths; the engine reads the geometry before the layout
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
2026-10-11 09:48:22 -07:00
Robert KarlandClaude Fable 5.1 12a7825605 Import Strata at 6f32ec0 (upstream snapshot, unmodified)
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>
2026-10-04 12:55:44 -07:00