Skip to content

[Feature][KV-offloading]: Relax Offloading Block Size asserts #48635

Description

🚀 The feature, motivation and pitch

Setting offloading block size for some models like,

  • deepseek-ai/DeepSeek-V4-Flash, and
  • google/gemma-4-31B-it

trips the assert

assert len(gpu_block_sizes) == 1, (

This is the "all kv groups must have the same block size" assert.

How to run,

Deepseek V4

MODEL="deepseek-ai/DeepSeek-V4-Flash"
DSV4_EXTRA="--kv-cache-dtype fp8 --block-size 256 --tokenizer-mode deepseek_v4 --tool-call-parser deepseek_v4 --enable-auto-tool-choice --reasoning-parser deepseek_v4"
TP_SIZE=4
CPU_BYTES=26843545600

KV_TRANSFER_CONFIG=$(cat <<EOF
{
  "kv_connector": "OffloadingConnector",
  "kv_role": "kv_both",
  "kv_connector_extra_config": {
    "block_size": 512,
    "spec_name": "CPUOffloadingSpec",
    "cpu_bytes_to_use": ${CPU_BYTES},
    "eviction_policy": "lru"
  }
}
EOF
)

vllm serve "${MODEL}" \
      --tensor-parallel-size="${TP_SIZE}" \
      --kv-transfer-config "${KV_TRANSFER_CONFIG}" \
      --enable-prefix-caching \
      --no-disable-hybrid-kv-cache-manager \
      ${DSV4_EXTRA} \
      --port 8000

Gemma4

MODEL="google/gemma-4-31B-it"
TP_SIZE=2
CPU_BYTES=26843545600

KV_TRANSFER_CONFIG=$(cat <<EOF
{
  "kv_connector": "OffloadingConnector",
  "kv_role": "kv_both",
  "kv_connector_extra_config": {
    "block_size": 512,
    "spec_name": "CPUOffloadingSpec",
    "cpu_bytes_to_use": ${CPU_BYTES},
    "eviction_policy": "lru"
  }
}
EOF
)

vllm serve "${MODEL}" \
      --tensor-parallel-size="${TP_SIZE}" \
      --kv-transfer-config "${KV_TRANSFER_CONFIG}" \
      --enable-prefix-caching \
      --no-disable-hybrid-kv-cache-manager \
      --port 8000

Request:
This feature request is to relax the assertion allowing models with disparate KV group block sizes to still accommodate/align on a common offloading block size.

Motivation:
This is important for disk offloading as we very quickly hit the IOPs bottleneck with large quantities of small file read/writes. Relaxing the assert lets the user tune the offloading block size per their disk capacity.

Alternatives

The users can still set the top-level GPU block size and benefit that way. But this is not ideal and is not supported by all models. For example, setting the gpu block size to anything other than 256 for deepseek-v4-flash hits the assert,

.view(permuted_kv_cache_shape)
. No issues with gemma4 when setting this.

Additional context

No response

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions