Repository navigation
Prompt cache: an opt-in rule for families to count keyed image prompts as repeats - #1929
Merged
Merged
Conversation
14 of 26 tasks
This was referenced Nov 2, 2026
Merged
Merged
prompt_cache.zig sits at the 600-line lean limit, so no family can add a cache rule without splitting it. The Rules struct depends on nothing else in the store, so it moves unchanged into prompt_rules.zig and prompt_cache.zig re-exports it, leaving every caller and default as before.
The repeat log only notes raw prompts, so image and keyed requests never earn a repeat cut, and an OCR family that serves the same page image again re-prefills it every time. A new prompt cache rule, repeat_keyed, lets a family opt in: the lane host then notes a keyed request under the same effective cache key that lookups and saves use, so its second pass keeps a repeat cut and later passes resume from it. The rule defaults to false, so existing families keep the raw-prompts-only behavior, and frame tests cover both settings.
ashhart
force-pushed
the
pr-ocr-cache-repeat-keyed
branch
from
November 2, 2026 15:51
0f809ac to
a5a7aaa
Compare
Owner
|
Thank you @laudney. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
Owner
|
Thanks @laudney! This is in TensorFold 1.2.2, out now: https://github.com/ashhart/TensorFold/releases/tag/v1.2.2 |
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.
Part of #1927.
The repeat log keeps only raw prompts: a request with images or a cache key is never noted, so every family keeps today's policy for image prompts. OCR families want the opposite for their own requests. Users resubmit the same page with the same instruction, and the prompt state that resumes it is keyed by image content and frame identity, not by the raw token IDs. This PR lets a family opt in to noting those keyed prompts, under the same key its lookups and saves use, and leaves every existing family unchanged.
Rules.repeat_keyedprompt_cache.zigsizeprompt_rules.zig31Changes
refactor(cache):prompt_cache.zigsits at the 600-line limit, so no rule can be added there.Rulesdepends on nothing else in the store, so it moves unchanged intozig/src/core/prompt_rules.zig, andprompt_cache.zigre-exports it. Every caller and default stays the same.feat(cache):Rules.repeat_keyed: bool = false.lane_hoststill notes raw prompts (no images, no cache key) exactly as before. Withrepeat_keyed, it also notes a request that carries a cache key, underjob.cacheKey(). A family sets it in its ownRules. No family sets it in this PR. GLM-OCR and Nemotron Parse will set it (Native OCR models on HIP: dots.mocr, GLM-OCR, LightOnOCR-3 and Nemotron Parse, CUDA to follow (tracker) #1927).Gates
lane_host_frame_test.zig: the frame-cache test runs with the flag off and on. With it off, a repeated keyed image request leaves the repeat log empty, as on main. With it on, the repeat keeps its cut and the next request resumes from it with the same output tokens.zig build test-lane-api-host: 456/456.zig build testwith the tokenizer PR on top, 465/465 steps, 6,177/6,222 tests (45 skipped);zig build test -Dhip=truewith the rocBLAS PR beneath, 492/492 steps, 6,187/6,234 tests (47 skipped).prompt_cache.zig572 lines,prompt_rules.zig31).