[Perf][MRV2] Allow FULL decode graphs for one-token prompt tails (#58400)
Signed-off-by: Nick Hill <nickhill123@gmail.com> Co-authored-by: Nicolò Lucchesi <nicolo.lucchesi@mistral.ai> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Yongye Zhu <zyy1102000@gmail.com>
This commit is contained in:
co-authored by
Nicolò Lucchesi
Claude Opus 5.5
mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Yongye Zhu
parent
ef42093a36
commit
e7c903609f
@@ -258,10 +258,13 @@ class MambaHybridModelState(DefaultModelState):
|
||||
else:
|
||||
max_seq_len = seq_lens_cpu_upper_bound[:num_reqs].max().item()
|
||||
|
||||
is_prefilling_np = input_batch.is_prefilling_np
|
||||
if input_batch.prefill_runs_as_decode_np is not None:
|
||||
# A prompt tail the scheduler padded with placeholder drafts must run
|
||||
# as a spec-decode row: the prefill kernels can't roll them back.
|
||||
is_prefilling_np = is_prefilling_np & ~input_batch.prefill_runs_as_decode_np
|
||||
is_prefilling = torch.zeros(num_reqs, dtype=torch.bool, device="cpu")
|
||||
is_prefilling[: input_batch.num_reqs] = torch.from_numpy(
|
||||
input_batch.is_prefilling_np
|
||||
)
|
||||
is_prefilling[: input_batch.num_reqs] = torch.from_numpy(is_prefilling_np)
|
||||
# During CUDAGraph capture, num_decode_draft_tokens_cpu and num_accepted_tokens
|
||||
# are created by attn_metadata_builder.build_for_cudagraph_capture, so we only
|
||||
# compute them during actual (non-capture) forward execution.
|
||||
@@ -281,16 +284,7 @@ class MambaHybridModelState(DefaultModelState):
|
||||
# Test request state, not num_scheduled_tokens == draft_count+1:
|
||||
# adaptive rewrites num_scheduled_tokens to an even split, so that
|
||||
# equality rarely holds and would demote every verify row to decode.
|
||||
# A one-token prompt tail over prior state that the scheduler padded
|
||||
# with placeholder drafts is also a spec-decode row: the prefill
|
||||
# kernels can't roll the placeholders back.
|
||||
num_computed = input_batch.num_computed_prefill_tokens_np
|
||||
is_prompt_tail = (num_computed > 0) & (
|
||||
input_batch.prefill_len_np - num_computed == 1
|
||||
)
|
||||
is_decode = (~input_batch.is_prefilling_np | is_prompt_tail) & (
|
||||
input_batch.num_scheduled_tokens > 0
|
||||
)
|
||||
is_decode = ~is_prefilling_np & (input_batch.num_scheduled_tokens > 0)
|
||||
spec_decode_mask = (num_draft_tokens_per_req > 0) & is_decode
|
||||
num_decode_draft_tokens_np[: input_batch.num_reqs] = np.where(
|
||||
spec_decode_mask, num_draft_tokens_per_req, -1
|
||||
|
||||
Reference in New Issue
Block a user