[HIP] BF16 round-to-nearest-even parity (cast, ctrl pack, shortconv history)
Reference comparison (strata-inkling --serve ground truth) exposed a systematic precision bug: vetta truncated f32->bf16 (>>16) while the reference f32_to_bf16 rounds to nearest even (0x7FFF + ((u>>16)&1)). Truncation bias accumulates over the 48-visit loop and drifts the residual stream. - k_cast_f32_bf16: round-to-nearest-even (was truncation). - k_ctrl_pack: packed cur/msg bf16 now round-to-nearest-even. - k_shortconv4_decode / k_shortconv4_dyn_decode: history ring rounded through bf16 between steps (exact strata "Round through BF16 between steps"), via a new bf16_round device helper. - CPU oracles updated to match (packer bf16_trunc, hip f32_to_bf16 + the shortconv/controller test history shifts). Effect on the full forward (single token 100, reference argmax 68014): argmax moved 100 -> 8 and logit[68014] rose 8.6 -> 11.1 (toward the reference), confirming the rounding fix is real and directional. Generation from "The capital of France is" (prompt ids verified identical to the reference) now produces structured text but the argmax still diverges from the reference " Paris" — further precision/composition parity is in progress (reference uses fp16 KV cache + fp16 expert input; candidate next mismatches). Verified: RUSTFLAGS="-D warnings" cargo test --workspace = 97/97 PASS; GPU 17/17 (--features hip, --ignored) green with the rounded oracles; lean proofs (5 files) green.
This commit is contained in:
1 parent
edcfab6548
commit
1221ac094a
4 files changed
+109
-18
No files matched your search
@@ -382,7 +382,7 @@ pub fn forward_inkling_with_state(
|
||||
blocks.truncate(n_prelude_blocks);
|
||||
}
|
||||
for ip in 6..18 {
|
||||
if p > 0 {
|
||||
if p > 0 && std::env::var("VETTA_NO_CTRL").is_err() {
|
||||
let mq = load_msg_queries(ar, ip, h)?;
|
||||
let n_bank = bank.len();
|
||||
let blk = DeviceBuf::alloc(n_bank.max(1) * h * 4)?;
|
||||
@@ -729,6 +729,7 @@ mod tests {
|
||||
let vocab = 201024usize;
|
||||
let prompt = "The capital of France is";
|
||||
let ids: Vec<i32> = tok.encode(prompt, false).unwrap().get_ids().iter().map(|&x| x as i32).collect();
|
||||
eprintln!("[gen] prompt_ids={ids:?}");
|
||||
let n_gen = 16usize;
|
||||
let max_seq = ids.len() + n_gen + 2;
|
||||
let mut states: Vec<Option<LayerState>> = (0..24).map(|_| None).collect();
|
||||
|
||||
Reference in new issue
Block a user