Repository navigation
WoA: work around MSVC ARM64 miscompile in NEON bf16 conversion - #2155
Open
matthewdouglas wants to merge 1 commit into
Open
matthewdouglas wants to merge 1 commit into
matthewdouglas wants to merge 1 commit into
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
This branch has not been deployed
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.
Since GitHub moved the
windows-11-armrunner to the VS2026 image on Sep 30 (MSVC 14.51, then 14.52 since mid-November), the Windows ARM64 CPU tests have been failing for every torch version: bf16 dequantization returns NaN or garbage. There were 7 failures under 14.51 and 328 under 14.52, with no code change on our side. 0.50.2 was built before the image change and isn't affected.The cause is a known MSVC ARM64 codegen bug (google/XNNPACK#11368). In
neon_f32_to_bf16x4, the compiler fuses the integer rounding add with the preceding float multiply into an integerMLAon the float bit patterns. This change usesvaddhn_u32instead ofvaddq_u32+vshrn_n_u32, the same workaround XNNPACK used (google/XNNPACK#11330). The result is bit-identical, and it's one instruction shorter on all compilers.I checked the built
libbitsandbytes_cpu.dllfrom this branch: the 5 integermlainstructions at the bf16 conversion sites are gone, replaced byaddhn.cpu_ops.cppis built into every backend library, so this also fixes bf16 dequantization of CPU tensors in the Windows ARM64 CUDA builds.🤖 Generated with Claude Code