Skip to content

Conversation

@yeqcharlotte
Copy link
Collaborator

@yeqcharlotte yeqcharlotte commented Dec 6, 2025

Summary:
Fixes circular import error introduced by upstream vLLM PR #29966 which added a module-level import that creates a circular dependency chain which causes the following errors:

cannot import name 'ConfigFormat' from partially initialized module

This circular import happens because:

  vllm/transformers_utils/config.py
    → imports from vllm.config.utils
    → requires vllm/config/__init__.py to execute first (Python package rule)
    → which imports from vllm.config.model
    → which imports from vllm.transformers_utils.config
    → DEADLOCK: transformers_utils/config can't finish initializing!

Test Plan:

  • The tests with following errors now pass: "cannot import name 'ConfigFormat' from partially initialized module"

Differential Revision: D88549243

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 effectively resolves a circular import issue in vllm.transformers_utils.config.py. By moving the import of getattr_iter from the module level to inside the patch_rope_parameters function, the import is deferred until runtime, which correctly breaks the dependency cycle. This is a standard and appropriate solution for this type of problem. The change is well-contained and correct, and I have no further suggestions.

@yeqcharlotte yeqcharlotte changed the title Fix circular import in vllm.transformers_utils.config [Misc] Fix circular import in vllm.transformers_utils.config Dec 6, 2025
Summary:
Fixes circular import error introduced by upstream vLLM PR vllm-project#29966 that prevented
module initialization for on_host_prefix_cache_connector_test and other tests.

The upstream commit 1c51457c2ded ("Access `partial_rotary_factor` from `rope_parameters`")
added a module-level import that creates a circular dependency chain:

  vllm/transformers_utils/config.py
    → imports from vllm.config.utils
    → requires vllm/config/__init__.py to execute first (Python package rule)
    → which imports from vllm.config.model
    → which imports from vllm.transformers_utils.config
    → DEADLOCK: transformers_utils/config can't finish initializing!

The fix moves the getattr_iter import from module-level (line 28) to inside the
patch_rope_parameters() function (line 307). This defers the import until the
function is actually called at runtime, which happens after all modules are fully
initialized, breaking the circular dependency.

Test Plan:
- buck2 test fbcode//vllm/fb/distributed:on_host_prefix_cache_connector_test
  Result: PASS (8/8 tests, was failing with "cannot import name 'ConfigFormat' from partially initialized module")

- buck2 test fbcode//smart/inference_platform_sp/llm_predictor_gpu/predictor/conversion/tests:generate_test
  Result: PASS (was failing with same circular import error)

Note: test_wf_audio still has an unrelated runtime error ("mat1 and mat2 shapes
cannot be multiplied") that existed before these changes and is not related to
the circular import fix.

Differential Revision: D88549243

Signed-off-by: Ye (Charlotte) Qi <yeq@meta.com>
@yeqcharlotte yeqcharlotte added the ready ONLY add when PR is ready to merge/full CI is needed label Dec 6, 2025
@yeqcharlotte yeqcharlotte enabled auto-merge (squash) December 6, 2025 07:10
@yeqcharlotte yeqcharlotte merged commit 92c35ab into vllm-project:main Dec 6, 2025
47 of 48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fb-exported meta-exported 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.

4 participants