Repository navigation
fix(provider): keep newest performance observation timestamp - #1398
darkbloombugs wants to merge 6 commits into
Conversation
|
@darkbloombugs is attempting to deploy a commit to the EigenLabs Team on Vercel. A member of the Team first needs to authorize it. |
Threat model review — advisoryReviewed head Review not completed for this head. Previous findings are superseded, not confirmed resolved. Models: budgeted Sonnet / selective Opus / selective Sol 6.1. Findings require human validation; this review never requests changes or blocks merging. Failure diagnostics: Coverage: 26/38 source units; cross-file integration pending. 0 selected depth batch(es) pending. All threat definitions indexed; relevant full definitions selected. Unchanged callers are not scanned. Cost this run: $0.5091 reported, $0.0000 reserved with unknown cost; 6 paid request(s), 0 reused batch(es), 58855 provider cache-hit tokens. Saved findings and earlier report · Historical findings are not confirmed resolved. |
|
Maintenance candidate Fresh candidate compilation used copied local dependency/build caches: the first single-job attempt hit its preserved 590-second limit, then a sequential continuation succeeded in 586.490 seconds. 59 distinct functions / 64 cases passed, including ordering and build-environment tests; the separately rerun four ordering tests overlap that total. Checks on that candidate passed 14 changelog tests, five fragments, 368 documents and six-file documentation coverage. Newer master The baseline’s two failing tests / ten assertions and two passing controls remain historical, not freshly executed against master. This does not qualify the full provider runtime suite, live inference, GPU/model execution, hardware performance or coordinator routing. CI/reviewer gates remain; advisory review stopped with HTTP 409 at 0/52 units. No merge or deployment. |
|
Reviewed remote head Source review found no actionable defect in the timestamp fix. A signed local refresh against master Fresh validation of local candidate Documentation impact/checks, changelog checks and 31 Python tooling tests also pass. No GPU/model, live-fleet or native Apple qualification is claimed. Publication is held: these non-draft PRs trigger the paid-capable threat-review workflow on |
|
Refreshed onto master Conflicts fixed: Proof:
Review checked master's #1446 calibration paths. Nothing depends on Non-blocking follow-up: |
davidtai
left a comment
There was a problem hiding this comment.
Reviewed. at = max(at, now) is the right one-line fix: freshness tracks the newest observation while EWMA order and counts stay receipt-ordered, and the reseed check already handles a negative now - at. Wire format unchanged. Approving; merge once the approved CI run is green.
Keep both the Performance Observation Ordering and Watchdog Launch Evidence sections of docs/developer/test.md. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
davidtai
left a comment
There was a problem hiding this comment.
Re-approving after resolving a docs-only conflict in docs/developer/test.md (kept both the Performance Observation Ordering and Watchdog Launch Evidence sections). No source change; the one-line max(at, now) fix is unchanged.
* fix(provider): correct the deadline-admission rate estimators Deadline refusals on ordinary engines (each one a failover hop, then another queue and prefill elsewhere) came from three estimator defects: - Decode was charged per running row against a per-request EWMA, about B times too much at batch width B (#1521), and every MTP row was charged its full 1+k draft width. The bridge now measures each completed request's decode-step shape (rows, confirmed tokens and assigned width per step), smooths and resets it with the decode EWMA, and passes it to the SDK's per-batch charge. A request carrying a reviewed deadline calibration gets no shape: its calibrated conversion and its fallback keep the per-row charge its error envelope was measured against, so serving qualification's two-conversion proof (calibratedPathProven) still holds. The deadline catalog is empty, so no production request carries a calibration today. - One externally contended "isolated" prefill sample after an idle gap replaced the estimate and could lock an ordinary EngineV2 engine out until restart (#1429). Admission now prices no lower than one eighth of the startup calibration cell's idle rate, and restores that rate when the evidence expired while the engine sat idle at nominal posture. Evidence older than 30 minutes on an idle engine is treated as absent, anchored or not, because a calibration cell can itself run under another process's GPU load. Published rates are unchanged. - A late older completed observation moved freshness backward (the fix of open #1398, max(at, now), carried here with its test) and could restart the combined prefill EWMA. Deadline decision and request-profile telemetry keep their wire fields, but projected_service_us is no longer the per-row formula of the projected tokens and rates. DARKBLOOM_TTFT_ADMISSION_FIXES=0 restores the previous estimators. libs/mlx-swift-lm moves to the per-batch charge commit on SDK main. SDK main's Package.swift requires mlx-swift 81f58d79, whose GPU.CommandBufferLimits (mlx-swift #57) MLXLMCommon uses, so libs/mlx-swift moves to that commit and libs/mlx to its nested MLX 71271f08 (mlx #36). That MLX change is host-side only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(provider): forward the admission-estimator rollback to launchd launchd does not inherit the installing shell, so a DARKBLOOM_TTFT_ADMISSION_FIXES=0 export reached only a foreground provider: the background provider job kept the corrected estimators, and restarts and watchdog recovery reuse its saved plist. Add the key to LaunchAgent.inferencePassthroughEnvKeys beside DARKBLOOM_PREFILL_DEADLINE_MODE, so darkbloom start persists it into the provider plist. The watchdog plist stays without it: it never runs inference. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(provider): tidy deadline-admission comments, docs and coverage Behavior-preserving follow-up from the independent refactor pass: - IsolatedPrefillAdmissionRate.resolve drops its freshness parameter, which no caller passed, and reads EnginePerformanceMeasurements.freshness. - ServingQualificationDeadlineEvidence said the SDK has exactly two service conversions. That now holds only for requests carrying a reviewed calibration, which get no per-batch decode shape; say so. - Add AdmissionRateEstimatorTests.completedRequestRecordsDecodeShape: a scripted request finishes through the real bridge event pump and its terminal timing must reach the decode-shape estimate. Dropping the decodeShape argument in recordPerformanceFinish failed no test before. - inference.md: a step costs one measured step only while it is no wider and has no more decode rows than the measured steps; it said a plain step costs one cadence whatever its batch size. Split the estimator paragraph and list AdmissionRateEstimators.swift in the code map. - prediction-decision-telemetry.md: MTP rows can be charged fewer than 1+k tokens without dropping to one. - Changelog: subject-verb agreement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(provider): move libs/mlx-swift-lm to the SDK refactor-pass commit 4b8a1bbd adds the paired SDK PR's refactor-pass follow-up on top of 51773fe1: documentation comments in FirstTokenDeadlineAdmissionV2.swift and the request fixture of one unit test. No library code changes, so the provider build and its metallib are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(provider): trim line endings from the admission-estimator rollback value DeadlineAdmissionFixes.resolve trimmed only .whitespaces, so a DARKBLOOM_TTFT_ADMISSION_FIXES value ending in a line ending (from a file or a deployment template, which LaunchAgent forwards to the provider job unchanged) matched none of 0/false/no/off and silently left the estimator corrections on. Trim .whitespacesAndNewlines, as the other documented "trimmed, case-insensitive" rollbacks do (MiMoV26WiredResidency.isEnabled, MiMoV26DecodeDefaults.isEnabled). killSwitchParsing now covers newline-terminated off and on values, and forwardsDeadlineAdmissionRollbackToProviderJob checks that a forwarded "off\n" still disables the corrections in the job. Both fail with the previous trimming. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(provider): state deadline-admission estimator effects in hardware support docs/AGENTS.md maps native admission changes to both architecture/inference.md and architecture/hardware-support.md; the estimator corrections updated only the former. Add a "Deadline admission rates" section: the corrections grant no memory and leave KV grants, load quotations, activation floors, serving width and memory concurrency unchanged; the MTP depth charge follows the chip's automatic verification envelope; the isolated-prefill anchor is the serving Mac's own startup calibration and is restored only at nominal posture, so Low Power Mode or a non-nominal thermal state keeps only its floor. List the estimator sources in the code map. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(provider): cite the measurement producer by full path and symbol The newest-observation age rule cited a bare EnginePerformanceMeasurements.swift, which docs-check cannot resolve. Cite provider-swift/Sources/ProviderCore/Inference/Engine/Bridge/EnginePerformanceMeasurements.swift and EnginePerformanceMeasurements.observe, which applies the rule to the aggregate, current-posture and workload-bucket series. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Re-pin libs/mlx-swift-lm to the merged SDK change (#329) Layr-Labs/mlx-swift-lm#329 squash-merged as e28f89de ("fix(cbv2): charge first-token deadline decode once per batch step (#329)"). Move the gitlink from the PR branch head 81f0ef74 to that commit on SDK main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(provider): bound only the aggregate prefill rate, on a whole-Mac idle check Two corrections to the anchored isolated-prefill rate on ordinary engines. The one-eighth startup-anchor floor was applied after the fresh prompt-size bucket had tightened the rate, so it could raise a fresh, legitimately slow long-prompt bucket: a 5,000 tok/s 512-token anchor priced a fresh 100 tok/s 32K-prompt bucket at 625 tok/s. The floor now bounds only the aggregate, and the fresh bucket still tightens the result afterwards. Bucket evidence expires after 120 seconds, so this cannot bring back the restart-long lockout. Restoring the idle anchor, and treating evidence older than 30 minutes as absent, checked only this bridge's own requests. On a multi-model provider another resident model could be using the GPU. Both now also require that the shared whole-Mac service budget holds no other model's lease and no load, encoder preparation or cache transfer (WholeMacServiceBudget.isIdle(except:)); the request's own lease does not count. Without a shared budget the bridge-local check remains. Regression tests: freshLongPromptBucketBelowFloor and otherModelWorkKeepsAnchorOff fail with either change reverted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(provider): smooth decode step time together with its shape Per-batch decode charging prices each projected step as one measured step, tokensPerStep / rate, scaled by rows and width. The per-request decode TPS and the step shape were smoothed independently, so samples from different batch widths produced a pair no request measured: 10 tok/s at eight rows, then 100 tok/s solo, gave 37 tok/s at 5.9 rows and priced an eight-row step at about 0.037 s against 0.1 s measured. MeasuredDecodeStep now smooths each request's mean step duration and its shape with one weight and is reset with the decode EWMA, and admission passes the rate implied by that duration (DeadlineAdmissionFixes.decodeCharge). The priced step time and time per row are weighted averages of measured ones, so they stay inside the measured range; the eight-row step above is now priced at about 0.099 s. The published per-request decode EWMA, the per-row charge kept for reviewed calibrations and the kill-switch path are unchanged. Regression test: decodeRateAndShapeStayCoupled fails with the independent smoothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(provider): leave the first-token step's rows out of the decode shape engineDecodeRate times decode from the first token to the last, so it covers only the decode steps. The measured step shape averaged batchRowsSum, which also counts the step that confirmed the first token, over decodeSteps + 1. A first token produced in an eight-row step followed by solo decode reported 4.5 rows for a solo-step rate, letting admission price several projected rows at that rate without scaling. The engine publishes prompt completion from the first-token step right after recording the row's participation in it, so the prefill receipt's sample carries that step's row count (EnginePrefillReceipt.firstTokenStepRows). engineDecodeShape subtracts it and averages over the decode steps alone; without a usable count (cancelled before the first token, native block timing, inconsistent counters) it keeps the previous average. No SDK change is needed. Regression tests: firstTokenStepRowsExcluded drives the real bridge pump and fails when the receipt's count is not passed; decodeShapeFromTiming pins the arithmetic and fallback. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(provider): pin measurement-ordering tests to the fixed estimators EnginePerformanceMeasurements and EngineV2Bridge default their estimator flag to the process-wide DARKBLOOM_TTFT_ADMISSION_FIXES, so exporting the kill switch made the newest-observation assertions fail. Set keepsNewestObservationTime and admissionFixes explicitly, as the kill-switch test already does for the old behavior. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: correct the DARKBLOOM_PREFILL_DEADLINE_MODE default to enforce PrefillDeadlineMode.resolve returns .off only for an exact "off" and enforces otherwise, including when the variable is unset; an explicit [backend] prefill_deadline_mode in provider.toml takes precedence. The configuration reference listed the default as off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: describe the corrected deadline estimators with full source citations - inference.md and hardware-support.md: cite paths with every symbol (CBv2DecodeRateShape, CBv2MTPRoundDriver.speculationDepthCeiling, CBv2MTPConfig, MTPAutomaticVerificationPolicy.maxRectangularTokens, EngineV2Bridge.calibrationPosturePermitsWork, ServingQualificationDeadlineEvidence). Describe the coupled step smoothing and qualify the scaling claim: it is a bound for a single measurement, and across batch widths an average of measured steps. Describe first-token-step row exclusion, whole-Mac idleness, and the floor applying to the aggregate only. - prediction-decision-telemetry.md: decode_tps under per-batch charging is the step-implied rate, which can differ from observed_decode_tps. - test.md and the changelog fragment cover the new behavior and tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(provider): tidy the deadline-estimator review fixes Drop the unused Equatable conformance from MeasuredDecodeStep, state precisely why the prefill receipt's row sum is the first-token step's rows, and attach the 30-minute-expiry comment in otherModelWorkKeepsAnchorOff to the block that exercises it. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Completed performance observations can reach the provider bridge out of timestamp order.
EnginePerformanceMeasurements.Rate.observeoverwrites its timestamp with each receipt, so a late older receipt can make fresh evidence appear expired and make the next sample reseed across a false evidence gap.Keep the newest timestamp with
at = max(at, now). The same private rate owner serves aggregate, current-posture and workload-bucket observations. Existing receipt-order EWMA contributions, sample counts, completed-work counters and independent shape buckets remain intact.Before
After
Amber is completed work, blue is the production code path, red is incorrect freshness, and green is the corrected result.
Current refresh validation (October 9)
Signed refresh
2574f44f7ef479819f23693a26ff1576f5a5561bincludes mastercea374e88c1fd970859fccc949e3bb5f51513874. Production code and regression tests remain unchanged from the previous public head. The incoming provider build-environment and retired development-host changes are retained. The changelog preserves all incoming entries and this fix once; canonical documentation was reverified for October 9.swift build --build-tests --jobs 2 --force-resolved-versions: full test executable builds.swift test --skip-build --no-parallel --filter EngineMeasurementOrderingTests: 4/4 pass; the focused selection passes again after review.BuildEnvironmentTests: 4/4 pass, checking compiled production defaults and pure URL resolution.make docs-impact-check BASE=cea374e88c1fd970859fccc949e3bb5f51513874: six-file delta passes.make docs-check: 368 files pass. The earlier c93380 historical-link failure is retained in local evidence; master now contains the source-citation repair.Independent exact-patch correctness review and dedicated refactor assessment found no actionable issue and recommended no cleanup changes. Review included the actual code/callers, retained failing baseline and current validation logs; the reviewer did not rerun tests independently.
Normal commit and push hooks passed. The signed refresh was pushed non-force to private staging before the existing public branch, and GitHub verifies its signature. Hooks that traverse coordinator tests run without database/service credentials; database-dependent skips do not qualify a PostgreSQL lane. Checks use pinned installed dependencies, the existing CPU lane, at most two jobs, and a 590-second command limit plus up to ten seconds for teardown.
Validation still uses the actual measurement owner and bridge with the existing scripted engine and synthetic usage/clock boundaries. It does not qualify GPU/model inference, native hardware, a live fleet, or the general provider runtime suite. Receipt-order averaging and the separate combined-prefill scalar reset policy remain unchanged.
The PR was marked ready for code review on October 10, 2026. Latest-head CI and reviewer/approval gates are separate from these local results. No merge, deployment or release is requested.
Reproduction and validation (original reproduction)
Base:
e3575b993cb56f1930b9ee7825c0d0553410e820; Apple Swift 6.3.2 on macOS 26.3.1 arm64. Local SDK pin:3fd4944c3b3ee5cb45c5cbfac8805876332d3a29. Checks use existing pinned dependencies, two build jobs, sequential tests and 600-second command caps.swift test --skip-build --no-parallel --filter EngineMeasurementOrderingTests— 2 tests fail with 10 assertions; 2 controls pass. The owner reports age 122,000 ms instead of 1,000 ms, loses aggregate/qualified/shape freshness, and reseeds the next sample to 500 instead of 1,151 TPS.EngineV2Bridgerequests against the existing scripted engine, captures actual monotonic completion timestamps, then delivers their terminals in reverse order. Decode expiry moves backward on baseline. Both requests and all 32 generated tokens are still counted.recordAggregate: falsebuckets are controls.swift build --build-tests --jobs 2 --force-resolved-versionspasses. The final 55-test CPU selection passes after the refactor review.make docs-impact-check BASE=e3575b993cb56f1930b9ee7825c0d0553410e820passes for the six-file delta;make docs-checkpasses for 363 files.The architecture, measurement-age reference, regression guide and topical Unreleased changelog are updated. No wire fields, dependencies, configuration or release version change.
Scope and limitations
This is a reproduced provider measurement defect. The tests execute the actual measurement owner, bridge event pump, terminal accounting and capacity projection, with an existing scripted engine and synthetic numeric usage. The 121-second boundary uses a synthetic clock; the bridge ordering case captures real timestamps after submission. No fleet incident, live inference, GPU/model, hardware or coordinator routing qualification is claimed.
The full test target compiles and links, but
make provider-testand its general/native GPU lanes are not run under the CPU-only scope. Initial setup failures (a relocated compiler cache and a corrected test-fixture integer type) are retained separately and excluded from the failing-baseline proof.The fix preserves receipt-order averaging, including delayed samples; it does not introduce timestamp-sorted reweighting or sample rejection, change posture-epoch qualification, or revise the separate combined-prefill scalar reset policy. The completed/partial-prefill cancellation work in merged #1233 is distinct. Fresh deduplication of all 89 open PR file lists, 81 all-state search-matched PRs and owner history found no usable equivalent fix, including #1326 and #1354.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.