A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 13, 17:00 UTC
[V0 deprecation]clean up is_v1_supported_oracle (#28116)
Signed-off-by: wangxiyuan <wangxiyuan1007@gmail.com>
wangxiyuan committed
Nov 6, 2025 at 16:05 UTC
c3ee80a01ae8fc2dc7fa5ea007d38221d6095f06
2 files changed
+21
-134
tests/v1/test_oracle.py
+6
-44
@@ -1,55 +1,17 @@
1
# SPDX-License-Identifier: Apache-2.0
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
-import os
4
-
3
import pytest
4
7
-import vllm.envs as envs
8
-from vllm import LLM
5
from vllm.engine.arg_utils import AsyncEngineArgs
6
7
MODEL = "meta-llama/Llama-3.2-1B-Instruct"
8
9
14
-def test_reject_bad_config(monkeypatch):
15
- with monkeypatch.context() as m:
16
- m.setenv("VLLM_USE_V1", "0")
17
-
18
-
19
-def test_unsupported_configs(monkeypatch):
20
- with monkeypatch.context() as m:
21
- m.setenv("VLLM_USE_V1", "1")
22
-
23
- with pytest.raises(NotImplementedError):
24
- AsyncEngineArgs(
25
- model=MODEL,
26
- speculative_config={
27
- "model": MODEL,
28
- },
29
- ).create_engine_config()
30
-
31
-
32
-def test_enable_by_default_fallback(monkeypatch):
33
- with monkeypatch.context() as m:
34
- if os.getenv("VLLM_USE_V1", None):
35
- m.delenv("VLLM_USE_V1")
36
-
37
- # Should default to V1 for supported config.
38
- _ = AsyncEngineArgs(
10
+def test_unsupported_configs():
11
+ with pytest.raises(NotImplementedError):
12
+ AsyncEngineArgs(
13
model=MODEL,
40
- enforce_eager=True,
14
+ speculative_config={
15
+ "model": MODEL,
16
+ },
17
).create_engine_config()
42
- assert envs.VLLM_USE_V1
43
- m.delenv("VLLM_USE_V1")
44
-
45
-
46
-def test_v1_llm_by_default(monkeypatch):
47
- with monkeypatch.context() as m:
48
- if os.getenv("VLLM_USE_V1", None):
49
- m.delenv("VLLM_USE_V1")
50
-
51
- # Should default to V1 for supported config.
52
- llm = LLM(MODEL, enforce_eager=True, enable_lora=True)
53
- print(llm.generate("Hello my name is"))
54
- assert hasattr(llm.llm_engine, "engine_core")
55
- m.delenv("VLLM_USE_V1")
vllm/engine/arg_utils.py
+15
-90
@@ -1290,15 +1290,7 @@ class EngineArgs:
1290
"""
1291
Create the VllmConfig.
1292
1293
- NOTE: for autoselection of V0 vs V1 engine, we need to
1294
- create the ModelConfig first, since ModelConfig's attrs
1295
- (e.g. the model arch) are needed to make the decision.
1296
-
1297
- This function set VLLM_USE_V1=X if VLLM_USE_V1 is
1298
- unspecified by the user.
1299
-
1300
- If VLLM_USE_V1 is specified by the user but the VllmConfig
1301
- is incompatible, we raise an error.
1293
+ NOTE: If VllmConfig is incompatible, we raise an error.
1294
"""
1295
current_platform.pre_register_and_update()
1296
@@ -1324,22 +1316,7 @@ class EngineArgs:
1316
self.model = model_config.model
1317
self.tokenizer = model_config.tokenizer
1318
1327
- # * If VLLM_USE_V1 is unset, we enable V1 for "supported features"
1328
- # and fall back to V0 for experimental or unsupported features.
1329
- # * If VLLM_USE_V1=1, we enable V1 for supported + experimental
1330
- # features and raise error for unsupported features.
1331
- # * If VLLM_USE_V1=0, we disable V1.
1332
- use_v1 = False
1333
- try_v1 = envs.VLLM_USE_V1 or not envs.is_set("VLLM_USE_V1")
1334
- if try_v1 and self._is_v1_supported_oracle(model_config):
1335
- use_v1 = True
1336
-
1337
- # If user explicitly set VLLM_USE_V1, sanity check we respect it.
1338
- if envs.is_set("VLLM_USE_V1"):
1339
- assert use_v1 == envs.VLLM_USE_V1
1340
- # Otherwise, set the VLLM_USE_V1 variable globally.
1341
- else:
1342
- envs.set_vllm_use_v1(use_v1)
1319
+ self._check_feature_supported(model_config)
1320
1321
# Set default arguments for V1 Engine.
1322
self._set_default_args(usage_context, model_config)
@@ -1708,17 +1685,10 @@ class EngineArgs:
1685
1686
return config
1687
1711
- def _is_v1_supported_oracle(self, model_config: ModelConfig) -> bool:
1712
- """Oracle for whether to use V0 or V1 Engine by default."""
1713
-
1714
- #############################################################
1715
- # Unsupported Feature Flags on V1.
1716
-
1688
+ def _check_feature_supported(self, model_config: ModelConfig):
1689
+ """Raise an error if the feature is not supported."""
1690
if self.logits_processor_pattern != EngineArgs.logits_processor_pattern:
1718
- _raise_or_fallback(
1719
- feature_name="--logits-processor-pattern", recommend_to_remove=False
1720
- )
1721
- return False
1691
+ _raise_unsupported_error(feature_name="--logits-processor-pattern")
1692
1693
# No Concurrent Partial Prefills so far.
1694
if (
@@ -1726,12 +1696,9 @@ class EngineArgs:
1696
or self.max_long_partial_prefills
1697
!= SchedulerConfig.max_long_partial_prefills
1698
):
1729
- _raise_or_fallback(
1730
- feature_name="Concurrent Partial Prefill", recommend_to_remove=False
1731
- )
1732
- return False
1699
+ _raise_unsupported_error(feature_name="Concurrent Partial Prefill")
1700
1734
- # V1 supports N-gram, Medusa, and Eagle speculative decoding.
1701
+ # N-gram, Medusa, and Eagle are supported for speculative decoding.
1702
if self.speculative_config is not None:
1703
# speculative_config could still be a dict at this point
1704
if isinstance(self.speculative_config, dict):
@@ -1746,35 +1713,6 @@ class EngineArgs:
1713
"such as ngram, medusa, eagle, or mtp."
1714
)
1715
1749
- V1_BACKENDS = [
1750
- "FLASH_ATTN",
1751
- "PALLAS",
1752
- "TRITON_ATTN",
1753
- "TRITON_MLA",
1754
- "CUTLASS_MLA",
1755
- "FLASHMLA",
1756
- "FLASH_ATTN_MLA",
1757
- "FLASHINFER",
1758
- "FLASHINFER_MLA",
1759
- "ROCM_AITER_MLA",
1760
- "TORCH_SDPA",
1761
- "FLEX_ATTENTION",
1762
- "TREE_ATTN",
1763
- "XFORMERS",
1764
- "ROCM_ATTN",
1765
- "ROCM_AITER_UNIFIED_ATTN",
1766
- ]
1767
- if (
1768
- envs.is_set("VLLM_ATTENTION_BACKEND")
1769
- and envs.VLLM_ATTENTION_BACKEND not in V1_BACKENDS
1770
- ):
1771
- name = f"VLLM_ATTENTION_BACKEND={envs.VLLM_ATTENTION_BACKEND}"
1772
- _raise_or_fallback(feature_name=name, recommend_to_remove=True)
1773
- return False
1774
-
1775
- #############################################################
1776
- # Experimental Features - allow users to opt in.
1777
-
1716
if self.pipeline_parallel_size > 1:
1717
supports_pp = getattr(
1718
self.distributed_executor_backend, "supports_pp", False
@@ -1790,18 +1728,10 @@ class EngineArgs:
1728
"executor or multiprocessing executor or external "
1729
"launcher"
1730
)
1793
- _raise_or_fallback(feature_name=name, recommend_to_remove=False)
1794
- return False
1731
+ _raise_unsupported_error(feature_name=name)
1732
1733
if current_platform.is_cpu() and model_config.get_sliding_window() is not None:
1797
- _raise_or_fallback(
1798
- feature_name="sliding window (CPU backend)", recommend_to_remove=False
1799
- )
1800
- return False
1801
-
1802
- #############################################################
1803
-
1804
- return True
1734
+ _raise_unsupported_error(feature_name="sliding window (CPU backend)")
1735
1736
def _set_default_args(
1737
self, usage_context: UsageContext, model_config: ModelConfig
@@ -2000,17 +1930,12 @@ class AsyncEngineArgs(EngineArgs):
1930
return parser
1931
1932
2003
-def _raise_or_fallback(feature_name: str, recommend_to_remove: bool):
2004
- if envs.is_set("VLLM_USE_V1") and envs.VLLM_USE_V1:
2005
- raise NotImplementedError(
2006
- f"VLLM_USE_V1=1 is not supported with {feature_name}."
2007
- )
2008
- msg = f"{feature_name} is not supported by the V1 Engine. "
2009
- msg += "Falling back to V0. "
2010
- if recommend_to_remove:
2011
- msg += f"We recommend to remove {feature_name} from your config "
2012
- msg += "in favor of the V1 Engine."
2013
- logger.warning(msg)
1933
+def _raise_unsupported_error(feature_name: str):
1934
+ msg = (
1935
+ f"{feature_name} is not supported. We recommend to "
1936
+ f"remove {feature_name} from your config."
1937
+ )
1938
+ raise NotImplementedError(msg)
1939
1940
1941
def human_readable_int(value):