Repository navigation
test(provider): wait for warmup retirement before the idle check in the shape warmup retry test - #1581
Conversation
…he shape warmup retry test EngineV2 republishes its capacity gauges at the step boundary after a request's terminal event, so the bridge can retire a finished warmup or calibration request while engine.capacity() still counts it active. The production calibration tests read those gauges immediately and failed intermittently on CI. Poll for the idle engine (10 s bound, explicit failure message) before the idle and decode-row assertions.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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. Coverage: 4/4 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.0000 reported, $0.0000 reserved with unknown cost; 0 paid request(s), 0 reused batch(es), 0 provider cache-hit tokens. Saved findings and earlier report · Historical findings are not confirmed resolved. Bedrock: 1 request(s), 48635 uncached + 0 cache-read + 0 cache-write input / 650 output tokens; 0 request(s) with unknown usage. OpenRouter backup used 0 time(s). Dollar amounts above cover OpenRouter only; AWS billing is reconciled separately. |
|
Refactor pass (required gate): no must-fix changes.
Optional follow-up. |
Summary
ProductionModelCalibrationTests/shapeWarmupRetryResumesAfterFinishedCellsfails intermittently at its idle check,engine.capacity().activeRequests == 0. This blocked provider v0.10.1 release qualification.Root cause.
EngineV2servescapacity()from a gauge snapshot. The engine thread republishes that snapshot only at a step boundary (EngineLoopV2.publishGauges). That happens afterfinishRequesthas handed the request's terminal to the detokenizer queue, and in the idle branch it also waits forreleaseBoundRowsand segment release. Meanwhile the bridge's pump, the calibration cell and the warmup session can all retire.awaitProductionCalibration()can then return while the engine still counts the last warmup request as active. A busy CI runner widens this window.Fix (test-only). A private
requireEngineIdle(_:budget:)helper pollsengine.capacity().activeRequests == 0 && budget.serviceBudget.count == 0every 10 ms for up to 10 s. If the engine never drains, it fails through#requireand reports the active count and service charges. It replaces the immediate idle#expectin the target test and in each sibling test that has the same race. It also runs before any decode-row read, becausedecodeRowsTotalcomes from the same lagging snapshot and could undercount. In the wider-width test it also runs before the baseline row read. The assertions, row bounds and test intent are unchanged.shapeWarmupBudgetIncludesPromptRenderkeeps its immediate check because it submits no request.Before (test flow)
sequenceDiagram autonumber participant T as Test participant B as EngineV2Bridge participant E as EngineV2 thread T->>B: startShapeWarmupIfNeeded / awaitProductionCalibration B->>E: warmup cell requests E-->>B: .finished (detok queue) B-->>T: pump + service charge retired, session ends rect rgb(255, 220, 220) T->>E: capacity().activeRequests (stale snapshot) E-->>T: 1 → Expectation failed (flaky) end E->>E: publishGauges() at step boundary (too late)After (test flow)
sequenceDiagram autonumber participant T as Test participant B as EngineV2Bridge participant E as EngineV2 thread T->>B: startShapeWarmupIfNeeded / awaitProductionCalibration B->>E: warmup cell requests E-->>B: .finished (detok queue) B-->>T: pump + service charge retired, session ends rect rgb(215, 245, 215) loop requireEngineIdle (10 ms poll, 10 s bound) T->>E: capacity().activeRequests, serviceBudget.count end E->>E: publishGauges() → active 0 T->>E: decodeRowsTotal / idle assertions (published snapshot) endEvidence
CI failures (same commit passed on master CI):
.github/actions/provider-release-build)Local validation on a Mac Studio with the Swift 6.4 debug test build, from
provider-swift/:swift build --build-tests.scripts/stage-test-metallib.sh.DARKBLOOM_STATE_FILE,DARKBLOOM_LOADED_MODELS_FILEandDARKBLOOM_VERIFIED_WEIGHTS_FILE, ran../scripts/run-nested-suite.sh 'ProductionModelCalibration' --no-paralleltwice.make docs-impact-check BASE=origin/masterLimitations. The owner asked for speed because this blocks the release, so the planned 20-iteration loop and the before-fix reproduction were skipped. Locally, 80 repetitions of the unmodified test passed: 40 idle and 40 under 40
yesCPU hogs. The race window is too narrow to hit on this 28-core machine. The evidence for the race is the two CI failures plus the SDK code path above.Merge Danger
Two-way door, test-only. One test file changes. There is no production, SDK, protocol or docs change and no changelog fragment. Reverting is a single-file revert.
Refactor pass
The repository's dedicated refactor pass (
AGENTS.md, "Required Refactor Pass") is pending. The coordinating parent session will run it.Need help on this PR? Tag
@codesmith-botwith what you need.