File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -751,3 +751,25 @@ def test_reset_prefix_cache():
751751 assert manager .reset_prefix_cache ()
752752 assert not manager .block_pool .cached_block_hash_to_block
753753 assert all ([blk .block_hash is None for blk in manager .block_pool .blocks ])
754+
755+
756+ def test_prefix_cache_stats_disabled ():
757+ """Test that prefix_cache_stats is None when log_stats is False."""
758+ manager = KVCacheManager (
759+ make_kv_cache_config (16 , 11 ),
760+ max_model_len = 8192 ,
761+ enable_caching = True ,
762+ log_stats = False , # Disable logging stats
763+ )
764+ assert manager .prefix_cache_stats is None
765+
766+ # Call all functions that check whether log_stats is disabled.
767+ req = make_request ("0" , list (range (16 )))
768+ computed_blocks , num_computed_tokens = manager .get_computed_blocks (req )
769+ assert not computed_blocks
770+ assert num_computed_tokens == 0
771+ manager .allocate_slots (req , 16 , computed_blocks )
772+ manager .reset_prefix_cache ()
773+
774+ # Ensure prefix_cache_stats remains None
775+ assert manager .prefix_cache_stats is None
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ def __init__(
4040 self .enable_caching = enable_caching
4141 self .caching_hash_fn = sha256 if caching_hash_algo == "sha256" else hash
4242 self .log_stats = log_stats
43+ # FIXME: make prefix cache stats conditional on log_stats
4344 self .prefix_cache_stats = PrefixCacheStats () if log_stats else None
4445 # NOTE(woosuk): To avoid frequent block allocation, we preallocate some
4546 # blocks for each request. For example, when a request reaches the end
You can’t perform that action at this time.
0 commit comments