Skip to content

vision: admission budgets: per-request rows (400) and in-flight rows (503 + Retry-After) (ported from Enntity) - #236

Merged
AzeezIsh merged 9 commits into
mainfrom
stack/vision-admission
Oct 29, 2026
Merged

AzeezIsh merged 9 commits into
mainfrom
stack/vision-admission

Conversation

@AzeezIsh

Copy link
Copy Markdown
Contributor

Stack: … ← #234 ← this.

Summary

  • Ports Enntity's vision admission (AGPL-3.0, 7d33dd4c, b060f987, 060199eb) with credit, on top of main's Qwen vision: per-request row cap (CEILING_MAX_PATCHES 16384) makes multi-image agent histories unservable; over-cap requests get retried forever #180 scheduler 400.
    • --vision-max-request-rows (32768): a request over budget gets a 400 at admit time, before any media fetch or decode.
    • --vision-max-inflight-rows (65536): when the in-flight budget is spent, the response is a 503 with Retry-After: 2.
    • Anthropic error types: invalid_request_error / overloaded_error.
    • Model::vision_row_limits, plus VisionItem holding its row permit.
  • Within both budgets, requests are byte-identical. Also raises VISION_MAX_GRID_ITEMS from 1024 to 8192 (theirs, for hour-long video item counts).

Test plan (vs parent #234)

  • vision_admit 9/9, vision_limits 15/15, msg_entry 20/20, refusal 24/24 (reiner). The entry-builder tests are trimmed until the media split lands in the next PR.
  • pair: vision-fidelity unchanged; an over-budget request gets the 400; concurrent multi-image requests over the in-flight rows get the 503

Tracking: #220.

Generated with Devin

@AzeezIsh
AzeezIsh force-pushed the stack/dflash-warm-ctx branch from 5e8f472 to 26a7c63 Compare October 29, 2026 05:50
@AzeezIsh
AzeezIsh force-pushed the stack/vision-admission branch from bdc9c03 to 0ead7cb Compare October 29, 2026 05:50
@AzeezIsh
AzeezIsh force-pushed the stack/vision-admission branch from 0ead7cb to 79e9093 Compare October 29, 2026 07:13
@AzeezIsh
AzeezIsh changed the base branch from stack/dflash-warm-ctx to stack/video-timestamps October 29, 2026 07:13
@AzeezIsh
AzeezIsh force-pushed the stack/video-timestamps branch from 24e509f to e6386f6 Compare October 29, 2026 07:19
@AzeezIsh
AzeezIsh force-pushed the stack/vision-admission branch from 79e9093 to 63d7c29 Compare October 29, 2026 07:19
@AzeezIsh
AzeezIsh force-pushed the stack/video-timestamps branch from e6386f6 to 6b2cf43 Compare October 29, 2026 07:20
@AzeezIsh
AzeezIsh force-pushed the stack/vision-admission branch from 63d7c29 to 339ea06 Compare October 29, 2026 07:20
@AzeezIsh
AzeezIsh force-pushed the stack/video-timestamps branch from 6b2cf43 to ea4e068 Compare October 29, 2026 07:29
@AzeezIsh
AzeezIsh force-pushed the stack/vision-admission branch from 339ea06 to eda90fe Compare October 29, 2026 07:29
@AzeezIsh
AzeezIsh force-pushed the stack/video-timestamps branch from ea4e068 to 53e9c2d Compare October 29, 2026 07:30
@AzeezIsh
AzeezIsh force-pushed the stack/vision-admission branch from eda90fe to 13b85cc Compare October 29, 2026 07:30
@AzeezIsh
AzeezIsh marked this pull request as ready for review October 29, 2026 07:39
@AzeezIsh
AzeezIsh force-pushed the stack/vision-admission branch from 13b85cc to b15cc3d Compare October 29, 2026 07:40
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Defect found on the pair. This PR's admission is never wired at runtime.

Every production caller passes AdmitCtx::default(), so the limits and the budget are both None. The callers are:

  • prepare.rs:126 (build_msg_entries, which serves chat, Responses and Anthropic messages)
  • chat/mod.rs:73
  • template.rs:349

Upstream's prepare.rs passes state.vision_limits / state.vision_budget. The unit tests pass because they build AdmitCtx directly.

What the stack-top check on b4d2a6541 showed (receipts in out/stacktop-b4d2a6541/):

  • 1, 2 and 4 × 2048² images were served, at 4098, 8196 and 16392 vision tokens.
  • 8 × 2048² (32784 vision tokens, over the 32768 per-request cap) was refused only by the generic Prompt too long ... max_seq_len check, with code: null, not vision_input_too_large.
  • 7 concurrent 4-image requests (114,744 rows against the 65,536 in-flight budget) were all admitted at once. No 503, and no "deferred at admission" log line.

The fix wires prepare.rs the way upstream does and adds a test through build_msg_entries with the limits set. The test fails on the current head. After the fix, the 400/503 checks run again on the pair. Other results from the same run: T's greedy C1/C8 outputs equal the references 8/8, and tools pass 21/21.

AzeezIsh added a commit that referenced this pull request Oct 29, 2026
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
@AzeezIsh
AzeezIsh force-pushed the stack/video-timestamps branch from 53e9c2d to 27629e0 Compare October 29, 2026 08:54
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
@AzeezIsh
AzeezIsh force-pushed the stack/vision-admission branch from e535188 to 2d377ef Compare October 29, 2026 08:54
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
@AzeezIsh AzeezIsh closed this Oct 29, 2026
@AzeezIsh AzeezIsh reopened this Oct 29, 2026
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
@AzeezIsh AzeezIsh closed this Oct 29, 2026
@AzeezIsh AzeezIsh reopened this Oct 29, 2026
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
…ission test to use #236's own path + drop useless conversion (500-LoC cap, clippy)
@AzeezIsh
AzeezIsh force-pushed the stack/vision-admission branch from 63939ae to 11e7dd2 Compare October 29, 2026 11:03
…3+Retry-After)

Port of Enntity/atlas 7d33dd4 + b060f98 + 060199e (AGPL-3.0-only).

--vision-max-request-rows (32768): a vision request's rows over the
bound is a 400 before any fetch/decode. --vision-max-inflight-rows
(65536): rows all requests hold at once; a spent budget is a 503 with
Retry-After. Within both bounds, requests are byte-identical.

vision_limits::VisionRowLimits + vision_budget::VisionRowBudget +
api/chat/vision_admit.rs::Admission; begin after collect_message_media,
note per item at pad_count, admit+attach each VisionItem. Model's
vision_row_bounds (encoder window + request bound) feeds
VisionRowLimits::resolve at startup. 060199e: Anthropic errors carry
the typed status (overloaded_error for 503) + pass Retry-After through.
…ission test to use #236's own path + drop useless conversion (500-LoC cap, clippy)
@AzeezIsh
AzeezIsh force-pushed the stack/vision-admission branch from 11e7dd2 to 0a313f9 Compare October 29, 2026 11:09
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
@AzeezIsh
AzeezIsh merged commit 60ded4f into main Oct 29, 2026
25 of 26 checks passed
AzeezIsh pushed a commit that referenced this pull request Nov 1, 2026
…ll syntax

Blocking cut GLM content at any unquoted native opener (SparkGLM's
"The delimiter <tool_call> opens a tool invocation." came back as "The
delimiter"). For literal-XML carriers (glm5_next, qwen4_exp) the orphan
cut now needs call syntax after the opener (a name with <arg_key>,
arguments or a close, JSON, or a function marker); other models still cut
at the opener. Reasoning cleanup strips a leaked closing tag at its own
position, so a quoted copy before it survives.

The GLM literal-XML stream tests (glm_literal_xml_tests,
qwen_literal_xml_tests, the native-literal and Poolside header cases) were
in a module nothing included since the stack's file split, and their
fixture tokens were gone. They run again on SparkGLM's fixture, with
end-to-end blocking/stream checks of the native opener in prose. The
#236 vision-cap test in that module fails once wired; it is marked
ignored for its owner.

Ported from Enntity/atlas 0ce591b, 095ff22, 17e5c92 and adb7a5b's
tests (AGPL-3.0-only).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
AzeezIsh pushed a commit that referenced this pull request Nov 1, 2026
The reasoning-leak opener scan maps its match (and_then(Some) -> map), as
Enntity/atlas 095ff22 has it, and the #236 vision test drops a useless
String conversion; both surfaced once the test module compiled again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant