[Bugfix][Spec Decode] Stop dummy draft decode steps from writing KV through stale block-table rows (#56734)
Signed-off-by: Yifan Qiao <yifanqiao@inferact.ai> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
9b49f92344
commit
d2983f2f16
@@ -254,6 +254,7 @@ class AutoRegressiveSpeculator(DraftModelSpeculator):
|
||||
input_batch.idx_mapping,
|
||||
temperature,
|
||||
seeds,
|
||||
dummy_run=dummy_run,
|
||||
)
|
||||
|
||||
# Get the input ids and last token indices for the speculator.
|
||||
|
||||
@@ -166,6 +166,7 @@ class MultiModuleMTPSpeculator(DraftModelSpeculator):
|
||||
input_batch.idx_mapping,
|
||||
temperature,
|
||||
seeds,
|
||||
dummy_run=dummy_run,
|
||||
)
|
||||
|
||||
num_tokens = input_batch.num_tokens
|
||||
|
||||
@@ -481,6 +481,7 @@ class DraftModelSpeculator(BaseSpeculator):
|
||||
temperature: torch.Tensor,
|
||||
# [max_num_reqs]
|
||||
seeds: torch.Tensor,
|
||||
dummy_run: bool = False,
|
||||
) -> None:
|
||||
# Copy temperature, seeds, and idx mapping to the pre-allocated buffers.
|
||||
# NOTE(woosuk): For draft sampling, we only consider the temperature
|
||||
@@ -490,10 +491,15 @@ class DraftModelSpeculator(BaseSpeculator):
|
||||
# affect the output distribution after rejection sampling.
|
||||
self.temperature.copy_(temperature)
|
||||
self.seeds.copy_(seeds)
|
||||
self.idx_mapping[:num_reqs].copy_(idx_mapping)
|
||||
# idx_mapping for CG padded requests points to -1, which is ignored
|
||||
# during sampling to prevent writing stale values to draft logits.
|
||||
self.idx_mapping[num_reqs:].fill_(-1)
|
||||
# idx_mapping == -1 marks a row the drafter must not act on: sampling
|
||||
# skips it and compute_slot_mappings emits PAD. CUDA-graph padded rows
|
||||
# always get it; a dummy batch gets it for every row, since its arange
|
||||
# idx_mapping names request-state slots with stale block tables.
|
||||
if dummy_run:
|
||||
self.idx_mapping.fill_(-1)
|
||||
else:
|
||||
self.idx_mapping[:num_reqs].copy_(idx_mapping)
|
||||
self.idx_mapping[num_reqs:].fill_(-1)
|
||||
|
||||
def _build_uniform_batch_dp_sync(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user