Repository navigation
Conversation
4 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
related issue: #24768
This PR Adds a simple heuristic for adjusting the length of generated drafts during runtime (mtp only currently)
UPDATE: I added a more sophisticated heuristic using a rolling window in this branch, based on this code.
So this PR is more of an initial poc
Additional information
The simple heuristic algorithm works as follows:
we define
Threshold N
Bias B
"success" - the target model accepting the full draft minus B tokens.
"failure" - the opposite of success.
If a "success" happens N times in a row, then increase the size of the generated by one, and if a "failure" happens N times in a row, reduce the size of the generated draft by one.
Draft size never goes past --spec-draft-n-min or --spec-draft-n-max.
N is configurable via the cli arg --spec-draft-adaptive-length-threshold (defaults to 0, i.e. disabled)
*N=11 worked well for me (i.e. draft size stayed mostly constant after adjusting to the workload)
B is configurable via the cli arg --spec-draft-adaptive-length-bias (defaults to 0)
*Sometimes a bias of 1 when testing on gemma 4 gave me better results than a bias of 0.
I do not recommend enabling --draft-p-min with this flag, as it was not tested and no thought was put into the interaction between the flags.
Currently, the heuristic doesn't work when --spec-draft-n-min is 0.
Code is intentionally limited to mtp implementation to make needed refactoring easier.
I tested PR with the prompts
"Write a long relaxing story" for prose
and
"Write 15 python functions" for code
using the vulkan backend with llama-server
How to test:
Requirements