[Spec] Add explicit prefill shared-read capability for plugins (#39502)

This commit is contained in:
Jialin Ouyang
2026-09-18 13:11:01 -07:00
committed by GitHub
parent aed3fb1cdd
commit da2f434951
4 changed files with 105 additions and 6 deletions
@@ -35,10 +35,7 @@ def maybe_publish_prefill_shared_read_done(
declared = model_runner.attn_backend.shared_read_ends(forward_batch.forward_mode)
if declared is not SharedReadEnds.PRE_REPLAY:
return
if (
not model_runner.spec_algorithm.is_none()
and not model_runner.spec_algorithm.is_dflash_family()
):
if not model_runner.spec_algorithm.supports_prefill_shared_read_done():
# Stage the draft's shared reads before publishing the read-done event.
stage = getattr(model_runner, "prefill_shared_read_stager", None)
if stage is None or not stage(forward_batch):
@@ -136,6 +136,14 @@ class SpeculativeAlgorithm(Enum):
def supports_target_verify_for_draft(self) -> bool:
return self.is_dflash_family()
def supports_prefill_shared_read_done(self) -> bool:
"""Whether target EXTEND has no later speculative shared-buffer reader.
The backend must still declare a pre-replay read end. Other algorithms
must stage their draft's shared reads before publishing the target event.
"""
return self.is_none() or self.is_dflash_family()
def supports_mixed_chunk(self) -> bool:
"""Whether mixed chunk prefill may stay enabled with this algorithm.
@@ -100,6 +100,10 @@ class CustomSpecAlgo:
def supports_target_verify_for_draft(self) -> bool:
return False
def supports_prefill_shared_read_done(self) -> bool:
# Whether target EXTEND has no later speculative shared-buffer reader.
return False
def supports_ragged_verify(self) -> bool:
return False