Skip to content

Conversation

@ryanolson
Copy link
Contributor

@ryanolson ryanolson commented Aug 6, 2025

vLLM's block manager do not dedup.

We allowed duplication when we were override the vLLM device block manager.

Moving forward with the connector api, we want to dedup on host and disk. In the future, we will revisit how we interact with the native, or replace the native, block manager.

Summary by CodeRabbit

  • New Features

    • Introduced a distributed key-value block manager (KVBM) for vLLM, enabling leader-worker block management, block transfer orchestration, and KV cache offloading across device, host, and disk.
    • Added Python and Rust APIs for KVBM integration, including cache manager, connector leader/worker, and block controller classes.
    • Provided comprehensive vLLM integration with support for external block transfers, slot/block lifecycle management, and connector metadata handling.
  • Documentation

    • Added user guides for deploying Dynamo Cloud and running KVBM in vLLM.
    • Introduced detailed architecture and test plan documents for block manager and slot management systems.
  • Bug Fixes

    • Improved error handling and validation for block allocation, transfer, and cache reset operations.
  • Chores

    • Updated Dockerfiles and build scripts to support KVBM environments and dependencies.
    • Enhanced dependency management and feature flags for Rust and Python packages.
  • Tests

    • Added extensive unit and integration tests for KVBM, vLLM integration, and block manager workflows.
    • Removed legacy block manager tests, replacing them with new tests targeting distributed and vLLM scenarios.
  • Refactor

    • Refactored block manager internals to support locality-aware block data, async initialization, and distributed resource management.
    • Modularized codebase with clear separation between logical, local, and distributed block handling.

End-users can now leverage distributed KV cache management for large language models, with improved reliability, extensibility, and documentation.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 6, 2025

Caution

Review failed

Failed to post review comments.

Walkthrough

This change introduces a distributed Key-Value Block Manager (KVBM) system with deep integration into vLLM, including a new multi-stage Dockerfile, Rust and Python bindings, distributed leader-worker block management, connector protocols, and comprehensive testing and documentation. The update refactors block data handling for locality, adds connector APIs, and implements vLLM protocol adapters.

Changes

Cohort / File(s) Change Summary
Container and Build Integration
container/Dockerfile.kvbm, container/build.sh, container/run.sh
Adds a multi-stage Dockerfile for KVBM, updates build/run scripts to recognize the KVBM framework, and supports mounting /tmp for GDS when using KVBM disk pools.
Python vLLM/KVBM Integration
lib/bindings/python/src/dynamo/llm/vllm_integration/*, lib/bindings/python/src/dynamo/llm/vllm_integration/connector/*, lib/bindings/python/src/dynamo/llm/vllm_integration/connector_leader.py, lib/bindings/python/src/dynamo/llm/vllm_integration/connector_worker.py, lib/bindings/python/src/dynamo/llm/vllm_integration/kv_cache_manager.py, lib/bindings/python/src/dynamo/llm/vllm_integration/kv_cache_utils.py, lib/bindings/python/src/dynamo/llm/vllm_integration/rust.py
Implements Python adapters, protocol wrappers, and utility classes to bridge vLLM and the Rust KVBM backend, including leader/worker connectors and cache manager logic.
Rust Python Bindings: Block Manager & Distributed
lib/bindings/python/rust/llm/block_manager.rs, lib/bindings/python/rust/llm/block_manager/*, lib/bindings/python/rust/llm/block_manager/vllm/*, lib/bindings/python/rust/lib.rs, lib/bindings/python/rust/llm.rs
Refactors Python bindings for the block manager to support distributed leader-worker resources, adds new controller, distributed, and vLLM integration modules, and exposes new public classes and methods for KVBM.
Rust Core Block Manager Refactor
lib/llm/src/block_manager.rs, lib/llm/src/block_manager/block.rs, lib/llm/src/block_manager/block/data.rs, lib/llm/src/block_manager/block/data/local.rs, lib/llm/src/block_manager/block/data/logical.rs, lib/llm/src/block_manager/block/data/logical/distributed_leader_worker.rs, lib/llm/src/block_manager/block/data/logical/null.rs, lib/llm/src/block_manager/block/data/view.rs, lib/llm/src/block_manager/block/factory.rs, lib/llm/src/block_manager/block/factory/local.rs, lib/llm/src/block_manager/block/factory/logical.rs, lib/llm/src/block_manager/block/locality.rs, lib/llm/src/block_manager/block/state.rs, lib/llm/src/block_manager/block/transfer.rs, lib/llm/src/block_manager/block/transfer/cuda.rs, lib/llm/src/block_manager/block/transfer/memcpy.rs, lib/llm/src/block_manager/block/transfer/nixl.rs, lib/llm/src/block_manager/config.rs
Refactors the block manager for locality-aware, async initialization, distributed leader-worker support, and introduces new block data abstractions, transfer protocols, and configuration options.
Distributed Block Manager and Controller
lib/llm/src/block_manager/distributed.rs, lib/llm/src/block_manager/distributed/leader.rs, lib/llm/src/block_manager/distributed/transfer.rs, lib/llm/src/block_manager/distributed/utils.rs
Implements distributed leader-worker block management, block transfer handlers, transfer request utilities, and leader-worker synchronization.
Connector Protocol and Scheduler
lib/llm/src/block_manager/connector.rs, lib/llm/src/block_manager/connector/protocol.rs, lib/llm/src/block_manager/connector/scheduler.rs
Introduces a connector protocol for block transfer scheduling, request/response flows, and a scheduler for coordinating distributed KV block operations.
Controller API and Handler
lib/llm/src/block_manager/controller.rs, lib/llm/src/block_manager/controller/client.rs, lib/llm/src/block_manager/controller/handler.rs
Adds a controller service and client for managing block pools at different cache levels, with async control message handling and status/reset operations.
Documentation and Guides
docs/guides/run_kvbm_in_vllm.md, docs/guides/dynamo_deploy/README.md, lib/llm/src/block_manager.md, lib/llm/src/block_manager/distributed/README.md, lib/bindings/python/rust/llm/block_manager/vllm/slot_manager_test_plan.md, lib/bindings/python/rust/llm/block_manager/vllm/slot_test_plan.md
Adds user and developer documentation for KVBM usage in vLLM, block manager lifecycle, distributed block manager architecture, and detailed test plans.
Testing
lib/bindings/python/tests/test_kvbm.py, lib/bindings/python/tests/test_kvbm_vllm_integration.py, lib/bindings/python/tests/test_block_manager.py
Adds new KVBM and vLLM integration tests; removes legacy block manager test suite.
Cargo and Dependency Updates
Cargo.toml, lib/bindings/python/Cargo.toml, lib/llm/Cargo.toml
Updates dependencies and features to support new block manager and distributed features, including new crates and feature flags.
Python API & Exports
lib/bindings/python/src/dynamo/_core.pyi, lib/bindings/python/src/dynamo/llm/__init__.py
Updates Python type stubs and module imports to expose new KVBM and vLLM integration classes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PythonApp
    participant KvbmCacheManager
    participant RustKVBM
    participant DistributedLeader
    participant DistributedWorker

    User->>PythonApp: Issues inference request
    PythonApp->>KvbmCacheManager: create_slot(request)
    KvbmCacheManager->>RustKVBM: Allocate blocks, manage slot
    RustKVBM->>DistributedLeader: (If leader) Setup, synchronize workers
    RustKVBM->>DistributedWorker: (If worker) Register, handle block transfer
    PythonApp->>KvbmCacheManager: allocate_slots(request, tokens)
    KvbmCacheManager->>RustKVBM: Block allocation, onboarding, transfer
    RustKVBM->>DistributedWorker: Transfer blocks if needed
    DistributedWorker-->>RustKVBM: Transfer complete
    KvbmCacheManager-->>PythonApp: Blocks ready for inference
    PythonApp-->>User: Returns inference result
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~90+ minutes

Possibly related PRs

Poem

In burrows deep, with code anew,
The rabbit builds a cache that grew—
Blocks and slots, both near and far,
Now leap across the networked bar.
Leader, worker, test, and doc,
Distributed dreams unlock!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ryanolson ryanolson merged commit 89c87ef into ryan/connector-dev Aug 7, 2025
7 of 8 checks passed
@ryanolson ryanolson deleted the ryan/connector-dedup branch August 7, 2025 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants