pub fn f32_to_bf16(val: f32) -> u16Expand description
Convert f32 to BF16 with IEEE-754 round-to-nearest-even.
Must stay byte-identical to PyTorch’s torch.float32 -> torch.bfloat16
cast: reference activations and the dequanted-weight snapshots Atlas is
scored against are produced that way, so any drift here shows up as an
accuracy regression with no other symptom.
Phase 2b (FP8 dequant audit, 2026-05-24) replaced truncation
(bits >> 16) with ties-to-even. Truncation is biased toward zero and
the bias accumulated across the 31745 dequanted tensors of
Qwen3.6-35B-FP8 to a mean per-layer cosine of 0.969.
NaN maps to the canonical quiet-NaN pattern with the sign preserved, which is also what PyTorch does.
ATLAS_DISABLE_RNE is a bisect escape hatch that reverts to
truncation. It is a PRESENCE check, not a value check — =0 disables
RNE just as =1 does.