Add GroupViT to NormalizedConfigManager; fix NormalizedTextAndVisionConfig attribute resolution - #2513
Open
kratos0718 wants to merge 1 commit into
Open
Add GroupViT to NormalizedConfigManager; fix NormalizedTextAndVisionConfig attribute resolution#2513kratos0718 wants to merge 1 commit into
kratos0718 wants to merge 1 commit into
Conversation
resolution bug in NormalizedTextAndVisionConfig
GroupViT has an ONNX export config but was missing from
NormalizedConfigManager. It's a dual text/vision encoder with the same
text_config/vision_config shape Pix2StructNormalizedTextConfig already
handles, so registering it should have been a one-line reuse of that
existing class.
It wasn't: NormalizedTextAndVisionConfig.__getattr__ prefixes the raw
accessor name (e.g. "num_layers") onto the sub-config path, instead of
first resolving it through the NUM_LAYERS-style constant mapping to the
config's real attribute name ("num_hidden_layers"). This happened to work
for Pix2Struct only because its text_config defines both num_layers and
num_hidden_layers as synonyms - it silently breaks for any model whose
sub-config only has the standard name, which is every other model with
this shape.
Fixed __getattr__ to resolve the mapped name before prefixing. Pinned
Pix2Struct's existing num_layers/hidden_size/num_attention_heads values
in a regression test so this can't quietly break again.
This was referenced Sep 22, 2026
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.
Summary
Part of #351. GroupViT already has an ONNX export config but was missing from
NormalizedConfigManager.GroupViT is a dual text/vision encoder — same
text_config/vision_configshapePix2StructNormalizedTextConfigalready handles — so registering it should have been a one-line reuse of that existing class. It wasn't, because of a real bug this surfaced:The bug:
NormalizedTextAndVisionConfig.__getattr__prefixes the raw accessor name (e.g."num_layers") onto the sub-config path, instead of first resolving it through theNUM_LAYERS-style constant mapping to the actual underlying config attribute name ("num_hidden_layers"). Concretely,.num_layerswas doinggetattr(text_config, "num_layers")instead ofgetattr(text_config, "num_hidden_layers").This happened to work for Pix2Struct only because its
text_configdefines bothnum_layersandnum_hidden_layersas synonyms — coincidence, not correctness. It silently breaks (raisesAttributeError) for any model with this same composite shape whose sub-config only has the standard name, which is every other model that would use this class, including GroupViT, OwlViT, OwlV2 and SigLIP.The fix: resolve the mapped name (
getattr(self, attr_name.upper(), attr_name)) before prefixing it with the sub-config path, so the correct underlying attribute name is looked up on the nested config either way."groupvit": Pix2StructNormalizedTextConfigto_conf(alphabetically, betweengptjandimagegpt)groupvitfrom theTODO: missing normalized configscommentNormalizedTextAndVisionConfig.__getattr__in the same fileTest plan
test_groupvit_normalizes_expected_attributes: instantiates a realGroupViTConfig()and assertshidden_size/num_attention_heads/num_layers/image_size/num_channelsall resolve correctly against the nestedtext_config/vision_configtest_pix2struct_num_layers_unaffected_by_the_groupvit_fixas an explicit regression guard, pinning Pix2Struct's existing normalized values so the fix can't silently regress thempython -m unittest) against the actualtransformers.GroupViTConfigandtransformers.Pix2StructConfig(not mocked) — all 3 tests passFollow-up
OwlViT, OwlV2 and SigLIP have the exact same shape and are also fixed by this change — I'll open those as separate PRs once this one's reviewed, since they're independent registrations, not because they need anything different.