Repository navigation
Fix the numerical behavior and initialization items of the 0.10.0 review - #401
Merged
Merged
Conversation
- An all-padding batch column no longer gives NaN: its attention output is zero, as in transformers' sdpa (`query_lengths` replaces `sliding_window_q_lengths`). - Granite's residual, embedding and logits multipliers round the product, not the scalar, in Float16/BFloat16, as torch does. - The Qwen3.5 `A_log` stays Float32 under 16-bit eltypes. - A ViT with `init_values = 0` builds no layer scale, as in timm. - The convolutions of the MobileNetV4 hybrid attention start from xavier_uniform. The tolerance of the Float16 check of qwen3_5_tiny goes from 6e-2 to 7e-2: the error is 0.0603, 0.0600 with a 16-bit A_log. Part of #342. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
CarloLucibello
force-pushed
the
cl/numerical-behavior-fixes
branch
from
November 8, 2026 08:59
678380c to
871eb19
Compare
37 of 42 tasks
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.
Fixes the five open items under "Numerical behavior and initialization" in #342.
sdpa, in the language models, the BERT-like encoders and the CLIP and SigLIP text encoders.residual_multiplier,embedding_multiplierandlogits_scalinground the product, not the scalar, in Float16/BFloat16, as torch does. Aresidual_multiplierof 0.22 had scaled every residual branch by 0.2197 in BFloat16.A_logstays Float32 under 16-bit eltypes, as in the checkpoints and in vLLM. transformers rounds it, so this differs from it on purpose; the effect is far below the half-precision noise.init_values = 0builds no layer scale, as in timm.xavier_uniform, as in timm (random initialization only).Notes:
qwen3_5_tinygoes fromrtol6e-2 to 7e-2: its error is 0.0603, and was 0.0600 with a 16-bitA_log.+rounds some ties wrongly on AArch64 without bf16 ([AArch64] Vectorized bfloat fadd without +bf16 is not correctly rounded: the round-to-even bias is taken from the operand, not the sum llvm/llvm-project#240103). The new Granite test avoids it.Part of #342; its boxes can be ticked once this merges.
🧔♂️🤖 Assisted by AI