99from vllm .engine .arg_utils import EngineArgs
1010from vllm .usage .usage_lib import UsageContext
1111from vllm .utils .argparse_utils import FlexibleArgumentParser
12+ from vllm .utils .hashing import _xxhash
1213
1314
1415def 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
6167def test_defaults_with_usage_context ():
6268 engine_args = EngineArgs (model = "facebook/opt-125m" )
0 commit comments