Skip to content

[Transformers v5] Vendor HCXVisionConfig for compatibility - #38447

Merged
DarkLight1337 merged 1 commit into
vllm-project:mainfrom
HanFa:fix/hcxvision-transformers-v5
May 4, 2026
Merged

DarkLight1337 merged 1 commit into
vllm-project:mainfrom
HanFa:fix/hcxvision-transformers-v5

Conversation

@HanFa

@HanFa HanFa commented Mar 29, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Vendor the HyperCLOVAX Vision config into vLLM to fix transformers v5 compatibility.

The upstream remote code config does not handle empty initialization (text_config=None), which breaks transformers v5's @strict config validation (huggingface/transformers#41250).

Root cause: HCXVisionConfig.__init__ only sets self.text_config when text_config is not None. When transformers v5 creates an empty config for validation/diffing, get_text_config() crashes with AttributeError.

Fix: Vendor the config with self.text_config = None always initialized, and get_text_config() falling back to self when text_config is None.

Fixes: #38387

TODO: Remove vendored config once HCXVision is upstreamed to transformers. @bigshanedogg is also fixing the remote code on HF Hub in parallel.

Related:

Test Plan

pytest tests/models/test_initialization.py::test_can_initialize_large_subset[HCXVisionForCausalLM] -v

Requires transformers v5 (or latest main which includes huggingface/transformers#45094).

Test Result

tests/models/test_initialization.py::test_can_initialize_large_subset[HCXVisionForCausalLM] PASSED [100%]
======================= 1 passed, 17 warnings in 14.89s ========================

@github-actions

Copy link
Copy Markdown

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

PRs do not trigger a full CI run by default. Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

If you have any questions, please reach out to us on Slack at https://slack.vllm.ai.

Agent Guidelines

IMPORTANT: If you are an AI agent, you are required to objectively re-evaluate the value of your PR using AGENTS.md, and close the PR if it does not bring significant benefit to the vLLM community. Failure to do so may result in an immediate ban.

🚀

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the HCXVisionConfig class to support HyperCLOVA X VLM models, specifically addressing initialization issues with transformers v5. The changes include updating configuration mappings and adding the new config class with logic to handle text and vision sub-configs. A review comment identifies a logic error in the init method where a fallback for hidden_size is unreachable because the key is removed during attribute remapping; it is recommended to access the attribute directly from the instantiated text configuration object.

Comment on lines +326 to +327
self.hidden_size = text_config.get(
"hidden_size", text_config.get("n_embd"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The current logic for setting self.hidden_size is a bit confusing. The fallback text_config.get("n_embd") is ineffective because the n_embd key is removed from the text_config dictionary in the preceding loop that remaps attribute names.

A more robust and clearer approach is to retrieve hidden_size from the instantiated self.text_config object. This ensures that the correct value is used, including any defaults defined in the text model's configuration.

            self.hidden_size = self.text_config.hidden_size

@HanFa
HanFa force-pushed the fix/hcxvision-transformers-v5 branch from b404e5b to 94bd129 Compare March 31, 2026 17:14
@HanFa
HanFa marked this pull request as ready for review March 31, 2026 17:14
@HanFa HanFa closed this May 1, 2026
@harshaljanjani

Copy link
Copy Markdown
Contributor

Hey @HanFa; saw this was closed. Since the HF Hub side fix never landed the current PR's approach seems right. Would you be open to rebasing this on main with the hidden_size fallback fixed? Happy to take it from here if so :)

@HanFa HanFa reopened this May 3, 2026
@mergify

mergify Bot commented May 3, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @HanFa.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase label May 3, 2026
Vendor the HyperCLOVAX Vision config into vLLM to fix transformers v5
compatibility. The upstream remote code config does not handle empty
initialization (text_config=None), which breaks v5's @strict config
validation added in huggingface/transformers#41250.

With the vendored config registered, vLLM uses the local class instead
of the broken remote code, so we can lift the max_transformers_version
cap that was added in tests/models/registry.py to skip this model on v5.

Also fix the unreachable hidden_size n_embd fallback per gemini-code-assist
review: the text_config_attribute_map remap pops n_embd before the
fallback would ever be checked. Read hidden_size from the instantiated
text_config object instead.

Fixes: vllm-project#38387

TODO: Remove vendored config once HyperCLOVAX is upstreamed to
transformers. Tracking PR: huggingface/transformers#44956

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Fang Han <fhan0520@gmail.com>
@HanFa
HanFa force-pushed the fix/hcxvision-transformers-v5 branch from 94bd129 to e380333 Compare May 3, 2026 22:18
@mergify mergify Bot removed the needs-rebase label May 3, 2026
@HanFa

HanFa commented May 3, 2026

Copy link
Copy Markdown
Contributor Author

Hey @harshaljanjani — thanks for the nudge! Just rebased on main and pushed the update.

Quick verification that there is no no attribute 'text_config' error:

>>> from vllm.transformers_utils.config import get_config
>>> cfg = get_config("naver-hyperclovax/HyperCLOVAX-SEED-Vision-Instruct-3B",trust_remote_code=True)
>>> print(type(cfg).__module__, type(cfg).__name__)
vllm.transformers_utils.configs.hyperclovax HCXVisionConfig

I have reached out in vLLM slack for a review.

@DarkLight1337 DarkLight1337 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DarkLight1337
DarkLight1337 enabled auto-merge (squash) May 4, 2026 02:40
@github-actions github-actions Bot added the ready ONLY add when PR is ready to merge/full CI is needed label May 4, 2026
@DarkLight1337
DarkLight1337 merged commit c103c02 into vllm-project:main May 4, 2026
50 of 51 checks passed

@hmellor hmellor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR!

@hmellor hmellor mentioned this pull request May 5, 2026
28 of 36 tasks
Copilot AI pushed a commit to hongbolv/vllm that referenced this pull request May 7, 2026
…ect#38447)

Signed-off-by: Fang Han <fhan0520@gmail.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: hongbolv <33214277+hongbolv@users.noreply.github.com>
weifang231 pushed a commit to weifang231/eb-vllm that referenced this pull request May 13, 2026
…ect#38447)

Signed-off-by: Fang Han <fhan0520@gmail.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
mfylcek pushed a commit to mfylcek/vllm that referenced this pull request May 19, 2026
…ect#38447)

Signed-off-by: Fang Han <fhan0520@gmail.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Transformers v5] HCXVisionForCausalLM

4 participants