Skip to content

DeepseekV4: support bounded partial rollback - #25691

Closed
YanissAmz wants to merge 1 commit into
ggml-org:masterfrom
YanissAmz:dsv4-partial-rollback
Closed

YanissAmz wants to merge 1 commit into
ggml-org:masterfrom
YanissAmz:dsv4-partial-rollback

Conversation

@YanissAmz

Copy link
Copy Markdown
Contributor

A DSV4 context refuses any partial seq_rm: a compressed block row is derived from a compressor-state ring addressed by pos%state_size, so a token cannot be removed once the rows it wrote have been overwritten. Speculative decoding therefore has to checkpoint and restore the whole sequence state on every draft, and re-evaluate the accepted tokens.

Size the rings with the same rollback budget the recurrent caches already use (n_rs_seq): oversizing them by n_rs_seq rows makes exactly the last n_rs_seq positions removable, because their rows have not aliased onto any row that an unfinished block still reads. A compressed row a removed token completed keeps stale contents, but it sits at block index pos/ratio and is not exposed to a token until (pos + 1)/ratio exceeds it, which cannot happen again before that position is re-decoded and rewrites the row.

The rings only grow when a rollback budget is requested (n_rs_seq = 0 otherwise), so a context without speculative decoding is unchanged.

test-dsv4-rollback decodes a prompt, decodes a wrong tail on top of it, rolls the tail back and replays the real one, and requires the logits to match a context that never rolled back.

Overview

Additional information

Requirements

A DSV4 context refuses any partial seq_rm: a compressed block row is derived from a
compressor-state ring addressed by pos%state_size, so a token cannot be removed once the
rows it wrote have been overwritten. Speculative decoding therefore has to checkpoint and
restore the whole sequence state on every draft, and re-evaluate the accepted tokens.

Size the rings with the same rollback budget the recurrent caches already use (n_rs_seq):
oversizing them by n_rs_seq rows makes exactly the last n_rs_seq positions removable,
because their rows have not aliased onto any row that an unfinished block still reads.
A compressed row a removed token completed keeps stale contents, but it sits at block index
pos/ratio and is not exposed to a token until (pos + 1)/ratio exceeds it, which cannot
happen again before that position is re-decoded and rewrites the row.

The rings only grow when a rollback budget is requested (n_rs_seq = 0 otherwise), so a
context without speculative decoding is unchanged.

test-dsv4-rollback decodes a prompt, decodes a wrong tail on top of it, rolls the tail back
and replays the real one, and requires the logits to match a context that never rolled back.
@github-actions github-actions Bot added the testing Everything test related label Jul 15, 2026
@ggml-gh-bot

ggml-gh-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown

Hi @YanissAmz, thanks for your contribution!

Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:

  • PR Template not respected: Please respect the template when creating a new pull request. Make sure to fill out all required sections.

  • Multiple open PRs from a new contributor: We limit new contributors (those without a previously merged PR) to 1 open PR at a time. You currently have 5 open PRs.


Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below.

@am17an am17an closed this Jul 15, 2026
@TacoTakumi

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Everything test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants