[Diffusion][Attention] Support per-role attention backend via CLI (#2681)

Signed-off-by: gcanlin <canlinguosdu@gmail.com>
Signed-off-by: Hongsheng Liu <liuhongsheng4@huawei.com>
Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
Canlin GuoandHongsheng Liu authored and GitHub committed 2026-05-10 11:59:05 +08:00
1 parent 26d481fc84
commit 11c4c7f0ff
29 files changed
+1262 -106

No files matched your search

@@ -2,8 +2,8 @@
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import Generic, TypeVar
from dataclasses import dataclass, field
from typing import Any, Generic, TypeVar
import torch
@@ -64,6 +64,9 @@ class AttentionMetadata:
# a replicated tensor among processes appended to the front or rear of value, depends the joint_strategy
joint_strategy: str = "front"
# the strategy to joint the query, key, and value, can be "front" or "rear"
extra: dict[str, Any] = field(default_factory=dict)
# Opaque backend-specific per-forward parameters (e.g. block masks, KV indices).
# Backends MUST silently ignore unknown keys.
T = TypeVar("T", bound=AttentionMetadata)
@@ -79,6 +82,8 @@ class AttentionImpl(ABC, Generic[T]):
causal: bool = False,
num_kv_heads: int | None = None,
prefix: str = "",
qkv_layout: str | None = None,
backend_kwargs: dict[str, Any] | None = None,
**extra_impl_args,
) -> None:
raise NotImplementedError