Skip to content

Commit cefd2f6

Browse files
committed
[FEAT] Enhance CLI argument parsing for prefix caching: add error handling for invalid hash algorithms and introduce xxhash support
Signed-off-by: LuminolT <[email protected]>
1 parent 4e231a7 commit cefd2f6

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

tests/v1/engine/test_engine_args.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from vllm.engine.arg_utils import EngineArgs
1010
from vllm.usage.usage_lib import UsageContext
1111
from vllm.utils.argparse_utils import FlexibleArgumentParser
12+
from vllm.utils.hashing import _xxhash
1213

1314

1415
def test_prefix_caching_from_cli():
@@ -42,6 +43,16 @@ def test_prefix_caching_from_cli():
4243
vllm_config = EngineArgs.from_cli_args(args=args).create_engine_config()
4344
assert vllm_config.cache_config.prefix_caching_hash_algo == "sha256"
4445

46+
# an invalid hash algorithm raises an error
47+
parser.exit_on_error = False
48+
with pytest.raises(ArgumentError):
49+
args = parser.parse_args(["--prefix-caching-hash-algo", "invalid"])
50+
51+
52+
@pytest.mark.skipif(_xxhash is None, reason="xxhash not installed")
53+
def test_prefix_caching_xxhash_from_cli():
54+
parser = EngineArgs.add_cli_args(FlexibleArgumentParser())
55+
4556
# set hash algorithm to xxhash (pickle)
4657
args = parser.parse_args(["--prefix-caching-hash-algo", "xxhash"])
4758
vllm_config = EngineArgs.from_cli_args(args=args).create_engine_config()
@@ -52,11 +63,6 @@ def test_prefix_caching_from_cli():
5263
vllm_config = EngineArgs.from_cli_args(args=args).create_engine_config()
5364
assert vllm_config.cache_config.prefix_caching_hash_algo == "xxhash_cbor"
5465

55-
# an invalid hash algorithm raises an error
56-
parser.exit_on_error = False
57-
with pytest.raises(ArgumentError):
58-
args = parser.parse_args(["--prefix-caching-hash-algo", "invalid"])
59-
6066

6167
def test_defaults_with_usage_context():
6268
engine_args = EngineArgs(model="facebook/opt-125m")

0 commit comments

Comments
 (0)