[Bug][Spec Decode] Fix AR metrics when drafting is skipped - #34757
benchislett wants to merge 4 commits into
Conversation
Signed-off-by: Benjamin Chislett <bchislett@nvidia.com>
Signed-off-by: Benjamin Chislett <bchislett@nvidia.com>
There was a problem hiding this comment.
Code Review
The pull request addresses a bug where acceptance rate (AR) metrics for speculative decoding were incorrectly calculated when drafting was skipped. The fix introduces a new boolean flag _prev_step_drafting_was_skipped in the Scheduler class and a drafting_was_skipped field in ModelRunnerOutput to track this state. This flag is then used to conditionally exclude dummy/placeholder draft tokens from AR statistics. The changes appear to correctly handle the scenario described in the bug report, ensuring more accurate metrics for speculative decoding.
|
This pull request has been automatically marked as stale because it has not had any activity within 90 days. It will be automatically closed if no further activity occurs within 30 days. Leave a comment if you feel this pull request should remain open. Thank you! |
|
This pull request has been automatically closed due to inactivity. Please feel free to reopen if you intend to continue working on it. Thank you! |
|
This pull request has merge conflicts that must be resolved before it can be |
|
@benchislett I duplicated this work in #54054 before finding this PR — my fault for not checking open PRs against #34734 properly. I have closed mine. One finding from it that may be worth folding in here, since this PR is currently stale with conflicts: The async-scheduling path needs separate handling. Consuming the flag in Also worth noting: there is a residual case in the stats function itself. Happy to help rebase this one or test a revision if useful — though I only have CPU-level scheduler testing available, no spec-decode checkpoint. |
|
This is still needed on 1. Not obsolete, but your touchpoint moved. The predicate is still there and still batch-wide, so #34734 reproduces as written — the stale-bot close in June was not the code moving out from under it. It has been extracted into a helper since you wrote this, which is where your rebase will land: # vllm/v1/worker/gpu_model_runner.py, main fa1b3b1922
:4550 def _input_fits_in_drafter(self, common_attn_metadata) -> bool:
:4553 if common_attn_metadata is None:
:4554 return False
:4557 num_drafter_query_tokens = self.num_spec_tokens + (
:4558 1 if self.speculative_config.use_dflash() else 0
:4559 )
:4560 return (
:4561 common_attn_metadata.max_seq_len + num_drafter_query_tokens
:4562 <= self.effective_drafter_max_model_len
:4563 )called at 2. The residual CarrotSwordsman flagged is now being fixed by two other PRs, and neither cites #34734 or this branch. They are #56137 and #56195, both aimed at exactly the ordering you were told might deserve its own fix — 3. One of those two approaches is unsafe, and it is worth knowing which. #56195 moves the grammar adjustment ahead of the guard, so the function can # vllm/v1/core/sched/scheduler.py, main fa1b3b1922
:1901 spec_decoding_stats: SpecDecodingStats | None = None # once per update_from_output, outside the loop
:1997 spec_decoding_stats = self.make_spec_decoding_stats( # inside the loop, return value assigned back
:1998 spec_decoding_stats, ...
:2294 ... # consumed once, outside the loopBecause the return value is assigned back into the accumulator, an early Your own gate sits outside 4. A composition note, and my stake in it. Your fix suppresses acceptance stats for a step where the drafter was skipped, which is right for the AR number — I have an open PR on that second case (#54748, a step counter keyed on the selected K), so I am not a neutral party here. I am not asking you to adopt or reference it — only flagging that the two changes push the same surface in opposite directions, and you may want to know that before rebasing. No action needed from me; happy to be told any of this is already accounted for. |
Purpose
FIX #34734.
Not the cleanest fix, open to other approaches. But this one does seem to work
Testing
Ran Llama 3.1 8B-Instruct with EAGLE3 and got AL 1.00 for prompts of size 2k. Now, reports no drafted tokens as expected.
Will fix CI failures as needed, but shouldn't affect anything other than statistics collection.