Repository navigation
fix(provider): a stale slow prefill estimate stops refusing after three deadline refusals - #1956
Draft
jonathan308 wants to merge 8 commits into
Draft
jonathan308 wants to merge 8 commits into
jonathan308 wants to merge 8 commits into
Conversation
…ate in force A refused request starts no work, so it measures nothing. On an ordinary engine with one slow isolated-prefill sample and no calibration anchor, every later request is projected at that sample's rate and refused until the 30-minute idle expiry, however old the sample is. Add failing tests for the intended rule through the real submission path with a scripted engine (no model, GPU or real throughput): - three refusals on an idle Mac with evidence older than the freshness window are followed by an admission that remeasures the rate; - a Mac that remeasures as slow goes back to refusing; - an admitted request that measures nothing does not reopen admission straight away; - a full streak waits for an idle Mac. And guards that already hold and must keep holding: a request whose absolute deadline has passed is refused, fresh slow evidence keeps refusing, the kill switch keeps the previous behavior, and refusals beside another model's work are not counted. Co-Authored-By: Claude <noreply@anthropic.com>
A deadline_unreachable refusal admits nothing, so it measures nothing. On an ordinary engine an isolated prefill estimate that refuses an idle Mac could therefore only be replaced by the idle rules of IsolatedPrefillAdmissionRate: the calibration anchor after 120 s at nominal posture, or no projection after thirty minutes. With no anchor, with an anchor that is itself slow, or off nominal posture, one slow sample kept refusing long prompts for the full thirty minutes. DeadlineRefusalStreak counts consecutive refusals that only the isolated prefill rate explains: ordinary engine, idle Mac, a bounded projection of nothing but this request's own prompt, no reviewed calibration and no native media. After three with no admission in between, evidence older than the 120 s measurement freshness window stops blocking the next request that finds the Mac idle. That request is submitted like one with no measured rate, so its absolute deadline still applies, and its isolated prefill replaces the expired estimate. Fresh evidence refuses as measured. An admission that ends a full streak starts a 120 s retry interval, so a Mac that really is too slow gets one such admission per interval even when the request ends before it measures. Unbounded (fail-closed) projections never count, so memory admission is unchanged. Native engines keep their own recovery probe. DARKBLOOM_TTFT_ADMISSION_FIXES=0 turns the rule off with the other estimator corrections. No wire or output change. Co-Authored-By: Claude <noreply@anthropic.com>
Document the rule in the deadline section of the inference architecture page and in the hardware-support page's deadline admission rates, list the new cases in the test guide, extend the DARKBLOOM_TTFT_ADMISSION_FIXES row and note that `unmeasured_prefill` also covers a measured rate the provider set aside as expired. Add the changelog fragment. Co-Authored-By: Claude <noreply@anthropic.com>
The dedicated refactor pass renamed three methods on DeadlineRefusalStreak: `refused()` to `recordRefusal()`, `admitted(at:)` to `recordAdmission(at:)` and `estimateExpired(at:)` to `expiresStaleEvidence(at:)`. The first two mutate and read as queries in the past participle; the third is also true while evidence is fresh, so it should not sit beside `isolatedPrefillEvidenceExpired()` under a name that claims the same thing. Identifiers only: conditions, order and mutation points are unchanged. Co-Authored-By: Claude <noreply@anthropic.com>
… streak A calibration cell wider than one row refreshes its prompt-size bucket without touching the isolated-prefill aggregate. The refusal streak checks only the aggregate's age, so with such a bucket fresh it would set aside a measurement made seconds ago. This test fails until the next commit. Co-Authored-By: Claude <noreply@anthropic.com>
The refusal streak set aside the isolated-prefill estimate whenever the aggregate was older than the freshness window. A calibration cell wider than one row refreshes its prompt-size bucket and not the aggregate, so a measurement made seconds ago in this prompt's size domain could be set aside with it. The streak now also requires that no fresh bucket covers the prompt, which keeps "fresh evidence refuses as measured" true for both sources the projection reads. Co-Authored-By: Claude <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
… only A full refusal streak admitted the next request of any size without a time projection. A Mac that is honestly too slow for long prompts would then run one long prompt to its first-content deadline every 120 seconds where it used to refuse at once. Pin the limit the native recovery probe already uses (`PrefillEvidenceRecovery.maximumPromptTokens`, 1,024 tokens): - a prompt over the limit is still refused after a full streak, and the streak stays full for the next small prompt; - a slow calibrated Mac refuses long prompts however many it refuses. The streak tests now submit a 1,000-token prompt so they stay inside the limit. The two new tests fail until the next commit. Co-Authored-By: Claude <noreply@anthropic.com>
…only After a full refusal streak the next request on an idle Mac was submitted without a time projection whatever its size. Only the absolute deadline ends such a request, and that deadline grows with the prompt, so a Mac that is honestly too slow for long prompts ran one long prompt to its deadline every retry interval where it refused at once before. The unprojected admission now takes a prompt of at most PrefillEvidenceRecovery.maximumPromptTokens (1,024), the limit the native recovery probe already uses. A small prompt is enough to remeasure the rate. A longer prompt is refused from the expired evidence as before and leaves the streak full, so the next small prompt is the one admitted. A Mac that is sent only longer prompts is not helped by the streak: it refuses until a small request arrives or the 30-minute idle expiry, as before this branch. Docs and the changelog fragment state the limit. Co-Authored-By: Claude <noreply@anthropic.com>
Collaborator
Author
|
Held for 0.10.13 (not closed). The independent review ( |
This was referenced Nov 12, 2026
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
deadline_unreachablerefusal admits nothing, so it measures nothing. On an ordinary engine, a slow isolated-prefill sample that has gone stale can therefore keep refusing an idle Mac until the existing 30-minute idle expiry. After three such refusals in a row, the provider now admits the next request of at most 1,024 prompt tokens that finds the Mac idle without a time projection, and that request's prefill replaces the estimate. A longer prompt is still refused until a small request has remeasured the Mac.What was wrong
Before a request starts, the bridge builds a first-token admission policy from its measured rates and the engine projects whether the first token can arrive before the first-content deadline (
EngineV2Bridge.targetFirstTokenDeadlineAdmission,provider-swift/Sources/ProviderCore/Inference/Engine/Bridge/EngineV2Bridge+Admission.swift).devalready ages that evidence (#1541):IsolatedPrefillAdmissionRate.resolverestores an idle Mac at nominal posture to its calibration anchor once the sample is older than 120 seconds, and drops the projection once an idle Mac's sample is older than 30 minutes. Native block engines have their own bounded recovery probe (#1287).The gap is between those two rules. An ordinary engine keeps a stale slow sample in force for up to 30 minutes when:
Every request refused in that window leaves the estimate exactly as it was, because only an admitted request produces a prefill sample.
What changes
DeadlineRefusalStreak(provider-swift/Sources/ProviderCore/Inference/Performance/Deadline/AdmissionRateEstimators.swift) counts consecutive refusals and holds a retry interval.EngineV2Bridge.recordDeadlineRefusalcounts a refusal only when the isolated prefill rate alone explains it: ordinary engine, idle Mac, a bounded projection that priced nothing but this request's prompt (no decode work ahead of it), no reviewed calibration, no native-media rate.targetFirstTokenDeadlineAdmissionreturns no policy for the next request when all of these hold:PrefillEvidenceRecovery.maximumPromptTokens, the limit the native recovery probe of fix(provider): recover expired prefill evidence on idle native engines #1287 already uses),engine.submit, absolute expiry still enforced. Its isolated prefill replaces the expired aggregate (existingapplyRateObservationbehavior) and later requests are projected from the new rate.DARKBLOOM_TTFT_ADMISSION_FIXES=0turns this off with the other estimator corrections.Why a size limit: without a projection only the absolute deadline ends the request, and that deadline grows with the prompt. A Mac that is honestly too slow for long prompts would run one long prompt to its deadline every 120 seconds where it refused at once before. A small prompt is enough to remeasure the rate, and its worst case is short. A prompt over the limit is refused from the expired evidence as before and leaves the streak full, so the next small prompt is the one admitted.
Why a refusal count and not a new age bound: age bounds already exist (120 seconds and 30 minutes), and age alone cannot tell a Mac that is slow from one whose single sample was. The count is the signal that the estimate is the thing refusing; the 120-second freshness window, reused unchanged, keeps a current measurement authoritative. Why three: one refusal can be one long prompt, and two can be a client's retry of it.
What does not change
projection = not_attempted,projection_reason = unmeasured_prefill.Linked issue
None.
Test plan
All runs are unit tests with scripted engines or the in-memory toy fixture model. No real model weights were loaded, no benchmark was run and the whole suite was not run (shared Mac, GPU in use).
Commands, from
provider-swift/:swift test --filter 'AdmissionRateEstimatorTests'dev: 17 of 17 passeddeadlineUnreachablethrown where the request should be admitted), 21 passedswift test --filter 'EngineMeasurementOrderingTests|AdmissionRateEstimatorTests|ObservedRateDeadlineAdmissionTests|PrefillEvidenceRecoveryTests|PrefillEvidenceRecoveryStateTests|EngineV2PrefillSamplingTests|EngineDeadlineRetirementBridgeTests|EngineProfileCancelTests|DeadlineDecisionBridgeTests|EngineTransferredRetirementWorkTests|DecodeInterleaveDeadlineAdmissionTests|FirstContentDeadlineTests|CancelledSettlementLifecycleTests'on the head's Swift sources: 97 tests in 15 suites passedmake changelog-check: 68 valid fragmentsmake docs-impact-check BASE=origin/dev: coverage OKmake docs-check: 211 files OKNew cases in
AdmissionRateEstimatorTests:Not run: the full provider suite, SDK tests, GPU or real-weight tests, benchmarks, a live provider.
Components touched
Protocol / interface changes
Documentation impact
docs/architecture/inference.md(deadlines),docs/architecture/hardware-support.md(deadline admission rates),docs/developer/test.md,docs/reference/configuration.md(DARKBLOOM_TTFT_ADMISSION_FIXES),docs/reference/prediction-decision-telemetry.md(projection_reason).Changelog
changelog.d/deadline-refusal-streak-expiry.mdand ranmake changelog-check.Risks
devtoday.Rollout
DARKBLOOM_TTFT_ADMISSION_FIXES=0(this also turns off the other estimator corrections from fix(provider): correct the deadline-admission rate estimators #1541).Notes for reviewers
projected_service_us,remaining_us,submit_remaining_us,prefill_tpsanddecode_tpsindeadline_decision. A rate-source label, or a distinctprojection_reasonfor a streak-driven admission, needs a new closed-enum value mirrored in the platform repository, so it belongs in a coordinated change.ContinuousBatchingV2. Two inputs to the gate did change: GPT-OSShighreasoning effort is no longer rewritten tomedium, and an explicitmax_tokensbeyond the single-Mac window is now cut to fit where it was refused. Both can lengthen how long a row holds a slot, which a queued target's projection charges. That is the projection working as designed, so nothing is changed here; those refusals have decode work ahead of the target or a busy Mac and are deliberately not counted by the streak.targetFirstTokenDeadlineAdmissionstays a pure read of bridge state for the paths this change touches; the streak is mutated only in the submission path.devat the owner's direction.Before And After
Before: observable behavior and code flow
flowchart TD R["Request with a first-content deadline"] --> A{"Absolute deadline passed?"} A -- yes --> X["Refuse: expired_before_submit"] A -- no --> P["targetFirstTokenDeadlineAdmission builds a policy from the isolated prefill rate"] P --> E{"Engine projection fits the deadline?"} E -- yes --> ADM["Admit: prefill is measured and updates the estimate"] E -- no --> REF["Refuse: deadline_unreachable"] REF --> N["Nothing measured: stale slow estimate unchanged"] N --> RAfter: observable behavior and code flow
flowchart TD R["Request with a first-content deadline"] --> A{"Absolute deadline passed?"} A -- yes --> X["Refuse: expired_before_submit"] A -- no --> S{"Full streak of 3, prompt at most 1,024 tokens, aggregate older than 120 s, no fresh bucket, Mac idle, no retry interval running?"} S -- yes --> O["No policy: ordinary engine.submit, absolute expiry only"] O --> M["recordAdmission: streak reset, 120 s retry interval starts"] M --> U["Isolated prefill replaces the expired estimate"] S -- no --> P["Policy from the measured rate"] P --> E{"Engine projection fits the deadline?"} E -- yes --> ADM["Admit: recordAdmission resets the streak"] E -- no --> REF["Refuse: deadline_unreachable"] REF --> C{"recordDeadlineRefusal: idle Mac, bounded projection of this prompt only, no calibration, no native media?"} C -- yes --> INC["Streak plus one, capped at 3"] C -- no --> SAME["Streak unchanged"]Refactor Pass
A dedicated refactor subagent reviewed the diff against the repository's style rules, with the invariants above and the focused test command.
DeadlineRefusalStreak(recordRefusal,recordAdmission,expiresStaleEvidence), committed separately. It judged the guards, call sites, comments and test helpers fine as written and left the two similar guards unshared because they read different inputs.AdmissionRateEstimatorTests26 of 26.Review Follow-up
A second read-only review of the pushed head found that the unprojected admission had no size bound: on a Mac whose stale estimate is honest, three long prompts refused in a row let the fourth run to its deadline, once every 120 seconds. The last two commits add the 1,024-token limit, test first. The tests that exercise the admission now submit a 1,000-token prompt. Final validation is the 29 of 29 and 97-test results in the test plan.
🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.