[Misc] Fix Current vLLM config is not set. warnings, assert to avoid issues in the future (#31747)
Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com> Signed-off-by: Lucas Wilkinson <LucasWilkinson@users.noreply.github.com> Co-authored-by: Luka Govedič <ProExpertProg@users.noreply.github.com>
This commit is contained in:
co-authored by
Luka Govedič
parent
5d3b6097ad
commit
6cdf015c3c
+12
-7
@@ -1441,13 +1441,18 @@ def get_cached_compilation_config():
|
||||
|
||||
def get_current_vllm_config() -> VllmConfig:
|
||||
if _current_vllm_config is None:
|
||||
# in ci, usually when we test custom ops/modules directly,
|
||||
# we don't set the vllm config. In that case, we set a default
|
||||
# config.
|
||||
# Use stack level 2 so the log contains the line of the caller,
|
||||
# so it's easier to track down the source of the warning.
|
||||
logger.warning("Current vLLM config is not set.", stacklevel=2)
|
||||
return VllmConfig()
|
||||
raise AssertionError(
|
||||
"Current vLLM config is not set. This typically means "
|
||||
"get_current_vllm_config() was called outside of a "
|
||||
"set_current_vllm_config() context, or a CustomOp was instantiated "
|
||||
"at module import time or model forward time when config is not set. "
|
||||
"For tests that directly test custom ops/modules, use the "
|
||||
"'default_vllm_config' pytest fixture from tests/conftest.py."
|
||||
)
|
||||
return _current_vllm_config
|
||||
|
||||
|
||||
def get_current_vllm_config_or_none() -> VllmConfig | None:
|
||||
return _current_vllm_config
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user