[Spec Decode] Enable Gemma4 DSpark adaptive verification with FlashInfer (#57263)
Signed-off-by: zixi-qi <zixi@inferact.ai> Co-authored-by: OpenAI Codex <noreply@openai.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: Nick Hill <nickhill123@gmail.com>
This commit is contained in:
co-authored by
OpenAI Codex
Claude Opus 5.5
Nick Hill
parent
3b4566c5cf
commit
a4eb3f25d6
@@ -8,6 +8,7 @@ never addressed by the logical view.
|
||||
"""
|
||||
|
||||
from types import SimpleNamespace
|
||||
from typing import Any
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
@@ -99,12 +100,16 @@ def test_get_kv_cache_spec_resolves_hisparse_block_size(
|
||||
|
||||
|
||||
class _FakeMetadataBuilder:
|
||||
def __init__(self, support: AttentionCGSupport):
|
||||
def __init__(self, support: AttentionCGSupport, varlen_bound: int | None = None):
|
||||
self.support = support
|
||||
self.varlen_bound = varlen_bound
|
||||
|
||||
def get_cudagraph_support(self, *_args):
|
||||
return self.support
|
||||
|
||||
def get_varlen_cudagraph_max_query_len(self, *_args):
|
||||
return self.varlen_bound
|
||||
|
||||
|
||||
class _TargetBackend:
|
||||
@classmethod
|
||||
@@ -183,6 +188,42 @@ def test_attention_checks_preserve_global_and_target_scoped_support():
|
||||
)
|
||||
|
||||
|
||||
def test_varlen_cudagraph_unsupported_backend_checks_scoped_bounds():
|
||||
"""ALWAYS passes without a bound, other builders need one at least as wide as
|
||||
the requested length, and NEVER fails whatever bound a builder reports."""
|
||||
config: Any = SimpleNamespace()
|
||||
spec = FullAttentionSpec(
|
||||
block_size=16,
|
||||
num_kv_heads=1,
|
||||
head_size=128,
|
||||
dtype=torch.bfloat16,
|
||||
)
|
||||
|
||||
def group(
|
||||
backend: Any,
|
||||
layer_name: str,
|
||||
support: AttentionCGSupport,
|
||||
bound: int | None = None,
|
||||
):
|
||||
builder: Any = _FakeMetadataBuilder(support, bound)
|
||||
attn_group = AttentionGroup(backend, [layer_name], spec, 0)
|
||||
attn_group.metadata_builders = [builder]
|
||||
return attn_group
|
||||
|
||||
target = group(_TargetBackend, "target", AttentionCGSupport.ALWAYS)
|
||||
draft = group(_DraftBackend, "draft", AttentionCGSupport.UNIFORM_BATCH, 8)
|
||||
never = group(_DraftBackend, "never", AttentionCGSupport.NEVER, 8)
|
||||
|
||||
unsupported = attn_utils.get_varlen_cudagraph_unsupported_backend
|
||||
assert unsupported([[target, draft]], config, 8) is None
|
||||
assert unsupported([[target, draft]], config, 9) == ("_DraftBackend", 8)
|
||||
assert (
|
||||
unsupported([[target, draft]], config, 9, checked_layer_names={"target"})
|
||||
is None
|
||||
)
|
||||
assert unsupported([[target, never]], config, 1) == ("_DraftBackend", None)
|
||||
|
||||
|
||||
def test_get_kv_sharing_fast_prefill_eligible_layers(monkeypatch: pytest.MonkeyPatch):
|
||||
"""Fast prefill applies to the contiguous suffix of KV-sharing layers.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user