Skip to content

oracles: the last fp32-to-bf16 copies round with core's bits() (#1863) - #2055

Merged
ashhart merged 2 commits into
mainfrom
lead/1863-oracles
Nov 4, 2026
Merged

ashhart merged 2 commits into
mainfrom
lead/1863-oracles

Conversation

@ashhart

@ashhart ashhart commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Part of #1863, the last part, after #1986 and #2052. The last eight copies that added the rounding bias with a plain + now use core's bf16_round: seven test oracles (GLM attention, KV8, launch and EH checks; the Nemotron train check; HIP Flash Next kernel tests; LFM2 DSpark), plus XPU's FP64 GDN reference. Inputs 0xffff8000-0xffffffff used to overflow, panicking in Debug and wrapping in ReleaseFast. They now give a NaN.

A one-off sweep over all 2^32 inputs found the 4,278,190,082 non-NaN inputs bit-identical, and all 16,777,214 NaNs give a NaN. 131,072 positive NaNs used to round to Inf or -0. No finite input changes. Each file gets a test of 0xffffffff plus 2^19 sampled inputs (the tie and carry edges, then random words), and each failed before the fix. Lean is unchanged, and zig fmt is clean.

@ashhart

ashhart commented Nov 3, 2026

Copy link
Copy Markdown
Owner Author

Rebased onto #2052. The macOS dev-tools build failed here with bf16_round.zig: file exists in modules contract and owner: one oracle imported core/bf16_round.zig by path from inside the contract module. #2052 makes bf16_round a named module, so this now sits on #2052 and every oracle imports it by name. It lands after #2052. The full dev-tools build, the kernel-contract and golden tests, and the family steps pass. The one failure is the HTTPS-tunnel test, which fails on #2052 alone too.

GLM's attn, eh and launch checks and CUDA FP8 KV reference, Nemotron's
training scan check, LFM2's DSpark taps test, Flash Next's HIP kernel
tests and the XPU FP64 GDN reference added the rounding bias with a plain
`+` and no NaN branch, so 0xffff8000-0xffffffff overflowed (a Debug panic).
Each now imports bf16_round by name, as #2052's callers do; a path import
would put core/bf16_round.zig in a second module beside the named one, so
tf-kernel-contract and the other tools importing the engine would not
compile. No build change. A test in each file pins 0xffffffff to a NaN
and the old bits on every bf16 value's tie and carry edges plus random
words; a one-off sweep of all 2^32 inputs gives the old bits on every
non-NaN and a NaN on every NaN.

Part of #1863; sits on #2052.
…st under zig build test

xpu/fp64_gdn.zig was compiled only into the xpu-qwen27 runner executable, so its test ran under no
build step, even with an Intel GPU. hostTests now roots a host module at it with the same stand-ins as
the host Qwen27 module (empty kernel images, the host ze table, core), so it needs neither ocloc nor a
device and runs on Linux and macOS. Dropping bits()'s NaN branch fails it at 0xffffffff.

Part of #1863; sits on #2052.
@ashhart
ashhart merged commit c8785fc into main Nov 4, 2026
7 of 11 checks passed
@ashhart
ashhart deleted the lead/1863-oracles branch November 10, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant