--- title: Running KVBM in TensorRT-LLM --- This guide explains how to leverage KVBM (KV Block Manager) to manage KV cache and do KV offloading in TensorRT-LLM (trtllm). To learn what KVBM is, please check [here](/dynamo/v-0-8-0/components/kvbm/architecture) - Ensure that `etcd` and `nats` are running before starting. - KVBM only supports TensorRT-LLM’s PyTorch backend. - Disable partial reuse `enable_partial_reuse: false` in the LLM API config’s `kv_connector_config` to increase offloading cache hits. - KVBM requires TensorRT-LLM v1.1.0rc5 or newer. - Enabling KVBM metrics with TensorRT-LLM is still a work in progress. ## Quick Start To use KVBM in TensorRT-LLM, you can follow the steps below: ```bash # Start up etcd for KVBM leader/worker registration and discovery docker compose -f deploy/docker-compose.yml up -d # Build a dynamo TRTLLM container (KVBM is built in by default) ./container/build.sh --framework trtllm # Launch the container ./container/run.sh --framework trtllm -it --mount-workspace --use-nixl-gds # Configure KVBM cache tiers (choose one of the following options): # Option 1: CPU cache only (GPU -> CPU offloading) # 4 means 4GB of pinned CPU memory would be used export DYN_KVBM_CPU_CACHE_GB=4 # Option 2: Both CPU and Disk cache (GPU -> CPU -> Disk tiered offloading) export DYN_KVBM_CPU_CACHE_GB=4 # 8 means 8GB of disk would be used export DYN_KVBM_DISK_CACHE_GB=8 # [Experimental] Option 3: Disk cache only (GPU -> Disk direct offloading, bypassing CPU) # NOTE: this option is only experimental and it might not give out the best performance. # NOTE: disk offload filtering is not supported when using this option. export DYN_KVBM_DISK_CACHE_GB=8 # Note: You can also use DYN_KVBM_CPU_CACHE_OVERRIDE_NUM_BLOCKS or # DYN_KVBM_DISK_CACHE_OVERRIDE_NUM_BLOCKS to specify exact block counts instead of GB ``` When disk offloading is enabled, to extend SSD lifespan, disk offload filtering would be enabled by default. The current policy is only offloading KV blocks from CPU to disk if the blocks have frequency equal or more than `2`. Frequency is determined via doubling on cache hit (init with 1) and decrement by 1 on each time decay step. To disable disk offload filtering, set `DYN_KVBM_DISABLE_DISK_OFFLOAD_FILTER` to true or 1. ```bash # write an example LLM API config # Note: Disable partial reuse "enable_partial_reuse: false" in the LLM API config’s "kv_connector_config" to increase offloading cache hits. cat > "/tmp/kvbm_llm_api_config.yaml" < "/tmp/llm_api_config.yaml" <