Repository navigation
fix(server): compile the native-backend session test against the lease API - #2114
justinchuby wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2114 +/- ##
==========================================
+ Coverage 80.30% 80.47% +0.17%
==========================================
Files 426 413 -13
Lines 205244 195882 -9362
Branches 205244 195882 -9362
==========================================
- Hits 164811 157631 -7180
+ Misses 34781 32721 -2060
+ Partials 5652 5530 -122
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
…e API `Rust quality / Check the native backend compiles` is red on main. `native_driver_sessions_generate_through_server_path` still passes a `SessionPlacement` where `generate` and `close_session` now take a `SessionLeaseGuard` (c8732ee, refined by 5b5eec2), so `cargo clippy --all-targets ... --features native-backend` fails to compile the lib test and every PR fails a required check. The test is `#[cfg(feature = "native-backend")]`, so the default-feature lanes never compiled it and the signature change went in green. Same shape as the mistake we have been catching in benchmarks all week -- the arm was not on the route we named -- except in a test, where a passing check is evidence of nothing having been built. Fixed the way the other driver tests do it: acquire a lease from `SessionLeases`, hand it to `generate` (which consumes it and releases it when the turn ends), and take a second lease to close with. The re-acquire is not ceremony: it fails if a finished turn ever leaves a session leased, which is the property the lease API was added for. `cargo test -p onnx-genai-server --features native-backend --lib native_driver_sessions` passes, and the exact CI command -- `cargo clippy --locked --all-targets -p onnx-genai-engine -p onnx-genai-server --features onnx-genai-engine/native-backend, onnx-genai-server/native-backend -- -D warnings` -- is clean. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
69ec641 to
a4d55df
Compare
|
Review: this fix compiles, but the second Both this and #2115 fix the same defect (#2056 changed let lease = leases
.acquire(driver.binding(session), "sess-native")
.expect("the finished turn released its lease");The comment on that
if let Some(mut route) = routes.remove(&handle.id) {
route.metrics.result(...);
let _ = deliver_driver_event(&route.events, DriverEvent::Finished(result), DELIVERY_GRACE);
} // <-- `route` drops HERE, and `_lease` with it
Receiving the result therefore implies the release is imminent, not done. There is no happens-before edge between the two, and the window is exactly the kind that widens on a loaded 2-core runner — so this fails rarely, on someone else's PR, in a lane nobody suspects. That is the expensive failure mode, not the loud one. The first Two ways forward, either is fine by me:
I have no preference between the two authors' styles — only that Verified statically only: I did not compile |
|
Caught, and the finding is the one that mattered: the commit fixed the clippy step and broke the formatting step of the same required job, so That is a sharper version of the same lesson this PR is about: I validated the step I knew was failing and did not re-run the whole gate. Verifying the specific thing you broke is not the same as verifying the gate, exactly as compiling on the default feature set is not the same as compiling the test you are citing. On the flake question — thank you for tracing it to the code rather than reasoning about it. Also useful that you checked priority 5 categorically — the other Re-verified after the amend: clippy |
|
Superseded by #2115, which waits for DriverRoute to release the turn lease before reacquiring it and has passed native-backend validation. |
|
Correction to my review, with measurements. The race is real but I described the wrong widener, and I could not reproduce it in 120 runs. I said the window "widens on a loaded 2-core runner". I went and measured instead of leaving that as an assertion, and it does not hold. Recording it because #2114 was closed partly on my say-so. What I ran. Built the test CI never runs (see below), then reverted the poll to #2114's single-shot
Why my mechanism was wrong. Single-CPU binding makes failure less likely, not more: the driver thread runs to the end of the The real widener is a full output channel, and it is much bigger than I claimed. let mut pending = match events.try_send(event) { Ok(()) => return Ok(()), ... };
let deadline = Instant::now() + grace;
loop {
if Instant::now() >= deadline { return Err(DriverDeliveryError::Stalled); }
thread::sleep(DELIVERY_RETRY_INTERVAL);
...
}The So the corrected verdict: the ordering hazard I described is real and the poll is still the right code — but the reachability argument I gave for it was wrong, and a reader of my review would have gone looking for the flake on a busy runner and not found it. A test with a slower consumer or a longer generation is where a single-shot The finding that outlasts this. While setting the experiment up I checked what CI does with this test: No lane runs Same family as #2058: a code path exactly one step can see. I will open this separately rather than bury it in a merged PR thread. Everything above was run under |
Main is red on the required check
Rust quality— step "Check the native backend compiles" — and has been since the session-lease change landed. Every open PR fails it, including mine; that is how I found it.What broke
native_driver_sessions_generate_through_server_path(crates/onnx-genai-server/src/tests.rs) still passes aSessionPlacementtogenerateandclose_session, which now take aSessionLeaseGuard(c8732ee69, refined by5b5eec2ca). Reproduced locally with the exact CI command:Why it landed green
The test is
#[cfg(feature = "native-backend")]. No default-feature lane compiles it, so the signature change was green everywhere that ran, and the one job that does compile it is the one now failing on main for everybody.This is the same failure mode we have spent the week catching in benchmarks — the arm was not on the route we named — except in a test, where it is worse: a benchmark on the wrong route gives you a number you will eventually distrust; a test that is not compiled on the leg you are citing gives you a green check that you will not. I am not touching CI scope here; that is the CI lane's call, and the gate did catch this, just after the merge rather than before it.
The fix
The way the other driver tests do it (
driver.rs:2224,:2334): acquire a lease fromSessionLeases, hand it togenerate— which consumes it and releases it when the turn ends — and take a second lease to close with.The re-acquire is not ceremony. It fails if a finished turn ever leaves a session leased, which is the property the lease API exists to provide, so the repaired test now asserts slightly more than the one it replaces.
Validation
cargo clippy --locked --all-targets -p onnx-genai-engine -p onnx-genai-server --features onnx-genai-engine/native-backend,onnx-genai-server/native-backend -- -D warnings— clean (the exact CI step,ci.yml:613).cargo test -p onnx-genai-server --features native-backend --lib native_driver_sessions— 1 passed, and it really ran (test tests::native_driver_sessions_generate_through_server_path ... ok), which is the check this PR is about.Test-only change; no production code touched. Merging normally via
merge_when_green.shonce required checks are green — no--admin, no ruleset bypass.