Expose exllamav3's recurrent checkpoint intervals in the model config - #468
Open
matthematics1137 wants to merge 1 commit into
Open
matthematics1137 wants to merge 1 commit into
matthematics1137 wants to merge 1 commit into
Conversation
Add recurrent_checkpoint_interval and recurrent_checkpoint_interval_pp to the model section and /v1/model/load, passed to the generator only when set so the engine defaults (2048 / 32768) apply otherwise. A denser ingestion grid makes the cost of editing a cached prompt proportional to the distance from the edit to the end of the prompt (recurrent states cannot roll back), for one recurrent state of host RAM per checkpoint. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
+1 In fact, I came here looking for precisely these knobs. When (say) running Deepseek V4 or a similar model using most of system RAM, they're quite useful for tuning caching behavior. |
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.
Is your pull request related to a problem? Please describe.
exllamav3 checkpoints the recurrent state of hybrid models so a request with a matching prefix resumes instead of re-prefilling, and its
Generatortakes two interval arguments for that. TabbyAPI passes neither, so a long prompt is checkpointed only near its end and any edit earlier in a cached prompt (a system header, an early tool result) costs a full re-prefill.Why should this feature be added?
Two optional
model:keys (also on/v1/model/load) pass the intervals through only when set, so the engine defaults apply otherwise. With a 1,024-token ingestion grid the cost of an edit becomes proportional to its distance from the end of the prompt instead of all-or-nothing, for +2-3% cold prefill and one recurrent state of host RAM per checkpoint.Examples
Edit at token 1,321 of a 5,266-token cached prompt: TTFT 10.2 s today, 8.6 s at interval 1024; edit at token 3,769: 10.1 s today, 5.0 s at 1024 (full table below, measured on a 27B Qwen3.5-class hybrid on a 12 GB RTX 4080 Laptop).
Additional context
Details, measurements, testing and risks follow. Companion PR: #467 (slot-cost log); the two touch the same docs row.
Motivation
exllamav3 keeps checkpoints of the recurrent state of hybrid models (Gated DeltaNet, short-conv, SWA
layers) in host RAM so a request with a matching prefix resumes instead of re-prefilling.
Generatortakesrecurrent_checkpoint_interval(default 2048; the last 2 x chunk_size tokens of the prompt, andgeneration) and
recurrent_checkpoint_interval_pp(default 32768; the rest of the prompt). TabbyAPI passesneither (
create_generator), so a long prompt is checkpointed only near its end; recurrent states cannotroll back, so an edit before that (a system header, an early tool result) costs a full re-prefill.
Measured on a 27B Qwen3.5-class hybrid (48 recurrent layers, EXL3 2.0 bpw, MTP drafter, 12 GB RTX 4080
Laptop at 80 W): 5,266-token prompt, one word edited at the given token position after the unedited
prompt was served once, TTFT in seconds, median of two repeats. The interval was set with a lab-only
engine patch (env var), since TabbyAPI has no knob:
Every cell is "replay from the last checkpoint at or below the edit" at ~470 tok/s: the edit cost becomes
proportional to the distance from the edit to the end of the prompt instead of all-or-nothing. Price:
+2-3% cold prefill; one host-RAM checkpoint per extra grid point (148 MiB for this model: +147 MiB RSS at
2048, +447 MiB at 1024, from the 4 GB
sysmem_recurrent_cachebudget); VRAM identical (8,756 MiB).(Evidence: the author's lab notes, see the footer.)
Change
common/config_models.py: optionalmodel:keysrecurrent_checkpoint_intervalandrecurrent_checkpoint_interval_pp(int,multiple_of=256,gt=0, default None = engine defaults).backends/exllamav3/model.py:create()reads both (warning if set for a model without recurrentlayers);
create_generator()passes each toAsyncGeneratoronly when set, so the engine defaultsstay in force otherwise, and logs the effective values (the engine rounds
_ppup to a chunk multiple).endpoints/core/types/model.py: the same fields onModelLoadRequest(/v1/model/load), likechunk_size; a separable hunk if config-only is preferred.config_sample.yml,docs/02.-Server-options.md: documentation with the trade-off above; the sampleentries are what
generate_config_file()produces from the new descriptions.Testing
On the author's machine: the engine-side effect (table) was measured with the lab env-var patch, not with this PR, which was
checked statically only (no server run): it applies cleanly to the pristine files;
py_compile; pydanticaccepts 1024/2048 and rejects 1000 and 0 for both keys on
ModelConfigandModelLoadRequest;generate_config_file()reproduces the sample entries. Owner re-test: load Qwen3.8-27B EXL3 withrecurrent_checkpoint_interval_pp: 1024(then 2048), check the "Using recurrent checkpoint intervals"line, rerun
tools/edit_probe.pyand expect the rows above and +447 / +147 MiB RSS; a non-recurrentmodel with the keys set (warning only); one API load with the keys;
use_as_defaultwith one key.Risks and compatibility
accept both arguments (checked);
Generator.__init__takes**kwargs, so older engines ignore them.multiple_of=256for both keys; the engine's own assert only checks the generationinterval (twice, an upstream typo) and rounds
_ppup to a chunk multiple.recurrent_checkpoint_intervalalso widens the allocation boundary in TabbyAPI'svalidate_context_requirementsand the engine'smax_rq_tokensalignment (job.py);_pphas no suchcoupling. Denser grids fill
sysmem_recurrent_cachesooner (4 GB = 27 checkpoints here); overflow onlyevicts older checkpoints (LRU).
docs/hunk needs a trivialmanual merge (both touch the
max_batch_sizerow); the other files stack in either order.Measurements and the pre-registered experiment log are in the author's lab notes (private for now; the relevant tables are reproduced above, and the full write-up is available on request).
🤖 Generated with Claude Code
https://claude.ai/code/session_01FWY9bG6iQAswvYgYFch6ex