- real_full_layer_end_to_end test: a complete Inkling layer-0 (SWA, ip=0) runs
end-to-end on real weights with the EXACT deep-residual cadence:
in0 = attn_norm(cur) (ip==0: no attention mix)
asc = attention block(in0) (projections..flash SWA..O-proj..sconv)
ip%block_size(6)==0: block0 <- cur; cur = asc (snapshot + replace)
mlpin = mlp_norm(attn_res_mix([block0], cur, mlp_queries[0]))
moeout = MoE block(mlpin) (router..8 NVFP4 experts..reduce)
cur += mlp_sconv(moeout) (MoE residual is a plain add)
- Extracted the exact residual rules from the reference: the AttnRes block
snapshot/replace applies ONLY to the attention output (ip%6==0 snapshots cur
then cur=asc, else cur+=asc); the MoE output is always a plain residual add.
The MoE input is a learned AttnRes mix over block snapshots + cur (mlp_queries).
- Parity vs a full CPU oracle (incl. the block-mix softmax over depth states):
max_rel_err 6.6e-4, router experts [116,69,124,72,18,64,106,0]. A complete
real Inkling layer now composes correctly — the deep residual is not a plain
add but the learned block mixture, reproduced exactly.
Verified: RUSTFLAGS="-D warnings" cargo test --workspace = 97/97 PASS;
lean proofs (4 files, 42 theorems) green; real full layer PASS
(--features hip, --ignored).
- real_attention_block_end_to_end test: the attention half of a real Inkling
layer-0 (SWA) runs end-to-end on real weights, composing the verified kernels:
attn_norm -> cast -> 6 projections (wq_du/wk_dv/wv_dv/wr_du/gate_attn/
attn_sink_proj via gemm_bf16) -> ShortConv4 K/V -> Q/R/K L2-clip (qk_clip
22.627, rel_clip 8.0, tau off for SWA) -> relpos bias projection -> KV store
(K clipped, V RMS-normalized) -> flash SWA GQA (window 1024 + relpos + sink +
sigmoid gate) -> cast -> O-proj (wo_ud) -> attn ShortConv4.
- Run T=3 sequential decode steps so the KV cache + shortconv history rings
grow autoregressively; parity vs a FULL CPU oracle at every step:
max_rel_err 2.9e-6 / 3.9e-6 / 5.1e-6. The bf16 cast boundaries (input norm ->
projections, attn out -> O-proj) are handled explicitly.
- With the real MoE block (5.6e-4), BOTH halves of a real Inkling layer now
compose correctly on real data. Next: join them into a full layer with the
AttnRes block-mix residual cadence (block_size=6), then loop controllers +
multi-layer forward + lowering + sampling.
Verified: RUSTFLAGS="-D warnings" cargo test --workspace = 97/97 PASS;
lean proofs (4 files, 42 theorems) green; real attention block PASS
(--features hip, --ignored).
- real_moe_block_end_to_end test: the MoE half of a real Inkling layer runs
end-to-end on real layer-0 weights, composing the verified kernels:
mlp_norm (rms_norm) -> cast f32->bf16 -> router GEMM (gate.weight [128,2304]
BF16) -> sigmoid top-8 router (gate.bias, route_scale=8) -> 8 real NVFP4
experts (w13 GEMV -> SiTU beta4/lb25 -> w2 GEMV, outer=amax/denominator) ->
weighted reduce.
- Parity vs a FULL CPU oracle (rms_norm + bf16-truncate cast + BF16 router GEMM
+ sigmoid top-8 + per-expert NVFP4 dequant GEMV + SiTU + reduce): router ids
match exactly ([31,124,0,7,69,121,14,2]), output max_rel_err 5.6e-4.
- This is the integration milestone: the individually-verified kernels compose
into a correct real MoE block on real data, with the bf16 cast boundary
handled explicitly (the dtype-mismatch bug class). The MoE half of a real
Inkling layer now runs correctly; the attention half is next.
Verified: RUSTFLAGS="-D warnings" cargo test --workspace = 97/97 PASS;
lean proofs (4 files, 42 theorems) green; real MoE block PASS
(--features hip, --ignored).
- ld::packer: ExpertMatrix + load_expert_matrix(layer, e, "w13"|"w2") loads a
real NVFP4 expert from safetensors with ZERO requantization — packed E2M1
[N,K/2] + E4M3 group scales [N,K/16] to device as-is, outer_scale =
amax[e] / denominator (denominator tensor read, default 2688 = 448*6 when
absent — exact strata ink_safetensors_loader semantics).
- Real-weight parity test: layer-0 expert-0 w13 [2304,2304] loaded from the
real archive, nvfp4_gemv on GPU vs a CPU dequant oracle over the real
packed bytes + scales + outer_scale. max_rel_err 2.8e-4 (f32 accumulation
order over K=2304; math identical). Confirms the expert scaling + layout
against real Inkling data — the key brick for the layered MoE forward.
Verified: RUSTFLAGS="-D warnings" cargo test --workspace = 97/97 PASS;
lean proofs (4 files, 42 theorems) green; real expert NVFP4 parity PASS
(--features hip, --ignored).
- ld::packer (feature hip): load_raw (tensor bytes -> DeviceBuf, dtype
preserved) + load_bf16_as_f32 (BF16 norm weights upcast to f32 for the
rms_norm kernel, matching the reference). The bridge from canonical IR to
GPU-resident weights; the seam where the per-layer loading/precision policy
(engine-side composition) will be applied.
- FIRST REAL-WEIGHT GPU RUN: load the real Inkling trunk (~1.85 GB: embed +
unembed [201024,2304] BF16, embed_norm + final_norm) and run embed ->
embed_norm -> final_norm -> cast -> unembed on gfx1150, producing real
logits over vocab 201024 + argmax token (20612, logit 27.77, all finite).
Trunk-only skip-layer baseline — proves packer + executor + sampling on
real data end-to-end. The full layered forward + Inkling parity refinements
(AttnRes block-mix etc.) come next for correct generation.
- ld: optional hip + rt deps, feature-gated (default workspace stays
host-independent).
Verified: RUSTFLAGS="-D warnings" cargo test --workspace = 97/97 PASS;
lean proofs (4 files, 42 theorems) green; real-weight trunk run PASS
(--features hip, --ignored).
- ld::inkling_plan: physical_schedule() unrolls the looped core (verified
against the reference logical->physical mapping; Inkling = 6 + 3x12 + 6 =
48 physical steps over 24 logical layers). scratch_layout()/scratch_plan()
lay out the decode activation arenas (residual/q/k/v/attn_out/moe/logits),
4 KiB-aligned with checked offsets, validated by abi::arena.
- ld::inkling_graph: GraphBuilder accumulates arena decls (scratch=0,
weights=1, inputs=2) + a flat op sequence and validates the whole plan
(no overlap, checked bounds, no use-before-write) via abi::arena.
emit_trunk() emits the first complete sub-graph: embed(+embed_norm fused)
-> final norm -> unembed, arena-validated. The per-layer k1->k4 body plugs
into the same builder next.
- abi::vplan: add GemmBf16 opcode (BF16 trunk/unembed GEMM).
- docs/inkling-forward-design.md: forward blueprint grounded in the strata
reference (k1->k4 stage order from kernel numbering, real scratch buffer
set, loop structure, two forward paths main-LLM + MTP DSpark).
Verified live: RUSTFLAGS="-D warnings" cargo test --workspace = 96/96 PASS;
4 ignored live tests pass; lean proofs (4 files, 42 theorems) green.