Skip to content

Add DETR to NormalizedConfigManager - #2510

Open
kratos0718 wants to merge 1 commit into
huggingface:mainfrom
kratos0718:add-detr-normalized-config
Open

kratos0718 wants to merge 1 commit into
huggingface:mainfrom
kratos0718:add-detr-normalized-config

Conversation

@kratos0718

Copy link
Copy Markdown

Summary

Part of #351. DETR already has an ONNX export config but was missing from NormalizedConfigManager, so ORTOptimizer can't run on it yet.

  • Added "detr": NormalizedTextConfig to _conf (alphabetically, between deit and dinov2)
  • Removed detr from the TODO: missing normalized configs comment above it

Unlike the other recent additions on this issue (ConvNeXT, BEiT, LeViT, etc., all vision models needing NormalizedVisionConfig), DETR needs its transformer encoder stats: hidden_size, num_attention_heads, num_hidden_layers. DetrConfig stores these under d_model, encoder_attention_heads, and encoder_layers, but DetrConfig.attribute_map already aliases all three to the names NormalizedTextConfig looks for, so getattr(config, "hidden_size") etc. resolves directly with no custom with_args(...) mapping needed (unlike e.g. BartLikeNormalizedTextConfig, whose config doesn't have this alias).

Test plan

  • Added two tests to tests/utils/test_normalized_config.py: one confirming detr resolves to NormalizedTextConfig, and one instantiating a real DetrConfig() and asserting the normalized hidden_size/num_attention_heads/num_layers match d_model/encoder_attention_heads/encoder_layers
  • Ran both locally against the actual transformers.DetrConfig (not mocked) — both pass

DETR has an ONNX export config but was missing from NormalizedConfigManager.
Its config exposes hidden_size, num_attention_heads and num_hidden_layers
through its own attribute_map (aliasing d_model, encoder_attention_heads and
encoder_layers respectively), so plain NormalizedTextConfig resolves them
with no custom optimum-side mapping needed.
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