Skip to content

Commit 7fe54de

Browse files
committed
precommit + fmt
1 parent 97793e2 commit 7fe54de

File tree

3 files changed

+46
-16
lines changed

3 files changed

+46
-16
lines changed

lib/bindings/python/rust/llm/block_manager.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl BlockManager {
9797
.map_err(to_pyerr)?,
9898
);
9999
}
100-
100+
101101
if leader.num_disk_blocks() > 0 {
102102
tracing::info!("Using {} disk blocks", leader.num_disk_blocks());
103103
config = config.disk_layout(
@@ -111,7 +111,15 @@ impl BlockManager {
111111
(Some(leader), rt)
112112
} else {
113113
tracing::info!("Leader not provided. Block transfer functionality will be disabled.");
114-
(None, Arc::new(tokio::runtime::Builder::new_multi_thread().enable_all().build().map_err(to_pyerr)?))
114+
(
115+
None,
116+
Arc::new(
117+
tokio::runtime::Builder::new_multi_thread()
118+
.enable_all()
119+
.build()
120+
.map_err(to_pyerr)?,
121+
),
122+
)
115123
};
116124

117125
let config = config.build().map_err(to_pyerr)?;

lib/bindings/python/tests/test_kvbm.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
try:
1616
from dynamo.llm import BlockManager
1717
from dynamo.llm.vllm_integration.kv_cache_manager import KvbmCacheManager
18+
1819
KVBM_NOT_AVAILABLE = False
1920
except ImportError:
2021
KVBM_NOT_AVAILABLE = True
@@ -24,6 +25,7 @@
2425
PAGE_SIZE = 4
2526
DEVICE_NUM_BLOCKS = 16
2627

28+
2729
def new_request():
2830
return Request(
2931
request_id=str(uuid.uuid4()),

lib/bindings/python/tests/test_kvbm_vllm_integration.py

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
import time
54
from typing import Optional
65

76
import pytest
@@ -24,14 +23,13 @@
2423
try:
2524
from dynamo.llm import BlockManager
2625
from dynamo.llm.vllm_integration.kv_cache_manager import KvbmCacheManager
26+
2727
KVBM_NOT_AVAILABLE = False
28-
except:
28+
except ImportError:
2929
KVBM_NOT_AVAILABLE = True
3030

31-
def new_kv_cache_manager(
32-
num_blocks: int = 11,
33-
page_size: int = 16
34-
):
31+
32+
def new_kv_cache_manager(num_blocks: int = 11, page_size: int = 16):
3533
"""
3634
Creates a new KVBM cache manager.
3735
@@ -89,7 +87,10 @@ def make_kv_cache_config(block_size: int, num_blocks: int) -> KVCacheConfig:
8987
)
9088

9189

92-
@pytest.mark.skipif(VLLM_NOT_AVAILABLE or KVBM_NOT_AVAILABLE, reason="VLLM not available or KVBM not available")
90+
@pytest.mark.skipif(
91+
VLLM_NOT_AVAILABLE or KVBM_NOT_AVAILABLE,
92+
reason="VLLM not available or KVBM not available",
93+
)
9394
def test_prefill():
9495
"""
9596
Tests the KvbmCacheManager's prefill functionality.
@@ -282,7 +283,10 @@ def test_prefill_plp():
282283
manager.free(req2)
283284

284285

285-
@pytest.mark.skipif(VLLM_NOT_AVAILABLE or KVBM_NOT_AVAILABLE, reason="VLLM not available or KVBM not available")
286+
@pytest.mark.skipif(
287+
VLLM_NOT_AVAILABLE or KVBM_NOT_AVAILABLE,
288+
reason="VLLM not available or KVBM not available",
289+
)
286290
def test_decode():
287291
manager = new_kv_cache_manager()
288292

@@ -350,7 +354,10 @@ def test_decode():
350354
manager.free_block_hashes(req0)
351355

352356

353-
@pytest.mark.skipif(VLLM_NOT_AVAILABLE or KVBM_NOT_AVAILABLE, reason="VLLM not available or KVBM not available")
357+
@pytest.mark.skipif(
358+
VLLM_NOT_AVAILABLE or KVBM_NOT_AVAILABLE,
359+
reason="VLLM not available or KVBM not available",
360+
)
354361
def test_evict():
355362
manager = new_kv_cache_manager()
356363
used_blocks = set()
@@ -416,10 +423,13 @@ def test_evict():
416423
# assert manager.block_pool.free_block_queue.num_free_blocks == 7
417424

418425

419-
@pytest.mark.skipif(VLLM_NOT_AVAILABLE or KVBM_NOT_AVAILABLE, reason="VLLM not available or KVBM not available")
426+
@pytest.mark.skipif(
427+
VLLM_NOT_AVAILABLE or KVBM_NOT_AVAILABLE,
428+
reason="VLLM not available or KVBM not available",
429+
)
420430
def test_hash_block_correct_reuse():
421431
"""
422-
This tests when a previously cached block is reused as a new block,
432+
This tests when a previously cached block is reused as a new block,
423433
its hash metadata should be correctly reset.
424434
"""
425435
block_size = 16
@@ -467,7 +477,10 @@ def test_hash_block_correct_reuse():
467477
assert blocks.blocks[1].block_hash is None
468478

469479

470-
@pytest.mark.skipif(VLLM_NOT_AVAILABLE or KVBM_NOT_AVAILABLE, reason="VLLM not available or KVBM not available")
480+
@pytest.mark.skipif(
481+
VLLM_NOT_AVAILABLE or KVBM_NOT_AVAILABLE,
482+
reason="VLLM not available or KVBM not available",
483+
)
471484
def test_computed_blocks_not_evicted():
472485
"""
473486
Test that the computed blocks are not evicted when getting new blocks
@@ -564,7 +577,10 @@ def _test_mm_prefix_caching():
564577
pass
565578

566579

567-
@pytest.mark.skipif(VLLM_NOT_AVAILABLE or KVBM_NOT_AVAILABLE, reason="VLLM not available or KVBM not available")
580+
@pytest.mark.skipif(
581+
VLLM_NOT_AVAILABLE or KVBM_NOT_AVAILABLE,
582+
reason="VLLM not available or KVBM not available",
583+
)
568584
def test_cache_key_salting():
569585
"""
570586
This tests that cache salts are applied during hashing and the cache
@@ -635,7 +651,10 @@ def test_cache_key_salting():
635651
"""
636652

637653

638-
@pytest.mark.skipif(VLLM_NOT_AVAILABLE or KVBM_NOT_AVAILABLE, reason="VLLM not available or KVBM not available")
654+
@pytest.mark.skipif(
655+
VLLM_NOT_AVAILABLE or KVBM_NOT_AVAILABLE,
656+
reason="VLLM not available or KVBM not available",
657+
)
639658
def test_prefill_not_enough_free_blocks_with_computed_blocks():
640659
"""
641660
This is a unit test that tests the correctness of the allocate_slots
@@ -758,6 +777,7 @@ def _test_eagle_with_sliding_window():
758777
Test Eagle behavior with sliding window."""
759778
pass
760779

780+
761781
@pytest.mark.skipif(KVBM_NOT_AVAILABLE, reason="KVBM not available")
762782
def test_kvbm_wrong_blocks_provided():
763783
"""

0 commit comments

Comments
 (0)