Repository navigation
[WIP][Speculative Decoding] Enable batch size > 1 - #26875
patrickvonplaten wants to merge 9 commits into
Conversation
…to assistant_decoding_batch
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. |
|
|
||
| # 5.2. Get the valid continuation, after the matching tokens | ||
| valid_tokens = selected_tokens[:, : n_matches + 1] | ||
| valid_tokens = selected_tokens[:, : n_matches.max() + 1] |
There was a problem hiding this comment.
I have a question about a part that I don't understand, given that the results are identical with and without batched spec. decoding
this assumes that all the sequences will have the same number of correct matches, when we choose the accepted tokens number based on the maximum correct matches, we also accept wrong tokens from sequences that had lower number of correct matches than the maximum, the solution would be to choose the minimum which guarantees that all the accepted tokens are correct
| valid_tokens = selected_tokens[:, : n_matches.max() + 1] | |
| valid_tokens = selected_tokens[:, : n_matches.min() + 1] |
that poses a risk that if a single sequence had zero correct matches, this whole spec. decoding cycle will be discarded for all other sequences even if they have correct matches.
is it possible to use padding to accept different number of candidate tokens per batch element as opposed to accepting the minimum/maximum common number of correct suggested tokens across the batch, this should at least keep the speedups of spec decoding that were observed at small batch sizes (if not even faster at larger sizer)
There was a problem hiding this comment.
is it possible to use padding to accept different number of candidate tokens per batch element as opposed to accepting the minimum/maximum common number of correct suggested tokens across the batch
This is possible if the padding lengths are adjusted at every iteration. For one sample that progresses slower, it should be padded more, to keep the same length as fast-progress samples.
|
Hi, good work! I am curious about how to deal with the wrong kv cache token rolling back for draft model, or you just mask them? |
|
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
|
@patrickvonplaten Is there any plan to merge this PR sometimes or is it canceled ? |
|
@Hubert-Bonisseur The PR has closed due to inactivity. I'm not sure of the current status of batch > 1 for speculative decoding, but I'm sure @gante will know :) |
|
It is still not supported : But I see that Patrick has left HF since writing this PR, which probably explains why it stalled. |
|
Maybe your whisper expert @sanchit-gandhi also knows the status of this feature ? |
|
Hey @Hubert-Bonisseur - handing this one over to @kamilakesbi who will take over the integration! |
|
Hey @kamilakesbi, just checking in to see if there are any updates on this. Thanks! |
What does this PR do?
This PR enables speculative decoding when batch size is > 1.
This PR has been tested to work correctly for Whisper. You can try it as follows:
TODOS