[Bugfix] Restore model info caching for package backends (#52690)
Signed-off-by: haoyang.qian <haoyangqian@gmail.com> Co-authored-by: OpenAI Codex <codex@openai.com>
This commit is contained in:
@@ -173,6 +173,36 @@ def test_lazy_modelinfo_package_hash_includes_submodules(tmp_path):
|
|||||||
assert first_hash != second_hash
|
assert first_hash != second_hash
|
||||||
|
|
||||||
|
|
||||||
|
def test_lazy_modelinfo_package_attempts_cache_load(monkeypatch):
|
||||||
|
cached_model_info = object()
|
||||||
|
loaded_hashes = []
|
||||||
|
|
||||||
|
def fake_load_cache(self, module_hash):
|
||||||
|
loaded_hashes.append(module_hash)
|
||||||
|
return cached_model_info
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
_LazyRegisteredModel,
|
||||||
|
"_load_modelinfo_from_cache",
|
||||||
|
fake_load_cache,
|
||||||
|
)
|
||||||
|
monkeypatch.setattr(
|
||||||
|
"vllm.model_executor.models.registry._run_in_subprocess",
|
||||||
|
lambda _: pytest.fail("Package-backed model should use the cache path"),
|
||||||
|
)
|
||||||
|
|
||||||
|
registered_model = _LazyRegisteredModel(
|
||||||
|
module_name="vllm.model_executor.models.transformers",
|
||||||
|
class_name="TransformersForCausalLM",
|
||||||
|
)
|
||||||
|
|
||||||
|
result = registered_model.inspect_model_cls()
|
||||||
|
|
||||||
|
assert result is cached_model_info
|
||||||
|
assert len(loaded_hashes) == 1
|
||||||
|
assert loaded_hashes[0]
|
||||||
|
|
||||||
|
|
||||||
def test_hf_registry_coverage():
|
def test_hf_registry_coverage():
|
||||||
untested_archs = (
|
untested_archs = (
|
||||||
ModelRegistry.get_supported_archs() - HF_EXAMPLE_MODELS.get_supported_archs()
|
ModelRegistry.get_supported_archs() - HF_EXAMPLE_MODELS.get_supported_archs()
|
||||||
|
|||||||
@@ -1004,9 +1004,10 @@ class _LazyRegisteredModel(_BaseRegisteredModel):
|
|||||||
# hardware-isolated ``vllm.models.<name>`` layout) live outside
|
# hardware-isolated ``vllm.models.<name>`` layout) live outside
|
||||||
# ``vllm/model_executor/models``. Resolve the module spec directly
|
# ``vllm/model_executor/models``. Resolve the module spec directly
|
||||||
# so the file-hash cache stays warm for them.
|
# so the file-hash cache stays warm for them.
|
||||||
|
model_path: Path | None = None
|
||||||
if self.module_name.startswith("vllm.model_executor.models."):
|
if self.module_name.startswith("vllm.model_executor.models."):
|
||||||
model_path = Path(__file__).parent / f"{self.module_name.split('.')[-1]}.py"
|
model_path = Path(__file__).parent / f"{self.module_name.split('.')[-1]}.py"
|
||||||
else:
|
if model_path is None or not model_path.exists():
|
||||||
try:
|
try:
|
||||||
spec = importlib.util.find_spec(self.module_name)
|
spec = importlib.util.find_spec(self.module_name)
|
||||||
except (ImportError, ValueError):
|
except (ImportError, ValueError):
|
||||||
|
|||||||
Reference in New Issue
Block a user