Repository navigation
bf16_round: one std-only module, and the remaining fp32-to-bf16 copies on its bits() (#1863) - #2052
Merged
Merged
Conversation
ashhart
added a commit
that referenced
this pull request
Nov 3, 2026
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.
… easy-set copies on its bits() core/contract.zig and the engine share builds (tf-kernel-contract, fsr-metal-contract), so a second path import of core/bf16_round.zig puts the file in two modules; the named module, wired like save_guard, has one owner. Each replaced copy keeps its public name as an alias and is checked bit for bit against its old spelling on every zero, subnormal, infinity, tie and NaN class; NaN now stays NaN in each.
…lectives and living affine on its bits() Each copy keeps its name as an alias and is checked bit for bit against its old spelling on every zero, subnormal, infinity, tie and NaN class. affine_mm's and H3's copies had no NaN rule (a NaN came out +-Inf or a zero); it now stays NaN, as the other four already did. H3's modulation had no test run, so its check gets test-h3-modulation-bf16 under zig build test.
ashhart
added a commit
that referenced
this pull request
Nov 3, 2026
…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
force-pushed
the
lead/1863-bf16-rest
branch
from
November 3, 2026 23:02
bd96fdd to
9c7b30e
Compare
ashhart
added a commit
that referenced
this pull request
Nov 4, 2026
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.
ashhart
added a commit
that referenced
this pull request
Nov 4, 2026
…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
added a commit
that referenced
this pull request
Nov 4, 2026
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.
ashhart
added a commit
that referenced
this pull request
Nov 4, 2026
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1863, after #1986. The rest of the engine's hand-written fp32-to-bf16 rounding copies move onto core's
bf16_round.bits().bf16_roundbecomes a small std-only module that every module imports by name. A Zig 0.17 file joins one module per compilation, so a shared file couldn't be imported by path from several modules. The easy set moves onto it: Gemma 4 DFlash weights, core affine4, pair_rows_layout, affine4_host, quant/convert, the Qwen-VL tower, the MOSS-Image encoder, the Qwen-Image host and the GLM vision tower.affine_mm, the MOSS-Image host, H3 modulation, the fabric collectives and living affine move onto it too.Exactness: 15 copies move. Nine give identical bits on every input. The other six give identical bits on every non-NaN input, and a NaN now stays NaN where the old copy had no NaN rule (affine4, pair_rows_layout, affine_mm, H3 modulation, the MOSS-Image encoder, Gemma 4 DFlash). Each moved copy has a bit-identical test, and each test was checked to fail when broken.
h3/modulationwas run by no test step, so this addstest-h3-modulation-bf16undertest.Checks:
zig build,zig build dev-toolsandzig build testpass; lean stays at 424, andzig fmtis clean.