From ff781825b657a4510ab32b0783b493e3d0088155 Mon Sep 17 00:00:00 2001 From: rzou Date: Mon, 28 Apr 2025 15:33:20 -0700 Subject: [PATCH] Ignore `''` filepath vLLM tries to get a list of files that Dynamo traced through. Some of these files can be equal to `''`. This may happen if the code object was dynamically generated, which does happen in some dataclasses cases. This is one of the issues that was blocking the upgrade of vLLM from PyTorch 2.6 to PyTorch 2.7 (#16859). The reason why this happened was because PyTorch 2.7 now traces through more HuggingFace code, including some custom dataclasses. Test Plan: - ran `pytest -v tests/models/test_transformers.py -k test_models[meta-llama/Llama-3.2-1B-Instruct-transformers]` with PyTorch >= 2.7 Signed-off-by: rzou --- vllm/compilation/backends.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vllm/compilation/backends.py b/vllm/compilation/backends.py index c493a764f56..3a0b07f833a 100644 --- a/vllm/compilation/backends.py +++ b/vllm/compilation/backends.py @@ -382,6 +382,10 @@ def __call__(self, graph: fx.GraphModule, example_inputs) -> Callable: hash_content = [] for filepath in forward_code_files: hash_content.append(filepath) + if filepath == "": + # This means the function was dynamically generated, with + # e.g. exec(). We can't actually check these. + continue with open(filepath) as f: hash_content.append(f.read()) import hashlib