Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/source/features/kvcache.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Models that select the V2 manager by default:
| DeepSeek-V4 | Sparse attention attaches auxiliary per-layer buffers |
| GPT-OSS | Sliding window on every other layer (VSWA), so the sliding-window and full-attention pools are sized independently |
| Gemma3 / Gemma4 (text and multimodal) | Alternating sliding-window and full-attention layers (VSWA); same independent pool sizing |
| Llama / Llama4 | Uniform KV pool layout (chunked attention does not partition the pools); validated across text, multimodal, and disaggregated workloads |

Separately, Gemma4 hybrid attention and sparse-attention models are routed to
V2 unconditionally: their per-layer buffer layouts cannot be represented by V1's
Expand Down
24 changes: 24 additions & 0 deletions tensorrt_llm/_torch/models/modeling_llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,14 @@ def forward(
@register_auto_model("LlamaForCausalLM")
class LlamaForCausalLM(SpecDecOneEngineForCausalLM[LlamaModel, LlamaConfig]):

@classmethod
def get_preferred_kv_cache_manager_version(
cls,
pretrained_config: Any = None,
) -> Literal["V2"]:
"""Prefer KV cache manager V2 for Llama."""
return "V2"

@classmethod
def get_preferred_transceiver_runtime(
cls,
Expand Down Expand Up @@ -1505,6 +1513,22 @@ def call_with_text_prompt(
class Llama4ForConditionalGeneration(SpecDecOneEngineForCausalLM[Llama4Model,
Llama4Config]):

@classmethod
def get_preferred_kv_cache_manager_version(
cls,
pretrained_config: Any = None,
) -> Literal["V2"]:
"""Prefer KV cache manager V2 for Llama4."""
return "V2"

@classmethod
def get_preferred_transceiver_runtime(
cls,
pretrained_config: Any = None,
) -> Optional[Literal["CPP", "PYTHON"]]:
"""Prefer the Python transceiver for Llama4 NIXL disaggregated serving."""
return "PYTHON"

def __init__(
self,
model_config: ModelConfig[Llama4Config],
Expand Down
4 changes: 4 additions & 0 deletions tests/unittest/llmapi/test_llm_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,8 @@ def test_registered_models_prefer_v2(self):
"Gemma4ForCausalLM",
"Gemma4ForConditionalGeneration",
"Gemma4UnifiedForConditionalGeneration",
"LlamaForCausalLM",
"Llama4ForConditionalGeneration",
)
for architecture in architectures:
model_cls = get_registered_model_class(architecture)
Expand Down Expand Up @@ -751,6 +753,8 @@ def test_registered_models_keep_v2_on_nixl(self):
"Gemma4ForCausalLM",
"Gemma4ForConditionalGeneration",
"Gemma4UnifiedForConditionalGeneration",
"LlamaForCausalLM",
"Llama4ForConditionalGeneration",
)
for architecture in architectures:
model_cls = get_registered_model_class(architecture)
Expand Down
Loading