From f1c910b828f8f79cf964633da8e40f522233e657 Mon Sep 17 00:00:00 2001 From: Vasileios Zografos Date: Tue, 18 Aug 2026 14:01:51 +0300 Subject: [PATCH] Fix: handle cache_dtype_str=auto in TurboQuant get_kv_cache_shape Hybrid models like Qwen3.8 have both full-attention and linear-attention layers. In the model runner, layers with kv_quant_mode=NONE (linear attention layers in hybrid models) cause get_kv_cache_shape to receive 'auto' as cache_dtype_str. TurboQuantBackend.get_kv_cache_shape() calls TurboQuantConfig.from_cache_dtype(cache_dtype_str) which raises ValueError because 'auto' is not a valid TQ preset. Fix: fall back to 'turboquant_4bit_nc' when cache_dtype_str is 'auto', since the underlying tensor was already allocated with TQ slot sizing. --- vllm/v1/attention/backends/turboquant_attn.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vllm/v1/attention/backends/turboquant_attn.py b/vllm/v1/attention/backends/turboquant_attn.py index 5d743be886ae..609b4efe4778 100644 --- a/vllm/v1/attention/backends/turboquant_attn.py +++ b/vllm/v1/attention/backends/turboquant_attn.py @@ -206,6 +206,12 @@ def get_kv_cache_shape( TurboQuantConfig, ) + if cache_dtype_str == "auto": + # Hybrid models (e.g. Qwen3.8) pass "auto" for layers with + # kv_quant_mode=NONE (linear attention layers that don't use + # standard KV cache). Fall back to turboquant_4bit_nc so the + # slot size matches the tensor already allocated with TQ sizing. + cache_dtype_str = "turboquant_4bit_nc" tq_config = TurboQuantConfig.from_cache_dtype(cache_dtype_str, head_size) return (num_blocks, num_kv_heads, block_size, tq_config.slot_size_aligned)