From a65fc5db145ddca09f06ecfd1b9ed3b647ba702b Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Sat, 22 Aug 2026 10:25:35 -0700 Subject: [PATCH] fix(memory): restore RegisteredMemoryContext::device, broken on main `main` does not compile in the CUDA lane. My own #1725 (ab0880b69) did it, and I am the one who missed it. error[E0599]: no method named `device` found for struct `RegisteredMemoryContext` --> crates/onnx-runtime-ep-cuda/src/provider.rs:1163:30 The deletion was collateral. #1725 rewrote the `use` list in manager.rs to bring in the pin-source types, and `pub fn device` went out with it. Nothing in that PR needed it gone; the underlying `RegisteredProviderContext::device` is untouched, so this restores the forwarder verbatim. Why review and CI both passed it: `onnx-runtime-ep-cuda` is the only caller, and it compiles in exactly one job. Every lane that ran on #1725 was blind to it by construction, and I verified #1725 with `cargo clippy` on the three crates I had edited -- which is precisely the crate set that cannot observe this break. A pub method with no in-crate caller also draws no dead_code warning, so deleting it was silent in both directions. Verified with the lane's own command rather than a proxy: cargo check -p onnx-runtime-ep-cuda -p onnx-runtime-python \ --features onnx-runtime-python/cuda main -> exit 101, the E0599 above fixed -> exit 0 Both reproduced locally on macOS aarch64 with no CUDA toolkit and no GPU, which is worth noting: this was catchable on any developer machine. Also clean: fmt; clippy -D warnings on the governor; 106 governor tests; and the native-cuda clippy lane from #1632. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c80f8522-983c-47f7-8241-2155a823aabe --- crates/onnx-runtime-memory-governor/src/manager.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/onnx-runtime-memory-governor/src/manager.rs b/crates/onnx-runtime-memory-governor/src/manager.rs index ad92d5846d..9ed03f4e4d 100644 --- a/crates/onnx-runtime-memory-governor/src/manager.rs +++ b/crates/onnx-runtime-memory-governor/src/manager.rs @@ -1452,6 +1452,17 @@ impl RegisteredMemoryContext { &self.record.label } + /// The device this context's allocations belong to. + /// + /// Reads through to the registered record rather than caching, so it + /// cannot drift from the registration. Callers live outside this crate — + /// `onnx-runtime-ep-cuda` labels its allocator mechanism with it — and + /// those callers compile only under a backend feature, so nothing in a + /// default build references this. + pub fn device(&self) -> DeviceKey { + self.record.registered.device() + } + /// A pin source that keeps this context from completing teardown. /// /// Handed to mechanisms that queue deferred releases — notably plugin