Skip to content

Commit ca3859a

Browse files
test: KVBM vLLM python tests (#1463) (#1736)
Co-authored-by: jthomson04 <jwillthomson19@gmail.com>
1 parent 3552619 commit ca3859a

File tree

6 files changed

+926
-474
lines changed

6 files changed

+926
-474
lines changed

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

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ pub struct BlockManager {
5151
#[pymethods]
5252
impl BlockManager {
5353
#[new]
54-
#[pyo3(signature = (worker_id, leader, page_size, device_num_blocks))]
54+
#[pyo3(signature = (worker_id, leader = None, page_size = 32, device_num_blocks = 16))]
5555
fn new(
5656
worker_id: u64,
57-
leader: distributed::KvbmLeader,
57+
leader: Option<distributed::KvbmLeader>,
5858
page_size: usize,
5959
device_num_blocks: usize,
6060
) -> PyResult<Self> {
@@ -85,29 +85,42 @@ impl BlockManager {
8585
.map_err(to_pyerr)?,
8686
);
8787

88-
let (leader, rt) = leader.dissolve();
89-
90-
if leader.num_host_blocks() > 0 {
91-
tracing::info!("Using {} host blocks", leader.num_host_blocks());
92-
config = config.host_layout(
93-
dynamo_llm::block_manager::KvManagerLayoutConfig::builder()
94-
.num_blocks(leader.num_host_blocks())
95-
.logical(Some(BlockParallelismStrategy::LeaderWorkerSharded))
96-
.build()
97-
.map_err(to_pyerr)?,
98-
);
99-
}
100-
101-
if leader.num_disk_blocks() > 0 {
102-
tracing::info!("Using {} disk blocks", leader.num_disk_blocks());
103-
config = config.disk_layout(
104-
dynamo_llm::block_manager::KvManagerLayoutConfig::builder()
105-
.num_blocks(leader.num_disk_blocks())
106-
.logical(Some(BlockParallelismStrategy::LeaderWorkerSharded))
107-
.build()
108-
.map_err(to_pyerr)?,
109-
);
110-
}
88+
let (leader, rt) = if let Some(leader) = leader {
89+
let (leader, rt) = leader.dissolve();
90+
if leader.num_host_blocks() > 0 {
91+
tracing::info!("Using {} host blocks", leader.num_host_blocks());
92+
config = config.host_layout(
93+
dynamo_llm::block_manager::KvManagerLayoutConfig::builder()
94+
.num_blocks(leader.num_host_blocks())
95+
.logical(Some(BlockParallelismStrategy::LeaderWorkerSharded))
96+
.build()
97+
.map_err(to_pyerr)?,
98+
);
99+
}
100+
101+
if leader.num_disk_blocks() > 0 {
102+
tracing::info!("Using {} disk blocks", leader.num_disk_blocks());
103+
config = config.disk_layout(
104+
dynamo_llm::block_manager::KvManagerLayoutConfig::builder()
105+
.num_blocks(leader.num_disk_blocks())
106+
.logical(Some(BlockParallelismStrategy::LeaderWorkerSharded))
107+
.build()
108+
.map_err(to_pyerr)?,
109+
);
110+
}
111+
(Some(leader), rt)
112+
} else {
113+
tracing::info!("Leader not provided. Block transfer functionality will be disabled.");
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+
)
123+
};
111124

112125
let config = config.build().map_err(to_pyerr)?;
113126
Ok(BlockManager {

0 commit comments

Comments
 (0)