Repository navigation
Conversation
Implement six synchronous device cache operations with retained storage, checked allocation geometry, explicit errors and plugin-only registration. Verify CPU and CUDA regressions, 137/137 new host lines, and sanitizer-clean standalone C/C++ device lifecycles. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Document PR #20 and completed implementation, CPU/CUDA validation, 137/137 host coverage and sanitizer gates. Keep M08b unimplemented pending user authorization. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Nov 10, 2026
Replace repository, PR and branch references with this upstream draft stack. Integrate the predecessor's documentation-only cleanup without rebasing or changing executable code. Existing implementation commits remain intact. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Upstream draft stack 10/21. Original milestone: M08a.
stateful-M10-cuda-plugin-kv-cacheat30798bfccfc711ff3d49a6d55d647d2ce8476108stateful-M09-plugin-stateful-hooksat30d855b9d1cabf430f4a233e9656e7c6c1ef1e3fThe
[Stateful - MNN]title/branch numbers identify positions in this 21-PR stack, not original milestone numbering. M16-M23 language-binding milestones remain deferred.Historical review base:
1988019b6e23ac4def4628cddd603c1bfb504fe8, preserved asstate/stateful-base-1988019b. The first PR targets that historical review anchor; each later PR targets its predecessor. These PRs have not been rebased onto currentmain. The anchor is for incremental review; integration/retargeting requires a later explicit decision.Validation provenance: Recorded milestone validation below is retained. The appended reference-cleanup/merge commits change Markdown references only; executable files are byte-for-byte unchanged. No new build/test or current-main qualification is claimed. Historical commits are preserved, while current documentation and PR links use this Microsoft draft stack. Upstream CI results are separate.
M08a, stacked on #34048 (
stateful-M09-plugin-stateful-hooks). This milestone implements the CUDA plugin EP cache backend only; M08b loop/chain device integration is not included or authorized yet.retain_valuerequest callback instead of importing native Session types into the plugin. Public API tables andORT_API_VERSIONremain unchanged.The approved specification, milestone checklist, exact evidence and public SDK example are in SPEC.md, TASKS.md and SCRATCHPAD.md.
Validation
Linux/A100 SM80, matching CUDA 13.1/cuDNN; GPU runs expose devices 0 and 1. All reported suites have nonzero counts and zero skips/exclusions.
./onnxruntime_session_loop_test --gtest_output=xml:coverage/m08a/verified/native-tests.xml./onnxruntime_autoep_test --gtest_output=xml:coverage/m08a/verified/autoep-tests.xml./onnxruntime_session_loop_test --gtest_output=xml:coverage/m08a/complete/native-tests.xml./onnxruntime_autoep_test --gtest_output=xml:coverage/m08a/complete/autoep-tests.xml./onnxruntime_autoep_test --gtest_filter='AutoEpSelection.CudaEP:*Stateful*' --gtest_output=xml:coverage/m08a/legacy-stateful-tests.xmlORT_NOT_IMPLEMENTEDThe separate instrumented plugin target built successfully with:
Clang18 host LLVM instrumentation is combined with supported NVCC13.1/GCC13. The existing nonfatal-warning build option accommodates stock mixed-compiler/pool/Cast diagnostics; no unrelated CUDA implementation was patched to silence them. New callback/device-test sources independently pass strict warning-as-error type checking.
Actual-plugin new executable host/glue coverage: 137/137 (100%):
Fresh passing profiles were merged with
llvm-profdata merge -sparse coverage/m08a/complete/*.profraw -o coverage/m08a/complete/m08a.profdata; module-specific LLVM line exports were intersected with added source locations against M07b03d7476859. LLVM diagnostics were exclusively dormant zero-hash maps, with no new-function mismatch.New device functions/lines: 0/0, N/A, not a claimed 100% device-coverage result. No kernels were added; the backend uses existing CUDA runtime copy APIs.
Compute Sanitizer commands, using CUDA 13.1's binary, all passed with zero errors and zero leaked bytes/allocations:
The documented C++17 CUDA SDK example also passed normal execution and memcheck through reset, backend-Session release and library unregistration. Its separate caller-owned allocator Session remains alive as required by the existing allocator API; final DLL unload while that caller resource is alive is not claimed. Genuine C11 compilation/execution, the CPU C++17 example with normal/no-exceptions client flags, formatting, 120-column limits, whitespace and all 93-requirement/24-milestone mappings passed.
Motivation and Context
Provide the first real device-resident KV implementation through M07's plugin dispatch contract, without changing stateless Session behavior or claiming GPU-native sampling. The tests prove actual GPU allocation/copy/retention rather than merely CUDA model registration, including completion before readback can hide a race and precise rejection of null-allocation/overflow failures before CUDA copies.
M08 remains incomplete until M08b is separately authorized and wires device-resident caches through loops/chains. This PR is independently reviewable and ready for human review; it does not merge its predecessors.