Skip to content

[Core]ModelConfig use architecture rather than archiectures#31633

Open
charlotte12l wants to merge 13 commits intovllm-project:mainfrom
charlotte12l:arch_name
Open

[Core]ModelConfig use architecture rather than archiectures#31633
charlotte12l wants to merge 13 commits intovllm-project:mainfrom
charlotte12l:arch_name

Conversation

@charlotte12l
Copy link
Contributor

@charlotte12l charlotte12l commented Jan 3, 2026

Purpose

Currently, hf_config/PretrainedConfig has s field architectures which is of type None| List[str]. However, when it's a List, it always of length 1 according to @hmellor in #28454 (comment)

Therefore, this PR follow the discussion #28454 (comment) and consolidate to always use architecture in ModelConfig. We will raise error if config architecture is different from inspected model cls architecture

Test Plan

python -m pytest tests/config/test_model_arch_config.py

Test Result

passed


Essential Elements of an Effective PR Description Checklist
  • [x ] The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • [ x] The test plan, such as providing test command.
  • [x ] The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

cc @heheda12345 @hmellor @DarkLight1337

Signed-off-by: Xingyu Liu <charlotteliu12x@gmail.com>
Signed-off-by: Xingyu Liu <charlotteliu12x@gmail.com>
Signed-off-by: Xingyu Liu <charlotteliu12x@gmail.com>
@mergify mergify bot added the new-model Requests to new models label Jan 3, 2026
Copy link
Contributor

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

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 refactors the handling of model architectures by transitioning from a list of architectures (architectures: list[str]) to a single architecture string (architecture: str) across the codebase. This change impacts configuration files (base_model_arch_groundtruth.json, draft_model_arch_groundtruth.json), test assertions, and core logic within vllm/config/model.py, vllm/config/model_arch.py, vllm/lora/layers/fused_moe.py, vllm/model_executor/models/registry.py, vllm/model_executor/models/transformers/moe.py, and vllm/transformers_utils/model_arch_config_convertor.py. The ModelArchitectureConfig class is updated to reflect this, and methods that previously accepted or returned a list of architectures now handle a single string. A review comment highlighted a potential AttributeError in vllm/model_executor/models/transformers/moe.py where self.config.architecture was used instead of the correct self.config.architectures[0] for transformers.PretrainedConfig objects, which was subsequently addressed by the author.

xingyuliu and others added 2 commits January 3, 2026 23:05
Signed-off-by: Xingyu Liu <charlotteliu12x@gmail.com>
Signed-off-by: Xingyu Liu <charlotteliu12x@gmail.com>
@charlotte12l
Copy link
Contributor Author

Just fyi @heheda12345 @hmellor I found some risky codes when writing this PR:

EAGLE models uses EAGLEConfig to update hf_config architectures in draft_model_config. However, draft_model_config 's model_info and resolved architecture are not updated. Therefore, for eagle draft models, hf_config.architectures is EagleLlamaForCausalLM but draft_model_config.architecture is LlamaForCausalLM. I didn't find a good way to resolve this, unless we re-inspect model_cls.

eagle_config = EAGLEConfig(
self.draft_model_config.hf_config,
method=self.method,
model_type="eagle",
)
self.draft_model_config.hf_config = eagle_config
self.draft_model_config.model_arch_config = (
self.draft_model_config.get_model_arch_config()
)

@charlotte12l charlotte12l changed the title [Misc]ModelConfig use architecture rather than archiectures [Core]ModelConfig use architecture rather than archiectures Jan 4, 2026
Signed-off-by: Xingyu Liu <charlotteliu12x@gmail.com>
@heheda12345
Copy link
Collaborator

Just fyi @heheda12345 @hmellor I found some risky codes when writing this PR:

EAGLE models uses EAGLEConfig to update hf_config architectures in draft_model_config. However, draft_model_config 's model_info and resolved architecture are not updated. Therefore, for eagle draft models, hf_config.architectures is EagleLlamaForCausalLM but draft_model_config.architecture is LlamaForCausalLM. I didn't find a good way to resolve this, unless we re-inspect model_cls.

eagle_config = EAGLEConfig(
self.draft_model_config.hf_config,
method=self.method,
model_type="eagle",
)
self.draft_model_config.hf_config = eagle_config
self.draft_model_config.model_arch_config = (
self.draft_model_config.get_model_arch_config()
)

Is this a bug on main branch?

@charlotte12l
Copy link
Contributor Author

charlotte12l commented Jan 5, 2026

Just fyi @heheda12345 @hmellor I found some risky codes when writing this PR:
EAGLE models uses EAGLEConfig to update hf_config architectures in draft_model_config. However, draft_model_config 's model_info and resolved architecture are not updated. Therefore, for eagle draft models, hf_config.architectures is EagleLlamaForCausalLM but draft_model_config.architecture is LlamaForCausalLM. I didn't find a good way to resolve this, unless we re-inspect model_cls.

eagle_config = EAGLEConfig(
self.draft_model_config.hf_config,
method=self.method,
model_type="eagle",
)
self.draft_model_config.hf_config = eagle_config
self.draft_model_config.model_arch_config = (
self.draft_model_config.get_model_arch_config()
)

Is this a bug on main branch?

Yes, it's on main. Let me try to fix it first in a separate PR

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Comment @cursor review or bugbot run to trigger another review on this PR

Signed-off-by: Xingyu Liu <charlotteliu12x@gmail.com>
@charlotte12l
Copy link
Contributor Author

Yes, it's on main. Let me try to fix it first in a separate PR

fixed in #31753

Signed-off-by: Xingyu Liu <charlotteliu12x@gmail.com>
Signed-off-by: Xingyu Liu <charlotteliu12x@gmail.com>
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
@22quinn 22quinn added the ready ONLY add when PR is ready to merge/full CI is needed label Jan 27, 2026
@22quinn
Copy link
Collaborator

22quinn commented Jan 27, 2026

Test failures look legit

AttributeError: 'ModelConfig' object has no attribute '_architecture'. Did you mean: 'architecture'?

Signed-off-by: Xingyu Liu <charlotteliu12x@gmail.com>
Signed-off-by: Xingyu Liu <charlotteliu12x@gmail.com>
@charlotte12l
Copy link
Contributor Author

Currently, hf_config/PretrainedConfig has s field architectures which is of type None| List[str]. However, when it's a List, it always of length 1 according to @hmellor in #28454 (comment)

@hmellor Just found some models have multiple architectures :(

Would appreciate any suggestions on how to proceed! cc @heheda12345

@mergify
Copy link

mergify bot commented Jan 31, 2026

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

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 Jan 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase new-model Requests to new models 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.

3 participants