[Core] Per-visit ShortConv history (exact strata hist_pool_all + visit*stride)

Root cause found by reading strata run_sconv: the ShortConv history pool is
indexed by GLOBAL VISIT (hist_pool_all + rec_visit*stride), so each core pass
has its OWN history ring -- history does NOT carry across the 3 passes for the
same token. The previous shared-per-layer history made pass 1 read pass 0's
input as history (wrong). LayerState now holds hist_k/v/a/m as [DeviceBuf;3]
indexed by pass; layer_forward_swa/full + run_layer take a pass index (prelude/
coda=0, core=0/1/2). For a fresh token every visit reads zero history, matching
the reference. Single-token argmax moved (8->183618), confirming history matters.

Verified: cargo test --workspace + hip 17/17 + lean 0 sorryAx green.
This commit is contained in:
adm committed 2026-12-01 15:51:34 +01:00
1 parent 1221ac094a
commit df120e6f5f
2 files changed
+30 -25

No files matched your search

+2 -2
View File
@@ -635,7 +635,7 @@ mod tests {
let mut st = crate::layer::new_state(&dims, steps).unwrap();
let cur = DeviceBuf::alloc(hidden * 4).unwrap(); cur.h2d(&x).unwrap();
let mut blocks: Vec<DeviceBuf> = Vec::new();
crate::layer::layer_forward_swa(&ar, &lw, &mut st, &dims, &cur, &mut blocks, pos, None).unwrap();
crate::layer::layer_forward_swa(&ar, &lw, &mut st, &dims, &cur, &mut blocks, pos, 0, None).unwrap();
assert_eq!(blocks.len(), 1, "ip=0 must snapshot one depth block");
let mut got = vec![0f32; hidden]; cur.d2h(&mut got).unwrap();
@@ -754,7 +754,7 @@ mod tests {
let mut st = crate::layer::new_state(&dims, 1).unwrap();
let cur = DeviceBuf::alloc(hidden * 4).unwrap(); cur.h2d(&x).unwrap();
let mut blocks: Vec<DeviceBuf> = Vec::new();
crate::layer::layer_forward_full(&ar, &lw, &mut st, &dims, &cur, &mut blocks, pos, None).unwrap();
crate::layer::layer_forward_full(&ar, &lw, &mut st, &dims, &cur, &mut blocks, pos, 0, None).unwrap();
let mut got = vec![0f32; hidden]; cur.d2h(&mut got).unwrap();
// CPU oracle
let qn_f = read_bf16_f32(&ar, &format!("{l}.q_input_norm.weight"));