Repository navigation
fix(skippy): preserve token ordering during sampled verification #1173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
73e29c7
Fix sampled verification token history
i386 13bc833
Guard non-output sampling history
i386 d2bb326
Merge branch 'main' into agent/fix-sampled-verification-token-history
i386 f1365f4
Merge branch 'main' into agent/fix-sampled-verification-token-history
i386 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
third_party/llama.cpp/patches/0048-Fix-sampled-verification-token-history.patch
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| From e74bdc80cc75cfe84a5d4cd13f182fbc18db2cbe Mon Sep 17 00:00:00 2001 | ||
| From: Mesh-LLM CI <ci@mesh-llm.local> | ||
| Date: Wed, 5 Aug 2026 06:15:39 +1000 | ||
| Subject: [PATCH] Fix sampled verification token history | ||
|
|
||
| --- | ||
| src/skippy.cpp | 22 +++++++++++++++++++--- | ||
| 1 file changed, 19 insertions(+), 3 deletions(-) | ||
|
|
||
| diff --git a/src/skippy.cpp b/src/skippy.cpp | ||
| index 21db2b77d..475668b7b 100644 | ||
| --- a/src/skippy.cpp | ||
| +++ b/src/skippy.cpp | ||
| @@ -5966,9 +5966,23 @@ enum skippy_status skippy_verify_tokens_frame_sampled( | ||
| } | ||
|
|
||
| if (session->stage_model->config.include_output) { | ||
| - const int32_t n_tokens = static_cast<int32_t>(token_count); | ||
| - for (int32_t i = 0; i < n_tokens; ++i) { | ||
| - output_tokens[i] = skippy_sample_token_ith(session, sampling, i); | ||
| + // Native verification decodes and records the complete batch before | ||
| + // sampling. Remove that eager append, then expose each input exactly | ||
| + // once and in causal order as its row is sampled. | ||
| + if (session->token_history.size() < token_count) { | ||
| + skippy_set_error(out_error, SKIPPY_STATUS_RUNTIME_ERROR, "sampled verification token history underflow"); | ||
| + return SKIPPY_STATUS_RUNTIME_ERROR; | ||
| + } | ||
| + const size_t history_size_before_verification = session->token_history.size() - token_count; | ||
| + if (session->sampling_accepted_token_count > history_size_before_verification) { | ||
| + skippy_set_error(out_error, SKIPPY_STATUS_RUNTIME_ERROR, "sampled verification history is behind sampler state"); | ||
| + return SKIPPY_STATUS_RUNTIME_ERROR; | ||
| + } | ||
| + session->token_history.resize(history_size_before_verification); | ||
| + for (size_t i = 0; i < token_count; ++i) { | ||
| + skippy_record_tokens(session, &token_ids[i], 1); | ||
| + const int32_t logits_index = static_cast<int32_t>(i); | ||
| + output_tokens[i] = skippy_sample_token_ith(session, sampling, logits_index); | ||
| } | ||
| if (out_mtp_draft != nullptr && token_count > 0) { | ||
| status = skippy_mtp_propose_next( | ||
| @@ -5981,6 +5995,8 @@ enum skippy_status skippy_verify_tokens_frame_sampled( | ||
| return status; | ||
| } | ||
| } | ||
| + } else { | ||
| + skippy_record_tokens(session, token_ids, token_count); | ||
| } | ||
|
|
||
| return skippy_success(out_error); | ||
| -- | ||
| 2.54.0 (Apple Git-157) | ||
|
|
||
37 changes: 0 additions & 37 deletions
37
third_party/llama.cpp/patches/0048-Preserve-grammar-state-during-sampled-verification.patch
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.