Repository navigation
Provider: prompt preparation holds a share of the whole-Mac serving allowance - #2613
Merged
Merged
Conversation
A full Mac refuses a text request as capacity before rendering its prompt, a prompt being prepared holds the last serving share against another request, a prompt prepared on the last share is served on it, and a failed render returns its share. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A text request now takes one serving share before its prompt is rendered and tokenized, under the owner ID its submission uses. A full Mac refuses the request as capacity before that work, and prompts being prepared at the same time count against the serving width. The bridge's allowance takes the share over in place at submission, so the request cannot lose its place between preparation and admission; a share not taken over is returned when preparation ends, on every exit path. Preparation shares count only toward admission: reported usage, deadline work and calibration evidence still start at submission. The owner's local requests, which wait for room at submission, take none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
7 tasks done
…shes The preparation admission tests now use a local engine that answers each request with one token and a stop terminal, so a served request ends without a stream error and the tests check that it was served. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308
pushed a commit
that referenced
this pull request
Nov 24, 2026
…rve prompt preparation tests on an engine that finishes
This branch was successfully deployed
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.
Summary
A text request's prompt was rendered and tokenized before the request took its share of the whole-Mac serving allowance, so any number of prompts could be in preparation at once on a Mac whose serving width was already full, each using CPU and memory before being refused at submission.
Now a text request takes one serving share (
WholeMacServiceBudget.acquirePreparation, viaEngineV2Bridge.acquirePromptPreparation) before its prompt is rendered and tokenized, under the same owner ID its submission uses:acquiretakes the share over in place, so an admitted request cannot lose its place between preparation and submission and is never counted twice. A share not taken over is returned when preparation ends, on every exit path (defer).OwnerMemoryWait), take no preparation share. Coordinator and pair requests always do.Planned follow-up (separate PR): let the owner's local requests wait for a preparation share as well, so their preparation is bounded the same way.
Tests-only control (expected to fail on
devat the new tests): #2612Behavior
flowchart LR subgraph Before A1[Text request] --> P1[Render + tokenize prompt] P1 --> S1{Serving share free?} S1 -- yes --> G1[Serve] S1 -- no --> R1[Refuse as capacity, after the work] end subgraph After A2[Text request] --> S2{Serving share free?} S2 -- no --> R2[Refuse as capacity, before any work] S2 -- yes --> H2[Hold the share] H2 --> P2[Render + tokenize prompt] P2 --> G2[Submission takes the share over, serve] P2 -- fails --> E2[Share returned] endCode
flowchart TD subgraph Before PC1[MultiModelBatchSchedulerEngine.prepareCompletion] --> TM1[tokenizeMeasured] TM1 --> SUB1[submitTokenized] SUB1 --> AC1["WholeMacServiceBudget.acquire(ownerID)"] end subgraph After PC2[MultiModelBatchSchedulerEngine.prepareCompletion] --> AP2["EngineV2Bridge.acquirePromptPreparation(requestID)"] AP2 --> PR2["WholeMacServiceBudget.acquirePreparation(ownerID): charges + other preparations + share ≤ 1"] PR2 --> TM2[tokenizeMeasured] TM2 --> SUB2[submitTokenized] SUB2 --> AC2["acquire(ownerID): counts other preparations, converts its own in place"] PC2 -. defer .-> END2["PromptPreparationShare.end(): releasePreparation if not taken over"] endValidation
PromptPreparationAdmissionTests(a full Mac refuses before rendering; a prompt being prepared holds the last share against another request; a prompt prepared on the last share is served on it; a failed render returns its share) andWholeMacPreparationShareTests(occupancy, in-place takeover, once per owner, reporting still starting atacquire, recovery next to another preparation).PromptPreparationAdmissionTests.swifton the same base, using only existing APIs; the first two tests are expected to fail there on behavior, the last two are guards that pass on both.run-ci); no full provider build was run locally.changelog.d/prompt-preparation-serving-share.md. Docs:docs/architecture/inference.md,docs/architecture/hardware-support.md.dev(c579589b3).Known effects, accepted: a request that fails preparation (bad template, over the window) briefly holds a share; on a full Mac a request whose first-content deadline already passed now gets the capacity refusal instead of the deadline refusal (both retriable 503s).
Refactor pass
Independent refactor pass on this head: no change warranted; locking, in-place takeover, release on every exit path, and the owner-local exemption checked.
Changelog
changelog.d/prompt-preparation-serving-share.mdOpen in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.