Skip to content

Fix the numerical behavior and initialization items of the 0.10.0 review - #401

Merged
CarloLucibello merged 1 commit into
masterfrom
cl/numerical-behavior-fixes
Nov 8, 2026
Merged

CarloLucibello merged 1 commit into
masterfrom
cl/numerical-behavior-fixes

Conversation

@CarloLucibello

Copy link
Copy Markdown
Member

Fixes the five open items under "Numerical behavior and initialization" in #342.

  • An all-padding batch column gave NaN logits. Its attention output is now zero, as in transformers' sdpa, in the language models, the BERT-like encoders and the CLIP and SigLIP text encoders.
  • Granite's residual_multiplier, embedding_multiplier and logits_scaling round the product, not the scalar, in Float16/BFloat16, as torch does. A residual_multiplier of 0.22 had scaled every residual branch by 0.2197 in BFloat16.
  • The Qwen3.5 A_log stays 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.
  • A ViT with init_values = 0 builds no layer scale, as in timm.
  • The convolutions of the MobileNetV4 hybrid attention start from xavier_uniform, as in timm (random initialization only).

Notes:

Part of #342; its boxes can be ticked once this merges.

🧔‍♂️🤖 Assisted by AI

- 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
CarloLucibello force-pushed the cl/numerical-behavior-fixes branch from 678380c to 871eb19 Compare November 8, 2026 08:59
@CarloLucibello
CarloLucibello merged commit 7545c2c into master Nov 8, 2026
4 of 5 checks passed
@CarloLucibello CarloLucibello mentioned this pull request Nov 8, 2026
37 of 42 tasks
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