-
Notifications
You must be signed in to change notification settings - Fork 139
[FIX_FOR_VLLM_CUSTOM=e31915063da3f6d6be6080040de28f5bb6945acd] Fix GraphCaptureOutput stub and MultiModalDataDict import path #1280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| """Root-level conftest – ensures torch compatibility shims are applied | ||
| before any ``import vllm`` happens during the test session. | ||
| """ | ||
|
|
||
| import vllm_gaudi._torch_compat # noqa: F401 -- side-effect: patches GraphCaptureOutput alias | ||
|
Comment on lines
+2
to
+6
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,42 @@ | ||||||||
| # SPDX-License-Identifier: Apache-2.0 | ||||||||
| """Torch compatibility shim for Gaudi's custom PyTorch builds. | ||||||||
|
|
||||||||
| Gaudi's PyTorch build (2.9+hpu) cherry-picked the builtins fix from | ||||||||
| upstream PyTorch (pytorch/177558), which renamed ``GraphCaptureOutput`` | ||||||||
| to ``CaptureOutput`` and removed the ``get_runtime_env`` method. | ||||||||
|
|
||||||||
| vLLM's ``env_override.py`` (guarded by ``not is_torch_equal_or_newer("2.12.0")``) | ||||||||
| tries to import ``GraphCaptureOutput`` and patch its ``get_runtime_env``. | ||||||||
| On Gaudi's build this block must be skipped because the fix is already applied. | ||||||||
|
|
||||||||
| We inject a stub ``GraphCaptureOutput`` class with a ``get_runtime_env`` | ||||||||
| class-method so that ``env_override.py`` can import and "patch" it without | ||||||||
| error. The patched method is never actually called because the underlying | ||||||||
| PyTorch code already contains the fix. | ||||||||
|
|
||||||||
| This module is loaded: | ||||||||
| * In tests – via ``tests/conftest.py`` (runs before any ``import vllm``). | ||||||||
| * At runtime – via a ``.pth`` file installed into site-packages so that | ||||||||
| the shim is in place before *any* Python code imports ``vllm``. | ||||||||
| """ | ||||||||
|
|
||||||||
| try: | ||||||||
| import torch._dynamo.convert_frame as _cf | ||||||||
|
|
||||||||
| if not hasattr(_cf, "GraphCaptureOutput"): | ||||||||
| # The Gaudi PyTorch build already has the builtins fix applied; | ||||||||
| # create a stub so that env_override.py can import and monkey-patch | ||||||||
| # it harmlessly. | ||||||||
|
|
||||||||
| class _GraphCaptureOutputStub: | ||||||||
| """Stub standing in for the removed GraphCaptureOutput class.""" | ||||||||
|
|
||||||||
| def get_runtime_env(self): # type: ignore[override] | ||||||||
|
||||||||
| def get_runtime_env(self): # type: ignore[override] | |
| @classmethod | |
| def get_runtime_env(cls): # type: ignore[override] |
Copilot
AI
Mar 31, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This catches all exceptions and silently ignores them. Since this module is meant to protect imports, swallowing unexpected errors (e.g., API changes, AttributeError, RuntimeError during torch init) can make failures much harder to diagnose.
Prefer catching the specific expected failures (e.g., ImportError / ModuleNotFoundError) and, if you still want to proceed silently, consider at least logging at debug level for unexpected exception types.
| except Exception: | |
| except (ImportError, ModuleNotFoundError): |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1 @@ | ||||||
| import vllm_gaudi._torch_compat | ||||||
|
||||||
| import vllm_gaudi._torch_compat | |
| import vllm_gaudi_torch_compat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Installing the
.pthviadata_files=[('.', ...)]typically places it under the scheme'sdatadirectory (oftensys.prefix), not thepurelib/site-packagesdirectory where Python actually processes.pthfiles at startup. If it doesn't land insite-packages, the runtime shim won't run and the originalimport vllmfailure will persist.Please adjust the installation approach so the
.pthends up insite-packages(or use an alternative startup mechanism that is reliably loaded fromsite-packages).