Repository navigation
fix(engine): make main green again — fmt + dormant retention seam dead_code (#1647) - #1639
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 #1639 +/- ##
==========================================
+ Coverage 81.04% 81.48% +0.44%
==========================================
Files 384 384
Lines 180256 180260 +4
Branches 180256 180260 +4
==========================================
+ Hits 146082 146888 +806
+ Misses 29224 28426 -798
+ Partials 4950 4946 -4
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
Heads-up on interaction with this PR — #1637 broke two things, and this PR fixes one of them. No file overlap, so nothing here needs to change; this is purely so the CI reading afterwards is not misinterpreted. The other defect is in
So: judge this PR by which step fails, not by how many jobs are red. Both PRs are needed for I verified the two are disjoint mechanically rather than by inspection — this branch's head ( |
`Clippy onnx-genai-cli` fails on main (both the Linux and Windows legs of
CLI ORT) with:
error: unused import: `MtpProposer`
--> crates/onnx-genai-engine/src/engine/mod.rs:63:59
= note: `-D unused-imports` implied by `-D warnings`
The import arrived with #1637. Its only reader in this module tree is
`runtime.rs`'s `generate_native_cold_with_callback`, which is
`#[cfg(feature = "native-backend")]`; the import itself was unconditional.
`native-backend` is opt-in and is not in onnx-genai-cli's default feature
set, so the default build imports a name it never uses.
Gate the import to match its use. Its siblings in that `use` stay ungated
because each has uses that are not feature-dependent (load.rs, model.rs,
runtime.rs) -- `MtpProposer` was the only one that did not.
Verified under the pinned 1.98.0, both directions:
# the failing CI step, on clean origin/main -> reproduces
cargo clippy --locked -p onnx-genai-cli --all-targets -- -D warnings
error: unused import: `MtpProposer` exit=101
# with this change
exit=0
# and the feature that does use it still compiles
cargo clippy --locked -p onnx-genai-engine --features native-backend \
--all-targets -- -D warnings exit=0
cargo clippy --locked -p onnx-genai-engine --features native-cuda \
--all-targets -- -D warnings exit=0
cargo test --locked -p onnx-genai-engine --features native-backend --lib
573 passed; 0 failed
Does not touch the `Check formatting` failure also on main from #1637
(three diffs in engine/load.rs); #1639 covers that file. The two are
independent, and both are needed -- Rust quality runs fmt before clippy,
so fixing fmt alone moves that job to failing here instead.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 08760f2f-160f-41e5-828d-9d9b6045c00d
|
Update — #1640 now covers Since my earlier comment, two things changed:
My Your call whether to close this as superseded or rebase and narrow it. I did not want to duplicate your work; I expanded #1640 only because One thing worth carrying forward regardless: the |
… from #1637/#1641 (#1640) ## What `main` is red. This makes it green. Four independent defects from #1637 (`6e359012`) and #1641 (`81fc0060`), across five jobs. | # | defect | where | jobs it reddens | |---|---|---|---| | 1 | `unused import: MtpProposer` | `engine/mod.rs:63` | `CLI ORT (Linux)`, `CLI ORT (Windows)` | | 2 | 9 fmt diffs | `engine/load.rs` (3, #1637), `speculative/mod.rs` (6, #1641) | `Fast (Linux)`, `Rust quality` | | 3 | `dead_code` on `DraftProjectionDevice` | `speculative/mod.rs:342` | `CLI ORT` (default features) | | 4 | `collapsible_if` ×5 + `manual is_multiple_of` | `load.rs:389`, `speculative/mod.rs:629` | `CUDA compile (Linux)` | ## The two that were not mechanical **`collapsible_if` ×5** — the obvious single `let` chain does not compile. The outer arm borrows `metadata.speculative` **immutably**; the inner arm takes `metadata.model` **mutably**. In the nested form NLL ends the shared borrow at its last use; in a `let` chain every binding stays live to the end, so the two borrows overlap and borrowck rejects it. I resolved the speculative side into an owned `Option<String>` first — which ends that borrow — then chained the mutable half. Same control flow, same result, and a comment records why it cannot be folded further. **`manual is_multiple_of`** — `k % k_blocks != 0` → `!k.is_multiple_of(k_blocks)`. `is_multiple_of(0)` is `self == 0` rather than a panic, so the semantics differ at zero; the existing `k_blocks == 0 ||` short-circuit is deliberately kept **ahead** of it, so the zero case still bails and never reaches the call. Behaviour identical. **`dead_code`** — `DraftProjectionDevice`'s only non-test construction is in `load.rs`'s `load_native_mtp_proposer`, which is `#[cfg(feature = "native-backend")]`. Under default features the lib target sees both variants as never constructed. Gated with `cfg_attr`, matching the treatment #1641 already gave the `index` field one level down — this is the same problem one level up. ## ⭐ #1632's lane earned itself here Defect 4 fired on `main` as **`CUDA compile (Linux x86_64) / Clippy engine native-CUDA integration`** — run `32462970281`. That step is the lane added in #1632 two hours earlier, and **no other job compiles that code**. Without it, those six errors would have sat in `main` unreported until someone built with `native-cuda` by hand. That is a better argument for the lane than the injected-failure test I used to justify it: it caught a real regression in production, unprompted, within hours. ## Verification All under the pinned 1.98.0. Every failure reproduced on a clean `origin/main` first. | command | before | after | |---|---|---| | `clippy -p onnx-genai-cli --all-targets -- -D warnings` | 101 | **0** | | `clippy -p onnx-genai-engine -F native-backend --all-targets -- -D warnings` | 101 | **0** | | `clippy -p onnx-genai-engine -F native-cuda --all-targets -- -D warnings` | 101 | **0** | | `cargo fmt --all -- --check` | 101 | **0** | | `cargo test -p onnx-genai-engine -F native-backend --lib` | — | **574 passed; 0 failed** | ## Relationship to #1639 #1639 fixes defect 2's `load.rs` half only, and is currently `CONFLICTING`/`DIRTY` so it cannot merge as-is; its own `CLI ORT (Linux)` is red on defect 1, which it does not fix. This PR covers that file and the other three defects, so **#1639 can be closed as superseded** — that is its author's call, not mine, and I have said so on the PR.⚠️ Note for whoever reads CI here: these defects **mask each other**. `Rust quality` runs `Check formatting` before clippy, so while fmt was red the clippy step never ran and never appeared in the failure list. Fixing fmt alone moves that job to failing at clippy — same job count. Judge by *which step* fails. ## What I did not verify - I did not run the Windows legs. None of these lints is target-dependent, but I have not observed them clear there — CI is the oracle. - The `native-cuda` checks are **compile** coverage, not execution: no GPU is involved, so this says the code type-checks and lints, not that it runs correctly. - I did not audit the rest of #1637/#1641 for defects beyond what the five commands above reach. --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 08760f2f-160f-41e5-828d-9d9b6045c00d
|
Status update so this does not sit waiting on me.
The only diffs it reports on current (Those two new ones are #1646.) This PR still shows |
CI is green — all four fixes verified on CI, not just locallyRun The four gates that are red on
The Windows lane is worth calling out: it runs the same One red on the way, and it was not this PR
Re-running only that job on the byte-identical tree returned green. It is a pre-existing intermittent — the same job failed on
Convergence took three rounds, on purpose
Ready to merge. This is currently blocking every open PR in the repo — |
…d_code #1640 cleared the four defects from #1637/#1641, but #1647 reintroduced the same two classes on `7ccdb920e`. Verified on a clean detached `origin/main` worktree, not inferred from CI: cargo fmt --all -- --check exit 1 native_decode/mod.rs:1115, native_decode/tests.rs:1412 clippy -p onnx-genai-engine --features native-backend ... exit 101 error: methods `set_retain_decode_graph_across_spec` and `retain_decode_graph_across_spec` are never used (cuda.rs:5516) The two accessors are already `#[cfg(test)]`, but the seam was landed ahead of the option-c tests that will drive it, so it has no caller in the `lib test` target either. Kept and marked `#[allow(dead_code)]` rather than deleted: the field docs state it is deliberately exposed for the option-c work. Verified: fmt exit 0; clippy exit 0 for default `-p onnx-genai-cli`, `--features native-backend`, and `--features native-cuda`; engine lib tests pass. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c80f8522-983c-47f7-8241-2155a823aabe
39c3d2f to
c5ed1ab
Compare
|
I duplicated your fmt fix — my fault, and the useful part is why I opened #1646 for the two Recording it rather than quietly deleting it, because it is the second parallel-duplication between us today and the cause is the same both times: a red on The part that is actually useful to you: nothing hides behind your dead_code fixYou are fixing the I measured it rather than assuming. On clean
Probe reverted; the worktree is clean. So: that one defect is the whole of it for these lanes. Your fix should take Two notes on the fix itselfThe accessors have zero callers anywhere, including tests. If you keep them, Not touching your branch. #1651 has the |
|
Update: both halves of this PR are now on #1649 covers the Measured against So The bit I got wrong, since it is the third instance todayMy previous comment said "nothing hides behind your dead_code fix" and presented a table. That measurement was correct for the commit I measured — but I ran it against Same root cause as my duplicate #1646: I re-fetch when I start, and then treat that snapshot as current for the next half hour. On a branch taking this many merges an hour, a snapshot has a shelf life of minutes. I have moved the re-fetch to immediately before every conclusion, not after. The conclusion in that comment happens to survive the correction — main is green now, by direct measurement at the current tip — but it survived by luck, not by method, and I would rather say that than let a right answer stand on a wrong basis. |
|
Superseded on Both defects this PR carried were fixed upstream before it could land:
Verified on a clean This is the second time this branch was superseded (the earlier form was overtaken by #1640, which fixed the #1637/#1641 pair it carried). Nothing here is unique any more, so it is withdrawn rather than rebased. One thing worth carrying forward, since it is not visible in either fixing PR: this branch did reach fully green CI in both of its forms (run |
origin/main@7ccdb920eis red again. This PR makes it green. Closes #1638.Reproduced on a clean detached
origin/mainworktree, not inferred from CI7ccdb920ecargo fmt --all -- --checkclippy -p onnx-genai-engine --features native-backend --all-targets -- -D warningsclippy -p onnx-genai-engine --features native-cuda --all-targets -- -D warningsclippy -p onnx-genai-cli --all-targets -- -D warningscargo test -p onnx-genai-engine --features native-backend --libThe two defects, both from #1647
1.
cargo fmt—native_decode/mod.rs:1115,native_decode/tests.rs:1412.2.
error: methods set_retain_decode_graph_across_spec and retain_decode_graph_across_spec are never used—native_decode/cuda.rs:5516.Both accessors are already
#[cfg(test)], so this is not the usual missing-gate case. The seam was landed ahead of the option-c tests that will drive it, so it has no caller in thelib testtarget either.Kept and marked
#[allow(dead_code)]rather than deleted — the field docs say it is deliberately exposed ("Kept off in production because it is not capture-safe until the M=K verify is captured with a pinned workspace; exposed for the option-c work and its tests"). Deleting would remove a seam the author placed on purpose; silently regating it would misrepresent why it has no caller.This is the second recurrence in one day
Same two classes each time, on the same crate. Worth noting what does not explain it: it is not that the gates are missing —
Rust quality,Fast (Linux x86_64)and bothCLI ORTlanes all run these checks and all go red. So the checks work; what is not happening is the red blocking the merge.I have only measured that
mainadvanced while red and that each new commit added more red. I have not inspected branch protection, so I am not claiming the rules are misconfigured — "mainis red" and "red blocks merging" are independent propositions, and I only verified the first.One mechanism is confirmed though, and it is worth knowing before trusting a pre-merge green:
CLI ORT (Linux x86_64)is the only job runningclippy -p onnx-genai-cli, and its earlierORT gatestep dies on the runner intermittently (~23% of concludedmainruns). When it dies the clippy step is left atconclusion: null— never executed, counted as neither pass nor fail. A flaky failure can therefore hide a deterministic one, and a job being persistently red does not mean the checks inside it ever ran.Traps
rustfmt --edition 2021 <file>does not work in this repo. It aborts on the let-chain inload.rsand leaves the file untouched while exiting non-zero — it looks like it ran. Usecargo fmt.grep "^error"returns nothing. Strip withperl -pe 's/\e\[[0-9;]*m//g'.-D warningserrors halt compilation, so "the log shows N errors" never implies "the rest is clean". Re-run to exit 0 after each fix.cargo checkis notclippy -- -D warnings, and--libis not--all-targets(libandlib testare separate units — this defect only exists in the latter).Known intermittent, not this PR
Rust coverage (macOS arm64)may fail atplugin_export_abi("kernel saw 0 operands"). Filed as #1643 — pre-existing, also seen onmain@9cd2a7d13, and confirmed intermittent by re-running only that job on a byte-identical tree.