[LD] FULL Inkling-2-Mini forward runs end-to-end (loop + controllers + MXFP8)

The complete 48-visit Inkling forward now runs on real weights on gfx1150:
prelude [0,6) -> core [6,18) x3 passes (bank rollback + cross-pass msgs +
gain/forget controllers on passes 1,2) -> coda [18,24) -> final depth mix +
unembed + softcap. Produces finite, softcap-bounded logits over vocab 201024
(argmax 120533, logit 19.219) in ~1.9s.

- k_mxfp8_gemv / vetta_mxfp8_gemv + ue8m0_to_f32: MXFP8 experts (layers 20..23
  are F8_E4M3 + UE8M0/32, NOT NVFP4). y[n] = sum_k e4m3(W[n,k]) *
  ue8m0(scale[n,k/32]) * x[k], no outer scale. Real layer-20 expert parity
  1.45e-4 vs CPU dequant oracle. This is the engine-side per-layer precision
  composition: layers 0..19 NVFP4, 20..23 MXFP8, dispatched transparently.
- packer: ExpertMatrix.mxfp8 flag + load_expert_matrix auto-detects the format
  (amax tensor presence) + expert_gemv dispatch.
- ld::layer: ControllerWeights/load_controllers + apply_controller (RMS pack ->
  down GEMM -> gain/forget GEMM -> gating); LoopMsgs; layer_forward_swa/full
  take Option<(&ControllerWeights,&LoopMsgs)> (has_msgs path: 3 separate
  controlled inputs for SWA, controllers before attn norm / after mlp norm).
- is_swa + load_msg_queries (stacked cross-pass queries) + run_layer (SWA/full
  dispatch, persistent per-layer state across passes) + forward_inkling (the
  proven schedule from proofs/inkling_loop.lean, incl. bank rollback).
- full_inkling_forward_logits test: whole-model forward -> finite bounded logits.

NOTE: the forward RUNS and is bounded; bit-parity of the generated token vs the
reference engine is the next verification step (no correctness claim yet).

Verified: RUSTFLAGS="-D warnings" cargo test --workspace = 97/97 PASS;
lean proofs (5 files) green; GPU 18/18 + MXFP8 real parity + full forward PASS
(--features hip, --ignored).
This commit is contained in:
adm committed 2026-12-01 15:14:05 +01:00
1 parent 38ac957b26
commit 3c870743fe
5 files changed
+354 -33

No files matched your search

+11
View File
@@ -60,6 +60,7 @@ mod ffi {
packed: *const u8, scales: *const u8, outer_scale: c_float, x: *const c_float, y: *mut c_float,
n: c_int, k: c_int, stream: *mut c_void,
) -> c_int;
pub fn vetta_mxfp8_gemv(weights: *const u8, scales: *const u8, x: *const c_float, y: *mut c_float, n: c_int, k: c_int, stream: *mut c_void) -> c_int;
pub fn vetta_situ(gu: *const c_float, act: *mut c_float, inter: c_int, beta: c_float, lb: c_float, stream: *mut c_void) -> c_int;
pub fn vetta_moe_reduce(y_part: *const c_float, tk_w: *const c_float, out: *mut c_float, top_k: c_int, hidden: c_int, stream: *mut c_void) -> c_int;
pub fn vetta_shortconv4_decode(cur: *const c_float, static_w: *const c_float, hist: *mut c_float, out: *mut c_float, slot_ids: *const i32, m: c_int, c: c_int, stream: *mut c_void) -> c_int;
@@ -254,6 +255,16 @@ pub fn nvfp4_gemv(packed: &DeviceBuf, scales: &DeviceBuf, outer_scale: f32, x: &
Ok(())
}
/// Launch k_mxfp8_gemv (M=1): MXFP8 experts (E4M3 + UE8M0/32, no outer scale).
#[cfg(feature = "hip")]
pub fn mxfp8_gemv(weights: &DeviceBuf, scales: &DeviceBuf, x: &DeviceBuf, y: &DeviceBuf, n: i32, k: i32) -> Result<(), String> {
let rc = unsafe {
ffi::vetta_mxfp8_gemv(weights.ptr as *const u8, scales.ptr as *const u8, x.ptr as *const f32, y.ptr as *mut f32, n, k, std::ptr::null_mut())
};
if rc != 0 { return Err("mxfp8_gemv launch failed".into()); }
Ok(())
}
/// Launch k_situ: SiTU double-softcapped activation (gu=[gate;up] -> act).
#[cfg(feature = "hip")]
pub fn situ(gu: &DeviceBuf, act: &DeviceBuf, inter: i32, beta: f32, lb: f32) -> Result<(), String> {