Repository navigation
Engram: one table layout owner — upstream llama.cpp's concatenated layout (the public V4.1 files) beside the per-site one, q6_K rows, the folded gate - #1174
Conversation
…enated), q6_K rows on the card, the folded gate, the relayout tool and its layout gate Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01X1hsQfyQxXKXsQ6LVTcsx5
# Conflicts: # crates/gpu-deepseek41/src/chain/glue.rs # crates/model/src/arch/deepseek41/tp.rs
…e arch key constant in the test, the layout gate's defaults twin, the q6_K kernel's per-arch ptx rows and unsafe pin, the self-test lists) Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01X1hsQfyQxXKXsQ6LVTcsx5
There was a problem hiding this comment.
Verdict: MUST_FIX: The layout gate accepts missing logits, and relayout crashes on an accepted table type.
Must fix
1. Require all nine logits rows
justfile:3250 calls the comparison without a count. tools/bloomery/rows.py:100 compares the shorter file. Nine per-site rows and zero upstream rows return success: “0 rows: every row bit-equal.” A mutant that stops writing upstream logits passes.
Pin the count now so this gate cannot certify missing output. Replace its comparison command with:
python3 -I tools/bloomery/rows.py diff "$D/persite.rows" "$D/upstream.rows" --n "$N" --count 92. Preserve table types absent from the label dictionary
tools/ref/engram-relayout.py:529 indexes TYPE_NAMES with the output type. A Q8_0 source with no --table-type passes plan_tables and _row_type, then raises KeyError: 8 here. IQ4_NL has the same path.
Fix the shared formatting site now rather than adding each accepted type to another table. Replace lines 528–531 with:
in_ty = sites[0].t["engram_embd"][2]
out_ty = next(o for p in plan for o in p if o.name in table_names).ty
types = f"tables={TYPE_NAMES.get(in_ty, str(in_ty))}->{TYPE_NAMES.get(out_ty, str(out_ty))} " \
f"kv={'+'.join(sorted({TYPE_NAMES.get(o.ty, str(o.ty)) for p in plan for o in p if o.name.endswith(kv_tail)}))}" \
+ (" gains=ones,gate" if per_site else "")3. Reuse the existing inline byte reader
crates/gpu-deepseek41/src/chain/glue.rs:360 duplicates crates/gpu-deepseek41/src/swap.rs:129: both extract a byte from its covering little-endian word under the same bounds invariant (R14).
Reuse now to avoid another owner of the unsafe read. Keep byte_at's existing docs and #[inline(always)], and replace its definition with:
pub(crate) unsafe fn byte_at(src: &[u32], o: usize) -> u32 {
// SAFETY: o / 4 < src.len() by the caller's contract.
(unsafe { *src.get_unchecked(o / 4) } >> (8 * (o % 4))) & 0xFF
}Delete image_byte and replace its three calls with:
crate::swap::byte_at(w, base + 64 * h + 32 * (q & 1) + l),
crate::swap::byte_at(w, base + 128 + 32 * h + l),
crate::swap::byte_at(w, base + 192 + 8 * h + l / 16 + 2 * q),This removes a function and adds none. Verify identical PTX for this move.
4. Remove the empty validation branch
tools/ref/engram-relayout.py:334 tests a literal that is always in DROPPED, then executes only pass. It validates nothing; line 79 nevertheless says the key is checked.
Remove this unused code now so later changes cannot mistake it for validation. Replace lines 334–336 with:
return bases, base, absolute, width, tyReplace line 79 with:
# `num_embeddings` is the sites' row counts, which the tables' shapes carry; dropped.Optimization headroom
- G. Per-launch and per-sync fixed cost: crates/gpu-deepseek41/src/chain/glue.rs:281, fuse Q6_K row decoding with the existing q8_1 conversion for a Q6_K KV projection. Saves one launch and
8 × rows × key_lengthbytes of f32 traffic per site per token [derived].
Checked
Duplicates: the byte readers have equivalent bounds and operations; reuse removes one function (R14).
Complexity: diagnostics contain no crapper results; no finding relies on a complexity score.
Silent failure: nine per-site rows and zero upstream rows return success; adding --count 9 refuses that input.
Tests: isolated planning/formatting checks reproduce KeyError for types 8 and 20; the proposed formatting fix handles both. All three inline suggestions target added lines; Python replacements parse and the shell replacement passes bash -n.
Gates: the unsafe ratchet increase has a dated PIN.
Escape catalog: C1–C4 do not alter these findings. No ledger lessons are in force.
Notes
Dryer and crapper did not run: their Python modules were missing.
GPU gates and PTX comparison were not run here.
GPU evidence lacks the required nvidia-smi line and full gate command outputs.
Card check: needs-gpu. This pull request changes crates/gpu-deepseek41/src/body.rs, crates/gpu-deepseek41/src/body/prefill.rs, crates/gpu-deepseek41/src/chain/glue.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
| # per-site twin to hold them to; the real file's open is generate_ds41's. Logs in target/engram-layout-gate/. | ||
| [group('v41-load')] | ||
| gate-gpu-ds41-engram-layout: | ||
| BLOOMERY_MODEL=deepseek41 ./tools/box.sh 'bash tools/ref/fixture-only.sh gate-gpu-ds41-engram-layout && export BLOOMERY_GATE_V41_LOAD=1 && cargo oxide build --arch {{arch}} -- -p bloomery-gpu-gates --features deepseek41 --release --bin generate_ds41 && D=target/engram-layout-gate && rm -rf $D && mkdir -p $D && F=$(. tools/ref/ref-paths.sh && printf %s "$FIXTURE_FILE") && T=$(. tools/ref/ref-paths.sh && python3 -I tools/ref/engram-relayout.py twin "$FIXTURE_DIR") && U=$(find "$T" -maxdepth 1 -name "*-00001-of-*.gguf" 2>/dev/null) && P=$(find "$T/per-site" -maxdepth 1 -name "*-00001-of-*.gguf" 2>/dev/null) && if [ -z "$U" ] || [ -z "$P" ] || [ "$(printf "%s\n" "$U" | wc -l)" != 1 ] || [ "$(printf "%s\n" "$P" | wc -l)" != 1 ]; then echo "gate-gpu-ds41-engram-layout: $T and $T/per-site do not hold one first shard each: just fixture-engram-upstream writes them (exit 66)" >&2; exit 66; fi && python3 -I tools/ref/engram-relayout.py check "$U" --source "$F" && python3 -I tools/ref/engram-relayout.py check "$P" --source "$F" && UB=$(. tools/ref/ref-paths.sh && FIXTURE_FILE=$U fixture_budget) && IDS=$(head -n 5 "$BLOOMERY_DATA/engram/corpus-prose.ids" | paste -sd, -) && echo "prompt ids $IDS; per-site $P; twin $U (budget $UB for both)" && arm() { BLOOMERY_CARD_BUDGET=$UB BLOOMERY_V41_MODEL=$1 BLOOMERY_REF_MODEL=$1 BLOOMERY_FIXTURE_MODEL=$1 BLOOMERY_GATE_CARD=${BLOOMERY_GATE_CARD:-any} bash tools/gpu-gate.sh generate_ds41 --place a --ctx 4096 --tokens "$IDS" -n 9 --top2 9 --rows $D/$2.rows > $D/$2.log && sed -n "s/^plan .*\(card_experts=.* layers\) card_budget=.*/\1/p" $D/$2.log > $D/$2.plan && grep "^tokens " $D/$2.log > $D/$2.tok && echo "$2 $(cat $D/$2.plan)" && echo "$2 $(cat $D/$2.tok)"; } && arm "$P" persite && arm "$U" upstream && [ -s $D/persite.plan ] && cmp $D/persite.plan $D/upstream.plan && echo "plan: the same experts on the card and the host" && cmp $D/persite.tok $D/upstream.tok && echo "tokens: identical" && N=$(sed -n "s/^rows .* n=\([0-9]*\).*/\1/p" $D/persite.log) && python3 -I tools/bloomery/rows.py diff $D/persite.rows $D/upstream.rows --n "$N" && echo "gate-gpu-ds41-engram-layout: PASS"' |
There was a problem hiding this comment.
Require all nine logits rows; the default comparison succeeds on an empty upstream file.
| BLOOMERY_MODEL=deepseek41 ./tools/box.sh 'bash tools/ref/fixture-only.sh gate-gpu-ds41-engram-layout && export BLOOMERY_GATE_V41_LOAD=1 && cargo oxide build --arch {{arch}} -- -p bloomery-gpu-gates --features deepseek41 --release --bin generate_ds41 && D=target/engram-layout-gate && rm -rf $D && mkdir -p $D && F=$(. tools/ref/ref-paths.sh && printf %s "$FIXTURE_FILE") && T=$(. tools/ref/ref-paths.sh && python3 -I tools/ref/engram-relayout.py twin "$FIXTURE_DIR") && U=$(find "$T" -maxdepth 1 -name "*-00001-of-*.gguf" 2>/dev/null) && P=$(find "$T/per-site" -maxdepth 1 -name "*-00001-of-*.gguf" 2>/dev/null) && if [ -z "$U" ] || [ -z "$P" ] || [ "$(printf "%s\n" "$U" | wc -l)" != 1 ] || [ "$(printf "%s\n" "$P" | wc -l)" != 1 ]; then echo "gate-gpu-ds41-engram-layout: $T and $T/per-site do not hold one first shard each: just fixture-engram-upstream writes them (exit 66)" >&2; exit 66; fi && python3 -I tools/ref/engram-relayout.py check "$U" --source "$F" && python3 -I tools/ref/engram-relayout.py check "$P" --source "$F" && UB=$(. tools/ref/ref-paths.sh && FIXTURE_FILE=$U fixture_budget) && IDS=$(head -n 5 "$BLOOMERY_DATA/engram/corpus-prose.ids" | paste -sd, -) && echo "prompt ids $IDS; per-site $P; twin $U (budget $UB for both)" && arm() { BLOOMERY_CARD_BUDGET=$UB BLOOMERY_V41_MODEL=$1 BLOOMERY_REF_MODEL=$1 BLOOMERY_FIXTURE_MODEL=$1 BLOOMERY_GATE_CARD=${BLOOMERY_GATE_CARD:-any} bash tools/gpu-gate.sh generate_ds41 --place a --ctx 4096 --tokens "$IDS" -n 9 --top2 9 --rows $D/$2.rows > $D/$2.log && sed -n "s/^plan .*\(card_experts=.* layers\) card_budget=.*/\1/p" $D/$2.log > $D/$2.plan && grep "^tokens " $D/$2.log > $D/$2.tok && echo "$2 $(cat $D/$2.plan)" && echo "$2 $(cat $D/$2.tok)"; } && arm "$P" persite && arm "$U" upstream && [ -s $D/persite.plan ] && cmp $D/persite.plan $D/upstream.plan && echo "plan: the same experts on the card and the host" && cmp $D/persite.tok $D/upstream.tok && echo "tokens: identical" && N=$(sed -n "s/^rows .* n=\([0-9]*\).*/\1/p" $D/persite.log) && python3 -I tools/bloomery/rows.py diff $D/persite.rows $D/upstream.rows --n "$N" && echo "gate-gpu-ds41-engram-layout: PASS"' | |
| BLOOMERY_MODEL=deepseek41 ./tools/box.sh 'bash tools/ref/fixture-only.sh gate-gpu-ds41-engram-layout && export BLOOMERY_GATE_V41_LOAD=1 && cargo oxide build --arch {{arch}} -- -p bloomery-gpu-gates --features deepseek41 --release --bin generate_ds41 && D=target/engram-layout-gate && rm -rf $D && mkdir -p $D && F=$(. tools/ref/ref-paths.sh && printf %s "$FIXTURE_FILE") && T=$(. tools/ref/ref-paths.sh && python3 -I tools/ref/engram-relayout.py twin "$FIXTURE_DIR") && U=$(find "$T" -maxdepth 1 -name "*-00001-of-*.gguf" 2>/dev/null) && P=$(find "$T/per-site" -maxdepth 1 -name "*-00001-of-*.gguf" 2>/dev/null) && if [ -z "$U" ] || [ -z "$P" ] || [ "$(printf "%s\n" "$U" | wc -l)" != 1 ] || [ "$(printf "%s\n" "$P" | wc -l)" != 1 ]; then echo "gate-gpu-ds41-engram-layout: $T and $T/per-site do not hold one first shard each: just fixture-engram-upstream writes them (exit 66)" >&2; exit 66; fi && python3 -I tools/ref/engram-relayout.py check "$U" --source "$F" && python3 -I tools/ref/engram-relayout.py check "$P" --source "$F" && UB=$(. tools/ref/ref-paths.sh && FIXTURE_FILE=$U fixture_budget) && IDS=$(head -n 5 "$BLOOMERY_DATA/engram/corpus-prose.ids" | paste -sd, -) && echo "prompt ids $IDS; per-site $P; twin $U (budget $UB for both)" && arm() { BLOOMERY_CARD_BUDGET=$UB BLOOMERY_V41_MODEL=$1 BLOOMERY_REF_MODEL=$1 BLOOMERY_FIXTURE_MODEL=$1 BLOOMERY_GATE_CARD=${BLOOMERY_GATE_CARD:-any} bash tools/gpu-gate.sh generate_ds41 --place a --ctx 4096 --tokens "$IDS" -n 9 --top2 9 --rows $D/$2.rows > $D/$2.log && sed -n "s/^plan .*\(card_experts=.* layers\) card_budget=.*/\1/p" $D/$2.log > $D/$2.plan && grep "^tokens " $D/$2.log > $D/$2.tok && echo "$2 $(cat $D/$2.plan)" && echo "$2 $(cat $D/$2.tok)"; } && arm "$P" persite && arm "$U" upstream && [ -s $D/persite.plan ] && cmp $D/persite.plan $D/upstream.plan && echo "plan: the same experts on the card and the host" && cmp $D/persite.tok $D/upstream.tok && echo "tokens: identical" && N=$(sed -n "s/^rows .* n=\([0-9]*\).*/\1/p" $D/persite.log) && python3 -I tools/bloomery/rows.py diff $D/persite.rows $D/upstream.rows --n "$N" --count 9 && echo "gate-gpu-ds41-engram-layout: PASS"' |
| if "engram.num_embeddings" in DROPPED: | ||
| pass |
There was a problem hiding this comment.
This constant membership test executes only pass and performs no validation.
| if "engram.num_embeddings" in DROPPED: | |
| pass |
| CHUNK = 16 << 20 | ||
| SAMPLE = 64 # transcoded blocks decoded on both sides, per transcoded range | ||
| # The per-site keys this tool reads (the canonical spelling), each to its llama.cpp spelling, in the converter's order. | ||
| # `num_embeddings` is the sites' row counts, which the tables' shapes carry: checked and dropped. |
There was a problem hiding this comment.
The source reader does not check this optional key before dropping it.
| # `num_embeddings` is the sites' row counts, which the tables' shapes carry: checked and dropped. | |
| # `num_embeddings` is the sites' row counts, which the tables' shapes carry; dropped. |
…/ MoE layers and the decode step on common owners, placement inputs, reference sets (#1178) ## What and why Kimi K3 support, the first half: everything below the chain. AGENTS.md "Common code first" drove each piece — what raon1 (KDA + gated latent + situ MoE) and nemotron_h_moe (latent MoE) already did is now a common owner, and `kimi_k3` holds only what an architecture fact forces. - **Description and fixture** (`crates/gguf/src/arch/kimi_k3.rs`, `crates/model/src/arch/kimi_k3/{hparams,names,roles,spec,fixture,place}.rs`): per-layer `head_count_kv` 0 = KDA / 1 = MLA, layer 0 dense (`dense_lead_of`), the latent MoE (`ffn_routed_down/norm/up`, `Moe.sum_norm`), the 2-shared gated stack, situ (β 4, β₂ 25), `Residual::AttnRes{block}` every 12th layer, `tokenizer.ggml.pre = kimi-k2`. The fixture writer cuts a 152 MB file from the real file's layers [0, 46, 83, 84] (KDA dense; KDA routed IQ2_XXS/IQ1_S; MLA routed; KDA routed all IQ1_S) at hidden 512 / latent 256 / 8 experts top 2 / shared width 512 / attn_res block 2; `gate-kimi-k3-meta` pins the header, the tensors by role and type (`kimi_k3_tensors.tsv`, 2573 rows) and the box plan's bytes (KDA store 7,913,476 B a layer, latent row 1,152 B a position, experts by type; the planner on A6000 + 3090 at ctx 32768: 3,313 card experts at cut 70, 1,394 NVMe picks a token, 516.5 GB NVMe). - **Tokenizer** (`Pre::KimiK2`): our ids equal `llama-tokenize` on every case (pins `kimik2-ids.tsv`, written by `kimik2-oracle.sh`), re-checked on shard 1 of the real file; `gate-kimi-k3-tokenizer`. - **KDA layer**: runs on the common `crates/gpu/src/linear/mixer_kda.rs` with K3's rule as launch args (`Sigmoid{lower_bound: -5}`, beta_scale 1, write_gate false, the full-rank `ssm_g` into z); no new kernel; `gate-gpu-kimik3-kda` against llama.cpp's `build_kda_layer` in f64 at 2 and 96 heads. - **Gated MLA**: raon1's `mla.rs` lifted to `crates/gpu/src/latent_gated.rs` (`attend`, `attend_rows`), both families call it; no new kernel; `gate-gpu-kimik3-mla` against `build_mla_layer` in f64 (2 and 96 heads, nope 128, 64 unrotated rope lanes, 512 latent, value 128; decode at 1..300 keys, 8 rows = 8 steps). - **MoE block**: raon1's `ffn.rs` lifted to `crates/gpu/src/arch/routed_ffn.rs` with the latent pair and the routed-sum norm as optional stages (`Routed.latent`, `Routed.sum_norm`, `None` for the families without them) and the router instance as a type parameter; rda's row kit to `arch/rows_kit.rs`; `kimi_k3/moe.rs` holds the load, width checks and refusals. New PTX entries only: `sigmoid_896_16_router(_pick)`, `sigmoid_8_2_router(_pick)`, `ds41_ffn_card_acc_2`, `_16`; `just ptx-compare c210226 generate_ds41` rc 0 added-only (537 base entries unchanged); `gate-ptx-spill` red on exactly the six before the pins. `gate-gpu-kimik3-moe`: 22 clauses on the fixture's three routed layers and one real-width layer against the host f64 reference, band rel L2 5e-2 (derived: q8_1 activation rounding ~0.6 % a site, worst sum 1.5 %, ×3; measured 1.6e-2..2.0e-2, separations ≥ 11 bands). - **Lifts** (`delta_mla.rs` for the Mla/Situ readers and the generic layer kinds, `latent_gated.rs` the attention core, `arch/gated_mla.rs` the gated MLA layer driver (sites, buffers, step, rows; raon1 keeps its wide-rows path), `routed_ffn.rs`, `rows_kit.rs`): raon1's bits unchanged (ptx-scan identical on its bins; `gate-gpu-raon1-attn` and the raon1 meta/tokenizer gates green in the batch; the gated_mla lift: `ptx-compare 5fcf11e` identical 544 = 544, gate-gpu-lib 520 + 10, kimik3-mla 66 clauses, raon1-attn 16, kimik3-e2e PASSED, one mutant red). - **Reference sets** (`crates/refset/src/arch/kimi_k3/`): the families `lcpp-kimi-k3` (the real file) and `fx-lcpp-kimi-k3` (the fixture), dumped by mainline llama.cpp 78feec062's own `kimi-k3` graph (`tools/ref/kimi-k3-dump.sh`, `just build-k3-lcpp` / `dump-ref-kimi-k3`, cards for both dumps), four prompts; the vendor tree opens our fixture with no refusal (arch kimi-k3, n_layer 4, n_head_kv [0,0,1,0]), the fixture writer's strongest check. Six contract tests, each red under a mutation of the family row; `just gate-refset` 362 passed with the sets in place. - **The decode step** (`crates/gpu/src/arch/kimi_k3/{body,kda,state}.rs`, round kimik3body): `GpuModel<Body>::open` walks the description's per-layer kinds over the common owners above; the one kernel a K3 fact forces is the AttnRes bank mix (`crates/gpu/src/attn_res.rs`, entry `attn_res_mix`: `gate-ptx-spill` red on exactly it before the pin, `just ptx-compare afcc136 generate_ds41` rc 0 added-only, the per-arch tables carry the derived 0/0 row until a scan on that arch; unsafe ratchet 3021 → 3036 blocks, `PIN(2026-11-06)`). `gate-gpu-kimik3-e2e` (fixture tier, the fx-lcpp-kimi-k3 sets a..d): the free chain's layers 0..2 within [0.05, 0.08, 0.2] of the vendor's (measured 3.0e-2, 5.1e-2, 1.35e-1), every mixer and ffn block alone on the vendor's rows within 4e-2 (measured ≤ 2.8e-2) with the vendor's picks on all 12 routed blocks, the logits row within 1.0, the mix vs the host f64 within 1e-5 (3.5e-7), steps deterministic, eager = replay; bands derived in the bin's doc. Mutants: the mix dropped, the routed norm dropped, layer 1 opened as MLA — each red. Known gap: the teacher-forced top-1 clause catches none of the three (3–5 of 32 positions above `MARGIN_FLOOR`; the vendor's CPU q8_K 256 and our q8_1 128 activation blocks differ by 1.4–2.8 % a branch, amplified by the free chain) — the block and layer clauses carry correctness; in the triage. - **Registrations**: `tools/families.tsv` (F, other), `gate-class.tsv`, `model-tokens.tsv`, `model-tax.tsv` (five `PIN(2026-11-05)` rows for the enum arms the registry does not own yet), `fixture-dirs.tsv`, `tools/ref/models/kimi-k3.sh`. Not in this PR: the decode step and chain (`kimi_k3/{body,state}.rs`, the AttnRes mix, the head), the prompt rows, the Program wiring, the real-file bring-up — rounds in flight on top of this branch. Until the body lands, `PlanInputs::read` refuses the family by name with its 348 coverage items in 6 rows (pinned). Release notes: none yet (the family does not run); the next PR's. - [x] **No second copy.** One owner each for the gated latent attention, the routed ffn, the row kit, the delta/MLA readers; raon1 and K3 call them. - [x] **Model code holds only architecture facts.** `kimi_k3/` holds shapes, names, the per-layer kind rule, the fixture cut and the load-time refusals; no family branch in a common owner. - [x] **Dead code is gone.** `raon1/ffn.rs` and the rda row kit are moves, not copies. - [x] **No silent failure.** A layer kind, a width, a count no instance is built for, a tier card: each refused by name; `PlanInputs::read` refuses the unfinished family. - [x] **Comments state what is true now.** `tools/check-comments.sh` rc 0. - [x] **No relaxed gate.** No band moved; new pins carry `PIN(2026-11-05)` (unsafe ratchet 3017 → 3021, ptx-shapes rows, model-tax rows); mutants per gate (sum-norm, situ-beta, select-bias, up-first; KDA state halved, latent row 512; the MLA and KDA gates' in-gate separations). - [x] `just mac-static main` green on the merged tree (the lease self-test's 4 FAILs were a load flake beside a parallel check: green alone, `lease.sh` untouched). Duplication found or removed: `raon1/wide.rs` refuses a latent or sum-normed block by name rather than growing the arithmetic (the prompt-rows round's); the byte-read helper noted in #1174 still has its four copies. ## What I ran Box (RTX A6000 + RTX 3090, driver 580), fixture tier. Rounds (Sonnet 5.5: kimik3, kimik3mla, kimik3kda, kimitok, kimilift, kimik3moe, kimik3place), each with FAIL-first and mutants as above. Lead's union batch on 1084d1f, `tools/gate-batch.sh --ledger --tier fixture --no-canary --list <just affected main>` (224 of 251 gates selected; narrow does not shrink it, the registration files have no gate-paths row): `DONE total=248 red=1 tier=fixture wall=2711s deferred=290`. Body merge (5fcf11e, `just ptx-compare dd97592 generate_ds41` added-only): `gate-gpu-kimik3-e2e` PASSED, `gate-ptx-spill` rc 0, `gate-gpu-gates-lib` rc 0, `gate-refset` 362 passed (real tier), `gate-gpu-lib` 519 of 520 — `hw_a_held_card_leaves_the_room_its_open_reads` read a negative room while three other rounds' gates shared the card (contention, not this change; rerun in the release batch). The one red of the union batch, `gate-models` (the biased-sigmoid router-row test did not name K3's two rows), fixed in b5cb4a8 and rerun green (47 + 3 passed). ## Hardware Box: AMD 64-core, 256 GB, RTX A6000 48 GB + RTX 3090 24 GB. Squash of the kimilift integration branch (rounds kimik3, kimik3mla, kimik3kda, kimitok, kimilift, kimik3moe, kimik3place, kimik3ref, kimik3body, kimik3mlalift; the repository allows no merge commit and the branch carried merges). Each round's own commit message is on the branch kimilift at b962b63. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01X1hsQfyQxXKXsQ6LVTcsx5
V4.1 GGUF 의 Engram 테이블을 upstream llama.cpp 레이아웃(공개 파일: 한 장의
per_layer_token_embd, 접힌engram_gate, q6_K 행)으로도 연다 — 레이아웃 소유자 하나, 두 잎.What and why
Every public V4.1-Flash GGUF made with llama.cpp ≥ b11870 stores the Engram as upstream's converter writes it: one
per_layer_token_embd.weighttable (every Engram layer's rows back to back, q6_K),blk.L.engram_gate.weight(f32, q ⊙ k folded) andengram_kv.weight; bloomery read only the older per-site layout and refused every public file by name (tensor blk.1.engram_embd.weight: is not in the file). This lands one layout owner,EngramLayout { PerSite, Concatenated }incrates/gguf/src/engram.rs(EngramTables::read: per site(tensor, base row, rows, type); the concatenated base rows fromple.head_offsetskept absolute; both layouts present, neither, a short table or a site past its rows refused by name), addressing by base row everywhere a site's rows are read (crates/engramhost reader, the card gather inglue.rs,body.rs/prefill.rs), the kv and gate names per layout with the gains asEngramGains::{Pair, Folded}, q6_K rows in the card gather (ds41_glue_engram_rows_q6k, pinned by a unit test against the host dequant) andDense::Q6Kfor the kv gemv. The per-site layout's bits do not move (gate-gpu-ds41-kernelsscan unchanged,gate-engramgreen with no pin moved).A relayout tool
tools/ref/engram-relayout.py(its--self-testin check-recipes) writes the fixture as its upstream-layout twin plus a per-site counterpart set from the same fold and transcode (fixture-variants/engram-upstream/v41/, 15.0 + 15.0 GB on the box); the newgate-gpu-ds41-engram-layoutopens the twin and its counterpart and holds a 5-token prompt + 8 decode steps' tokens identical and 9 rows bit-equal. The fixture itself cannot be the gate's other side: its kv is Q3_K and the twin's q6_K, and the fixture's margins (0.03–0.57) sit underMARGIN_FLOOR0.5, so the two diverge from row 0 by the gemv's sum order, not by the reader (the lab's new clause shows both layouts' hash walks and every visited row bit-equal).Folded gate derivation [derived]: with A = r(k·sk), B = r(x·sq), the pair path computes r(r(A·gk)·r(B·gq)) and the folded path r(A·r(B·G)) with G = r(gq·gk); the per-lane relative difference is ≤ ~10 u (u = 2⁻²⁴); the dot is an f64 sum, so |Δs| ≤ 10u·√ROW·max|G|; with the sqrt's slope 1/(2√|s|) and the sigmoid's ≤ ¼, |Δgate| ≤ 5.3e-6·max|G|/√|s|, inside
KERNEL_BAND1e-5 for |s| of O(1) and |G| ≤ 1. The fixture's |G| ≤ 1.7e-3. Which side the gate is applied to is not pinned by any fixture-tier e2e gate (a key-side mutant was bit-equal on 9 rows); the real-only kernels gate sees it.Release notes: Added — V4.1-Flash GGUFs in upstream llama.cpp's Engram layout (unsloth, bartowski, …) open;
gguf-inventory --engramprints a file's Engram layout.Code shape
EngramTables), both layouts address rows through it; the kv/gate names are one lookup per layout; the q6_K dequant rule has one owner (crates/gguf/src/quant.rs) the kernel is pinned against.ple.*keys live incrates/gguf/src/arch/deepseek41.rsandcrates/model/src/arch/deepseek41/{hparams,names,roles}.rs.rows.py --within(the first round's) reverted; the unusedCONCAT_TABLEimport after the TP merge removed.tools/check-comments.shrc 0.tools/unsafe-ratchet.txtraised (+5 blocks, +2 fns, each with its SAFETY line,PIN(2026-11-05)); the new kernel's rows pinned intools/ref/ptx-shapes.tsvand the four per-arch tables (derived 0/0 until a scan on that arch, the 72c9766 precedent).cargo fmtand clippy clean;just mac-static mainok (lint 0 at ratchet 0).Duplication found or removed: the byte-read helper exists four times (
glue.rs:360,dense.rs:88,swap.rs:129,crates/gpu/src/q6k_heads.rs:35) — reported, not folded here (it would re-prove PTX).What I ran
Box (RTX A6000 + RTX 3090, driver 580), fixture tier:
tensor blk.1.engram_embd.weight: is not in the filerc 101; mutants base-row, gate-dropped, q6k-scale, gate-q-only each red):gate-gpu-ds41-engram-layoutPASS (tokens identical, 9 rows bit-equal),gate-gpu-ds41-lib57 passed,gate-engram13 + 28,lab-engram5,gate-gpu-ds41-stepPASSED,gate-gpu-ds41-prefillPASSED,gate-ptx-spillPASS (red before the pin on exactly the new entry).tools/gate-batch.sh --ledger --tier fixture --no-canary --list <just affected main>on 9d84748:DONE total=191 red=4 tier=fixture wall=2334s deferred=239. The four:gate-gpu-ds41-tp(gate-gpu-ds41-tp: /models/fixtures/v41-folder is not on the workstation (fixture tier) #1172, the TP fixture folder missing on the box, red on main too);gate-gpu-lib518/519 (gate-gpu-lib: host::rank::dist the_head_checks_a_file_once_by_its_stamp fails on the workstation (main c9c31488e) #1171'shost::rank::disttest, red on main alone at 6b37111, green at 45ac6ad, red again here — not deterministic);gate-gpu-ds41-residency-aandgate-serve-draft-rulesfailed in 2 s / 9 s on a box.sh rsync race between the two lanes (.sync-id.new: No such file), rerun alone:gate-gpu-ds41-residency-aPASS (default and c1 clauses),gate-serve-draft-rulesrc 0;gate-gpu-librerun 519/519./models/DeepSeek-V4.1-Flash-1017-UD-IQ3_XXS(7 shards): the layout owner's per-site table printed with no refusal; generate smoke (--place a --tokens 1..8 -n 8): the Engram opens; the refusal moved past it to the next feature the public file needs,residency pre-plan: 1 feature(s) of this file are not implemented: q8_0 output head (the head reads q6_K and q5_K)— a follow-up (the public file'soutput.weightis q8_0), not this change's.just mac-static mainon 41be838: ok (lint 0 warnings at ratchet 0, combos 80 shapes 0 red, check-recipes 176 blocks ok).Hardware
Box: AMD 64-core, 256 GB, RTX A6000 48 GB + RTX 3090 24 GB.
🤖 Generated with Claude Code
https://claude.ai/code/session_01X1hsQfyQxXKXsQ6LVTcsx5