Repository navigation
SAM 3 skeleton test: compare against a float32 load and find the RoPE tables by any spelling - #14318
Merged
Merged
Conversation
… tables by any spelling On transformers 5.x the RoPE buffers are rotary_emb.inv_freq and position_ids, so the 'rope' name check failed every PR's (Python 3.13, a-k) shard. Behind it, from_pretrained(dtype = bfloat16) casts the global-attention position_ids to bf16 on some 5.x releases, so the reference is now a float32 load, which is what the skeleton deliberately builds.
Member
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.
Problem
(Python 3.13, a-k)fails on every PR since #14310 merged (for example #14316 and #14317, both on base fb372c1):#14310 showed the same failure on its own run before merging. Reproduced locally with transformers 5.18 (CI resolves 5.17.0); the 4.57 floor has no
Sam3Model, so the test skips there.There are two layers:
rotary_emb.inv_freq,rotary_emb.original_inv_freqandposition_ids; none containsrope.from_pretrained(dtype = bfloat16)casts the ViT'sposition_idsto bf16 on 5.18, while_build_skeletonbuilds them in float32 on purpose. They are not just a different dtype: layer 1 (global attention) has different values in bf16, and swapping the skeleton's buffers into the dense model changes the vision encoder output. That is exactly the 0.04 shift the test's docstring describes, so the skeleton is right and a bf16 load is not a valid reference.Fix
Test only:
from_pretrained(dtype = float32), the exact tables the skeleton is meant to reproduce on every transformers version.rope,rotaryorposition_ids.Testing
test_diffusion_segment_quant.pywith transformers 5.18: 37 passed, 3 skipped. On main the skeleton test fails as in CI._default_dtype(torch.float32)(the regression the test exists for) makes it fail onposition_ids.test_diffusion_segment.pywithtest_diffusion_segment_quant.py: 109 passed, 3 skipped.Not covered here
The dense bf16 path (
Sam3Model.from_pretrained(..., dtype = dtype)indiffusion_segment.py) gets the roundedposition_idson 5.18, so on that release its masks differ from the pre-quantized path's. That is a product question for the segmenter, separate from this CI fix.