[LingBot World] Eleven bit-identical removals of repeated work in the realtime path (#7648)
Signed-off-by: tzhouam <tzhouam@connect.ust.hk> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
a9e2117f5e
commit
86fcfe95f1
23 files changed
+1957
-200
No files matched your search
@@ -40,12 +40,18 @@ class ARDiffusionCrossAttentionKVSpec:
|
||||
|
||||
name: str
|
||||
num_tokens: int
|
||||
# Head count of this cross-attention cache. Cross-attention need not be sharded the same way as
|
||||
# self-attention: a model whose cross-attention keeps every local head on every rank stores that many heads
|
||||
# here instead of its self-attention share. None means "same as self-attention", the existing behaviour.
|
||||
num_kv_heads: int | None = None
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
if not self.name:
|
||||
raise ValueError("AR-Diffusion cross-attention cache names must be non-empty")
|
||||
if self.num_tokens <= 0:
|
||||
raise ValueError(f"AR-Diffusion cross-attention num_tokens must be positive, got {self.num_tokens}")
|
||||
if self.num_kv_heads is not None and self.num_kv_heads <= 0:
|
||||
raise ValueError(f"AR-Diffusion cross-attention num_kv_heads must be positive, got {self.num_kv_heads}")
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -135,6 +141,11 @@ class ARDiffusionKVCacheSpec:
|
||||
def cross_attention_lengths(self) -> dict[str, int]:
|
||||
return {cache.name: cache.num_tokens for cache in self.cross_attention}
|
||||
|
||||
@property
|
||||
def cross_attention_kv_heads(self) -> dict[str, int]:
|
||||
"""Per-cache head counts, for the caches that do not use the self-attention head count."""
|
||||
return {cache.name: cache.num_kv_heads for cache in self.cross_attention if cache.num_kv_heads is not None}
|
||||
|
||||
|
||||
@runtime_checkable
|
||||
class SupportsARDiffusionPipeline(Protocol):
|
||||
@@ -181,3 +192,12 @@ class SupportsARDiffusionWarmup(Protocol):
|
||||
def ar_diffusion_warmup_requests(self, session_id: str) -> Iterable[OmniDiffusionRequest]:
|
||||
"""Yield requests for compiled shapes, each carrying ``session_id``."""
|
||||
...
|
||||
|
||||
|
||||
def supports_chunk_step_grouping(pipeline: object) -> bool:
|
||||
"""Whether a step-execution ``pipeline`` declares that one chunk's steps may run without scheduler cycles.
|
||||
|
||||
An AR-runner policy input, consulted only after the pipeline has already been admitted to step
|
||||
execution; LingBot-World declares it as a class attribute.
|
||||
"""
|
||||
return bool(getattr(pipeline, "supports_chunk_step_grouping", False))
|
||||
Reference in new issue
Block a user