Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
SAM 3 skeleton test: compare against a float32 load and find the RoPE tables by any spelling (#14318)
Daniel Han5c8ccce8702e
diff --git a/studio/backend/tests/test_diffusion_segment_quant.py b/studio/backend/tests/test_diffusion_segment_quant.pyindex da4f70054f3..9c8f212dcb0 100644--- a/studio/backend/tests/test_diffusion_segment_quant.py+++ b/studio/backend/tests/test_diffusion_segment_quant.py@@ -688,7 +688,7 @@ def test_tiny_dequantized_weights_match_the_quantized_values(tmp_path, monkeypatdef test_skeleton_buffers_match_from_pretrained(tmp_path):- """The quantized load builds the model around the file; its buffers must be from_pretrained's. At SAM 3's real+ """The quantized load builds the model around the file; its buffers must be a float32 load's. At SAM 3's real1008 px input the ViT's global-attention RoPE tables are exact only when built in float32 (a bf16 default movedthem by up to 0.04 and every mask with them), so the skeleton is built in float32 whatever the caller's default."""transformers = pytest.importorskip("transformers")@@ -700,8 +700,10 @@ def test_skeleton_buffers_match_from_pretrained(tmp_path):config = _tiny_config()config.vision_config.backbone_config.image_size = 1008transformers.Sam3Model(config).to(torch.bfloat16).save_pretrained(tmp_path)+ # The float32 load is the reference: some 5.x releases (5.18 here) cast the global-attention position_ids to+ # bf16 under from_pretrained(dtype = bfloat16), moving the tables; others keep them in float32.dense = dict(- transformers.Sam3Model.from_pretrained(tmp_path, dtype = torch.bfloat16).named_buffers()+ transformers.Sam3Model.from_pretrained(tmp_path, dtype = torch.float32).named_buffers())previous = torch.get_default_dtype()torch.set_default_dtype(torch.bfloat16)@@ -709,7 +711,11 @@ def test_skeleton_buffers_match_from_pretrained(tmp_path):built = dict(sq._build_skeleton(str(tmp_path)).named_buffers())finally:torch.set_default_dtype(previous)- assert dense.keys() == built.keys() and any("rope" in name for name in dense)+ # The RoPE tables: `rotary_emb.inv_freq` and `position_ids` in transformers 5.x, "rope" in other spellings.+ rope = [+ name for name in dense if any(key in name for key in ("rope", "rotary", "position_ids"))+ ]+ assert dense.keys() == built.keys() and rope, sorted(dense)for name, value in dense.items():assert built[name].dtype == value.dtype and torch.equal(built[name], value), name