Repository navigation
server: --vision-image-share fixed gives every image the same share of the visual-token budget (#2510) - #2717
Conversation
fb71ce6 to
ff8e7ac
Compare
ashhart
left a comment
There was a problem hiding this comment.
Thanks for this. Pricing images in prompt order fixes the resume problem in #2510: an earlier image keeps its rows when a turn adds one. One thing blocks it as written. With the default 4,096-token budget, one full-size image can take the whole budget, so a request with two large images is now refused at the second one. Before this change, eight images shared the budget at about 512 tokens each. That breaks multi-image requests that work today.
Could the share stay stable without being first-come? For example, size each image at image_tokens / --vision-max-images (fixed for the server's life, so no turn re-sizes an earlier one), or keep the even split within a turn but price images from earlier messages as they were first prepared. Please keep your new refusal test, and add one for two full-size images in one request at the default budget that must pass.
|
GREEN at ff8e7ac — opencode-go/glm-5.3-flash as routed by Main (model id unverifiable); implementer model unverified. Red-first reproduced on my host: base tree + this head's tests = 78 pass / 2 fail / 80, the failures being 'expected 20, found 52' and 'expected error.Refused' — the old even split both shrinks the earlier image and refuses nothing, matching your receipt verbatim. At the head the media gate's image/video and core binaries pass (the step's api-module binary carries my container's 12 pre-existing originals_test env failures, identical at base, so the step as a whole is red here for reasons predating this PR). Mutation: replacing the running-left decrement with a per-image reset fails the past-budget refusal test; full removal is compile-rejected. Diff read: caps in prompt order, low-detail still capped, refusal names the image and flag before its fetch, single-image and all-fit identical to main; the appended image no longer re-sizes earlier ones so the cache identity holds. No GPU/image checkpoint here — the end-to-end resume rests on the host tests carrying the row identities, which they do. |
|
Thanks @devopsfortunato. The head hasn't changed since our review, so the blocking point still stands. With the default 4,096-token budget, the first full-size image takes the whole budget, so a request with two large images is refused at the second ("the images before it use the request's visual-token budget"), or the second gets almost no tokens. Today both get about 2,048 each. Could the per-image share be stable without being first-come? For example, size each image at I opened no other engine's source.
|
…shhart#2717) Each image is priced at --vision-image-tokens / --vision-max-images, a share that depends on neither the request's image count nor its position, so a turn that adds an image never re-sizes the ones already in the prompt and the cache resumes from the first image. The request's images stay within --vision-image-tokens, which is the row capacity each engine reserves, and a share that divides to 0 is refused by name.
…shhart#2717) Each image is priced at --vision-image-tokens / --vision-max-images, a share that depends on neither the request's image count nor its position, so a turn that adds an image never re-sizes the ones already in the prompt and the cache resumes from the first image. The request's images stay within --vision-image-tokens, which is the row capacity each engine reserves, and a share that divides to 0 is refused by name.
90bca17 to
74e6aa5
Compare
|
Rewritten as Why not the turn split. Every engine reserves exactly What it does. Every image takes that fixed share — 1,024 under the defaults — so a turn that adds an image never re-sizes the ones already in the prompt, the prompt cache resumes from the first image, and the request's images stay within The cost, said plainly. A lone image now gets a quarter of the budget, not all of it. That is the price of a share that can never move, and it is in the description, Your two tests. Two full-size images in one request at the default budget are admitted (1,024 each, Checks on |
|
Thanks @devopsfortunato, and thank you for checking the turn-split idea against what each engine actually reserves; that settles it. The share-of-0 refusal names both flags before anything is fetched, and the tests pin it. One change before this lands, and it's on us, since the fixed share was our suggestion. Dividing by
The tests would pin both ends: one image equal to main, and four images with equal shares whatever their order. Then the smaller things:
|
|
@devopsfortunato I owe you a correction, and a decision instead of another round of suggestions. My 10 Nov ask (divide the budget by the number of images in the request) is what main already does ( Looking at all three designs together, we've been asking for three things that can't all hold while every engine reserves exactly
Any two of these rule out the third. Prompt order gives up 2, the fixed share gives up 1, and main gives up 3. The decision: the default stays main's per-request split, so single-image and OCR replies don't change. Your current head's fixed share (
The three smaller points from my last comment (the dots.mocr recipe text, the two-line test comments, the Receipt section) still apply, adjusted to this.
|
|
Thanks @devopsfortunato for the rework and the clear tests. The current head still makes the fixed share the default: every image takes As we wrote on 12 Nov, the shape we can take is:
Since the opt-in changes tokens, please also state in the description the check it is held to, fixed before you run it: for example, the image questions and the pass mark against the default split. Post its result with the default path's token hashes beside it.
|
74e6aa5 to
6a856b6
Compare
6a856b6 to
ccac04e
Compare
|
Reworked as asked: the default stays main's per-request split, byte-identical with the flag unset (pinned for one and four images in |
|
Thanks @devopsfortunato, and thanks for the careful rework. The asks from our last comment are resolved: the default is main's per-request split, byte-identical with the flag unset and pinned for one and four images in One item remains. The check you wrote in the description has not been run: you were unable to run it on your host without a vision checkpoint, and we were unable to run it on this head before this review. The opt-in stays documented as unqualified until then. It needs a vision checkpoint on a GB10 (CUDA sm_121) with Qwen3.8-27B: on a two-turn chat where turn 2 adds a second image, turn 2 must resume from the first image's rows under
|
|
I ran a preliminary Metal check on an M5 Max with Qwen3.8-27B-MLX-4bit at For each arm I started a fresh server with
All arms answered all four color questions correctly. The four logged token hashes matched across all three arms ( Igor Lessio - AIFLOW LABS |
ccac04e to
ed93845
Compare
…f the visual-token budget (ashhart#2510) The default stays the per-request split, so replies without the flag are unchanged. With fixed, each image takes --vision-image-tokens / --vision-max-images whatever the request's image count, so a turn that adds an image leaves earlier images' rows where they were and the prompt cache resumes from the first image. A share of 0 is refused naming both flags.
ed93845 to
cb6ab0b
Compare
|
Thank you @devopsfortunato. 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. |
What this changes
A request's visual-token budget (
--vision-image-tokens, 4,096 by default) is divided by the number of images in the request, so a turn that appends an image re-sizes every earlier image, gives it a new cache identity, and the prompt cache cannot resume from the first image (#2510).This adds an opt-in,
--vision-image-share fixed, where every image takes--vision-image-tokens / --vision-max-imagestokens whatever the request's image count. The default is--vision-image-share request, main's per-request split, so with the flag unset the budget, the refusal text and the replies are unchanged. A fixed share that divides into nothing is refused naming the image and both flags. The flag needs--visionwhen it is notrequest.What the opt-in trades, as documented in
docs/vision.md: a lone image getsimage_tokens / max_images(1,024 under the defaults) instead of the whole budget, and in return an earlier image keeps its rows from turn to turn, so the cache resumes from the first image.This is the shape asked for in the review of the previous head: default stays main's split, fixed share opt-in, pinning test for one and four images, docs and changelog. The previous head made the fixed share the default; it is replaced.
d796b267e), one commit.atc overlap --json: coveragecomplete: false(pullRequestsLimit,pullFilesUnavailable); against current main the only conflict wasCHANGELOG.md, resolved by keeping both sides. Shared files with open PRs are listed by the tool; the source files I touch beyond the vision path are one-line.image_share = ...additions to familyapi.Visionliterals.Checks on this head
ccac04ed2tools/pr_check.py --base upstream/main --pr 2717): 168 on base, 168 on head, 0 new findings, 0 errors, 0 warnings.zig fmt --checkandgit diff --checkclean.zig build test-vision-cli-host— 25/25 pass.zig build test-media-request-ownership-host— 890 pass, 2 skipped, 0 fail (reachesimage_share_test.zigandimage_reuse_test.zig).zig build test-server-cpu— 1671 pass, 15 skipped, 0 fail.expected 40, found 16,expected 8, found 2, the 3-token request split). Changing the default's refusal text fails the exact-string assertion.zig build test-goldenand the fullzig build test(host has 8 GB; CI runs them), and no device gate: no kernel, precision or cache format changes, and the host has no GPU or checkpoint.Receipt
This reaches prompt preparation (how many visual tokens an image may take), not inference arithmetic.
image_tokens / n_images) and main's refusal string.image_share_test.zigpins it for one image (cap equal to the whole budget, ids and cache words) and for four images (a quarter each).images.expandon requests with image parts, for every family that opens vision. Each family'sapi.Visionreceives the share from itsVisionOpen;vision_inputs.zighas its own pricing but nothing references it.--vision-image-share request|fixed, defaultrequest, other values refused by name by the existing flag parser, needs--visionwhen notrequest; no profile row (it changes tokens whenfixed, so it is not a--profileswitch).d796b267e, Zig 0.17.0, Linux aarch64, 4 cores, 8 GB RAM, no GPU, no checkpoint.--vision-image-share fixedturn 2 must resume from the first image's rows (cached tokens cover the first image's prefix), where the default re-prepares the first image (cached tokens stop before it). Its answers are then compared with the default split's on the same image questions, and the opt-in passes only if no question that the default answers correctly is answered wrongly. This needs a vision checkpoint, which this host does not have; I have not run it. I can post the result with the default path's token hashes beside it once a run is possible, and the opt-in stays documented as unqualified until then.Checklist