Repository navigation
Fix graph capture identity after LoRA adapter activation - #2740
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
CUDA parameterizations remain unvalidated, and adapter recapture with recurrent state needs hardware-backed confirmation.
0 open findings
What changed in this PR
Fixes graph-capture identity so activating LoRA adapters does not replay a previously captured base-model path.
Changes:
- Includes adapter revision in capture identity using process-wide IDs, retaining older captures for cleanup.
- Uses actual capture IDs for recurrent-state fixup.
- Adds regression coverage and documents additive activation and KV-cache behavior.
| File | Description |
|---|---|
test/python/test_onnxruntime_genai.py |
Includes the new regression in the regular runner. |
test/python/test_adapter_graph_capture.py |
Tests adapter activation, capture isolation, logits, and unloading. |
src/ort_genai_c.h |
Documents activation and KV-cache semantics. |
src/models/multi_modal.cpp |
Uses actual capture IDs for recurrent-state fixup. |
src/models/model.h |
Replaces local capture-ID storage with the shared allocator. |
src/models/model.cpp |
Allocates adapter-aware capture IDs and releases retained captures. |
src/models/decoder_only.cpp |
Uses actual capture IDs for recurrent-state fixup. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Jiajia Qin (qjia7)
marked this pull request as ready for review
October 16, 2026 03:13
Jiajia Qin (qjia7)
requested review from
Baiju Meswani (baijumeswani) and
kunal-vaishnavi
October 16, 2026 03:14
Baiju Meswani (baijumeswani)
previously approved these changes
Oct 21, 2026
Jiajia Qin (qjia7)
requested review from
Baiju Meswani (baijumeswani) and
kunal-vaishnavi
October 21, 2026 14:40
kunal-vaishnavi
approved these changes
Oct 22, 2026
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.
Activating a LoRA adapter after a generator has captured decode currently reuses the base path's
gpu_graph_id. Graph replay bypasses input processing and kernel selection, so decode can silently ignore the newly activated adapter.This change includes the active-adapter revision in capture identity, alongside input length and execution variant. It reuses the process-wide
GraphAnnotationIdsallocator to prevent collisions between generators sharing a session, retains older captures for cleanup, and uses the actual capture ID for recurrent-state capture fixup. Adapter activation remains additive; it does not recompute earlier KV-cache entries.The new Python regression is included in the regular test runner. It captures the base path, activates A and then A+B on the same generator after rewind, compares full logits with fresh active generators, and verifies a fresh base generator sharing the session. It also checks distinct capture IDs and adapter unloading.
Validation on Windows / NVIDIA RTX 5080:
Related ORT operator and capture coverage: microsoft/onnxruntime#33370. This GenAI fix addresses capture identity independently of that operator implementation.