Resident GEN/STOP/QUIT service (strata-ctl contract) composing the three verified pieces:
- ld::layer::forward_inkling_with_state (48-visit autoregressive forward, persistent KV/ShortConv);
- abi::sampler (hardened zero-alloc greedy/top-k/p/min-p + penalties, non-finite tracking);
- gw::session::ServeSession (proofs/serve_session.lean FSM: GEN 0 pre-warm, STOP->DONE drain).
serve_gen is a pure orchestration fn (engine + ParsedGen + stop flag + emit closure), GPU-integration-tested. run_serve adds a stdin reader thread raising stop/quit atomics so STOP interrupts decode and drains to DONE. Token-id based (no tokenizer needed). gw 'hip' feature default OFF keeps the gateway host-independent.
Measured: live binary over pipe -> READY 8192 stop; 'The capital of France is' -> T 152717 (' Paris', exact ref) T 13 T 198 T 3967; DONE length. STOP after 2 tokens -> DONE 2 ... stop, no further tokens (Theorem 4/9). QUIT exits clean.
Verified: cargo test --workspace green (-D warnings), gw hip 10 default + 2 GPU serve tests green, 5 Lean files 0 sorryAx.
Added a reference-ground-truth debugging loop: drove the strata-inkling
reference engine (--serve, GEN protocol) on the same prompts to obtain the
correct continuations, then compared against vetta's forward.
- tokenizers crate (fancy-regex) added to vetta-infer-ld for real BPE
encode/decode from tokenizer.json.
- forward_inkling_with_state: stateful variant exposing the persistent
per-layer KV cache + shortconv history across decode positions, enabling
autoregressive prefill + generation. forward_inkling wraps it with fresh state.
- generate_continuation_real_prompt test: encode prompt -> token-by-token
prefill -> greedy sampling via the hardened abi sampler -> decode.
TWO REAL BUGS FOUND via reference comparison (reference: "The capital of
France is" -> " Paris."; single token 100 -> argmax 68014):
1. embed_token omitted embed_norm: the reference k_embed_lookup fuses gather +
RMS-normalize with embed_norm.weight. Fixed (gather then rms_norm).
2. full-attn ShortConv static_w transpose had REVERSED tap order: reference
upload_sc uses kt[c*4+(3-lag)] = kw[lag*kv_dim+c]; fixed to match.
NOTE: generation is still divergent after these two fixes (single-token argmax
moved 120533 -> 100, reference 68014); further correctness debugging is in
progress. These two fixes are verified-correct against the reference semantics.
Verified: RUSTFLAGS="-D warnings" cargo test --workspace = 97/97 PASS;
lean proofs (5 files) green; generation + full-forward tests run
(--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).
- New crate vetta-infer-hip: HIP FFI/DMA backend (unsafe isolated here per
AGENTS.md). Kernel build is feature-gated (`hip`, default OFF) so
`cargo test --workspace` stays host-independent (97/97, no toolchain).
build.rs invokes hipcc --offload-arch=gfx1150, archives libvetta_kernels.a,
links amdhip64 from ROCM_PATH/lib.
- kernels/hip/vetta_kernels.hip: device query, minimal device-buffer
lifecycle (alloc/free/h2d/d2h, RAII DeviceBuf), and the first microkernel
k_rms_norm_f32 (one block/row, shared-mem reduction). C ABI extended in
vetta_kernels.h.
- Safe wrappers: query_device, DeviceBuf, rms_norm_f32.
Verified LIVE on Sogliola (cargo test -p vetta-infer-hip --features hip
-- --ignored): device = AMD Radeon 890M Graphics gfx1150 CU=8 UMA=true;
rms_norm parity vs CPU oracle max_rel_err ~1.3e-6 across rows 1/4/3/2 and
d 2304/128/1024 (tolerance 1e-4). First GPU compute verified end-to-end:
hipcc -> static lib -> FFI -> launch -> parity. This opens the GPU execution
half (executor + remaining kernels toward the first served token).