[Misc] Name each backend and its kernel block sizes in block-size errors (#58557)
Signed-off-by: Eugenio "Jay" Zuccarelli <11176606+jayzuccarelli@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent
4694145045
commit
004e37ece2
@@ -77,6 +77,7 @@ def test_get_kv_cache_spec_resolves_hisparse_block_size(
|
||||
layers = {}
|
||||
for name, sizes in zip(specs, [main_sizes, indexer_sizes, [block_size]]):
|
||||
backend = SimpleNamespace(
|
||||
get_name=lambda name=name: name,
|
||||
customize_spec=AttentionBackend.customize_spec,
|
||||
get_supported_kernel_block_sizes=lambda sizes=sizes: sizes,
|
||||
)
|
||||
|
||||
@@ -298,6 +298,10 @@ def _make_mock_backend_for_kernel_block_size(
|
||||
supported_sizes: list[int | MultipleOf],
|
||||
):
|
||||
class _MockBackend:
|
||||
@staticmethod
|
||||
def get_name():
|
||||
return "MOCK"
|
||||
|
||||
@staticmethod
|
||||
def get_supported_kernel_block_sizes():
|
||||
return supported_sizes
|
||||
|
||||
@@ -54,6 +54,9 @@ class MultipleOf:
|
||||
def __init__(self, base: int):
|
||||
self.base = base
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"MultipleOf({self.base})"
|
||||
|
||||
|
||||
class AttentionBackend(ABC):
|
||||
"""Abstract class for attention backends."""
|
||||
|
||||
@@ -383,7 +383,13 @@ def select_common_block_size(
|
||||
for size in sorted(candidates, reverse=True):
|
||||
if block_size_is_supported(backends, size):
|
||||
return size
|
||||
raise ValueError(f"No common block size for {kv_manager_block_size}.")
|
||||
raise ValueError(
|
||||
f"No common block size for {kv_manager_block_size} ("
|
||||
+ "; ".join(
|
||||
f"{b.get_name()}: {b.get_supported_kernel_block_sizes()}" for b in backends
|
||||
)
|
||||
+ ")."
|
||||
)
|
||||
|
||||
|
||||
def allocate_kv_cache(
|
||||
|
||||
Reference in New Issue
Block a user