[3/N] HiSparse: host-resident sparse-MLA decode hot-buffering (#53781)
Signed-off-by: Matthew Bonanni <mbonanni@redhat.com> Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com> Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> Signed-off-by: Matthew Bonanni <matthew@neuralmagic.com> Signed-off-by: Nicolò Lucchesi <nicolo.lucchesi@mistral.ai> Co-authored-by: OpenAI Codex <codex@openai.com> Co-authored-by: Lucas Wilkinson <lwilkins@redhat.com> Co-authored-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> Co-authored-by: Nicolò Lucchesi <nicolo.lucchesi@mistral.ai> Co-authored-by: OpenAI Codex <noreply@openai.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-authored-by: Lucas Wilkinson <LucasWilkinson@users.noreply.github.com>
This commit is contained in:
co-authored by
OpenAI Codex
Lucas Wilkinson
Lucas Wilkinson
Nicolò Lucchesi
OpenAI Codex
Claude Opus 5
Lucas Wilkinson
parent
120ec4ebd2
commit
d43bb2f37f
@@ -34,6 +34,7 @@ class KVCacheSpecMetadata:
|
||||
|
||||
|
||||
_REGISTRY_KVCACHESPEC_LIST: dict[type["KVCacheSpec"], KVCacheSpecMetadata] = {}
|
||||
_REGISTRY_ROLE_MANAGERS: dict[str, type["SingleTypeKVCacheManager"]] = {}
|
||||
|
||||
|
||||
class KVCacheSpecRegistry:
|
||||
@@ -102,20 +103,34 @@ class KVCacheSpecRegistry:
|
||||
uniform_type_base_spec=uniform_type_base_spec,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def register_role_manager(
|
||||
cls, role: str, manager_class: type["SingleTypeKVCacheManager"]
|
||||
) -> None:
|
||||
"""Select ``manager_class`` for every group with the given role."""
|
||||
registered = _REGISTRY_ROLE_MANAGERS.get(role)
|
||||
assert registered is None or registered is manager_class, (
|
||||
f"Conflicting manager registration for group role {role}"
|
||||
)
|
||||
_REGISTRY_ROLE_MANAGERS[role] = manager_class
|
||||
|
||||
@classmethod
|
||||
def get_manager_class(
|
||||
cls, kvcache_spec: "KVCacheSpec"
|
||||
cls, kvcache_spec: "KVCacheSpec", role: str | None = None
|
||||
) -> type["SingleTypeKVCacheManager"] | None:
|
||||
"""
|
||||
Get the single type kvcache manager class for a given kvcache spec instance.
|
||||
|
||||
Args:
|
||||
kvcache_spec: A KVCacheSpec instance
|
||||
role: The group's role; a role-registered manager takes precedence.
|
||||
|
||||
Returns:
|
||||
The SingleTypeKVCacheManager class to use for this kvcache_spec
|
||||
"""
|
||||
cls._ensure_registered()
|
||||
if role is not None and (manager_class := _REGISTRY_ROLE_MANAGERS.get(role)):
|
||||
return manager_class
|
||||
kvcache_spec_cls = type(kvcache_spec)
|
||||
|
||||
# Walk up the MRO to find a registered base class
|
||||
|
||||
Reference in New Issue
Block a user