diff --git a/components/src/dynamo/vllm/tests/conftest.py b/components/src/dynamo/vllm/tests/conftest.py index 71156787329e..a186df53f9d7 100644 --- a/components/src/dynamo/vllm/tests/conftest.py +++ b/components/src/dynamo/vllm/tests/conftest.py @@ -6,11 +6,35 @@ framework is not installed in the current container. """ +import importlib import importlib.util import sys import pytest +# Cached result of attempting to import the omni handler module. +# `None` = not yet attempted, `True` = succeeded, `False` = raised. +_omni_importable: bool | None = None + + +def _can_import_omni() -> bool: + """Try to import dynamo.vllm.omni.base_handler once and cache the result. + + Catches any exception, not just ImportError — vllm_omni's import chain + can raise NotImplementedError (and other types) when vllm._C / libcuda + aren't available on a CPU-only runner. importlib.util.find_spec is + insufficient because it only resolves the top-level package, not the + transitive imports that actually fail. + """ + global _omni_importable + if _omni_importable is None: + try: + importlib.import_module("dynamo.vllm.omni.base_handler") + _omni_importable = True + except Exception: + _omni_importable = False + return _omni_importable + def pytest_ignore_collect(collection_path, config): """Skip collecting vllm test files if vllm module isn't installed. @@ -20,6 +44,16 @@ def pytest_ignore_collect(collection_path, config): if filename.startswith("test_vllm_"): if importlib.util.find_spec("vllm") is None: return True # vllm not available, skip this file + # Omni tests import dynamo.vllm.omni.* which transitively imports + # vllm_omni at module load. On CPU-only sample-runtime runners the + # import chain reaches vllm._C and raises (NotImplementedError when + # libcuda.so.1 is missing). Each file's local try/except ImportError + # doesn't catch this, so skip collection up-front if the canonical + # omni module isn't importable. + parts = collection_path.parts + if "omni" in parts and filename.startswith("test_"): + if not _can_import_omni(): + return True return None diff --git a/lib/llm/src/preprocessor.rs b/lib/llm/src/preprocessor.rs index ece8dbfa9529..048456d2b69b 100644 --- a/lib/llm/src/preprocessor.rs +++ b/lib/llm/src/preprocessor.rs @@ -1578,7 +1578,6 @@ impl OpenAIPreprocessor { choice.delta.refusal = None; choice.delta.reasoning_content = None; choice.finish_reason = None; - choice.stop_reason = None; choice.logprobs = None; true } else { diff --git a/lib/llm/tests/postprocessor_parsing_stream.rs b/lib/llm/tests/postprocessor_parsing_stream.rs index be2a258079b2..210b58a8cf14 100644 --- a/lib/llm/tests/postprocessor_parsing_stream.rs +++ b/lib/llm/tests/postprocessor_parsing_stream.rs @@ -329,7 +329,6 @@ fn mock_multi_choice_content_chunk( reasoning_content: None, }, finish_reason: None, - stop_reason: None, logprobs: None, }) .collect(); diff --git a/tests/serve/test_vllm_omni.py b/tests/serve/test_vllm_omni.py index c545e256a472..dbb1025b5921 100644 --- a/tests/serve/test_vllm_omni.py +++ b/tests/serve/test_vllm_omni.py @@ -10,7 +10,10 @@ try: from dynamo.vllm.omni.args import OmniConfig # noqa: F401 -except ImportError: +except Exception: + # vllm_omni's import chain can raise NotImplementedError (and other + # non-ImportError types) on platforms it doesn't support — e.g. a + # CPU-only runner where vllm._C can't load libcuda.so.1. pytest.skip("vLLM omni dependencies not available", allow_module_level=True) from tests.serve.common import (