Fix: Resolve circular import in model_loader/utils.py #29189
+7
−6
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.
Purpose
Fixes a circular import error where
vllm.model_executor.model_loader.utilscould not be imported because it attempted to import frommodels.adaptersat the top level, whilemodels.adapters(indirectly) depends onutils.Fixes #29110
Test Plan
I verified this locally by attempting to import the module in an isolated script to ensure the circular dependency chain is broken.
Verification Script:
Test Result
ImportError: cannot import name 'process_weights_after_loading' from 'vllm.model_executor.model_loader.utils'Success! Circular dependency is fixed.Additional Context
The import of
as_embedding_model,as_reward_model,as_seq_cls_model, andtry_create_mm_pooling_model_clswas moved from the global scope ofutils.pyintoget_model_architecture()where they are actually used. This defers the import execution and resolves the cycle.