[None][fix] Make LlmRequest.is_generation_only_request a property to match the C++ binding - #18858
Conversation
…match the C++ binding The C++ base binds the flag as a read-only property (`nanobind/batch_manager/bindings.cpp:221`), while the Python subclass overrode the same name with a plain method. One name, two spellings, and which one is correct depends on the object in hand: the base class needs `req.is_generation_only_request`, the subclass needed `req.is_generation_only_request()`. Both objects reach Python. The connector trampoline (`nanobind/batch_manager/kvCacheConnector.cpp:36`) takes `LlmRequest const&`, which nanobind casts by copy, so a callback invoked from C++ receives a base-class instance; every other caller holds the Python subclass. A guard that reads the attribute on the subclass gets a bound method -- always truthy, never raising, never logged -- and takes the generation-only branch for every request. Add `@property` to the subclass so it matches the base, and convert the eight in-tree callers plus the test fakes. No behaviour changes: every current caller already used the spelling that reads correctly for the object it holds. Signed-off-by: Yueh-Ting Chen <yuehtingc@nvidia.com>
|
/bot run --disable-fail-fast |
|
PR_Github #72028 [ run ] triggered by Bot. Commit: |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (16)
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review. WalkthroughThe change exposes ChangesGeneration-only request property
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to Generation-only classification now uses a boolean property, so context requests reach connector scheduling while generation-only requests are rejected as intended. The updated callers and regression coverage indicate no remaining merge-blocking risk. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
zhaoyangwang-nvidia
left a comment
There was a problem hiding this comment.
This is exactly the follow-up split we discussed on #18762 — scoped to just the property/method mismatch, all eight in-tree callers converted consistently, and the new test constructs a real LlmRequest via executor_request_to_llm_request and exercises both the context and generation-only paths through the real connector manager, which pins down the base-class vs. subclass attribute-access bug this fixes. LGTM.
|
PR_Github #72028 [ run ] completed with state
|
|
/bot skip --comment "The change of the current MR should be covered by the single-GPU pipeline. It is safe to skip the multi-GPU pipeline." |
|
PR_Github #72098 [ skip ] triggered by Bot. Commit: |
|
PR_Github #72098 [ skip ] completed with state |
Description
Two objects reach Python as
LlmRequest: the C++ base, which the KV connector trampoline hands to a connector implementation, and the Python subclass, which every other caller holds. The base bindsis_generation_only_requestas a read-only property; the subclass overrode it with a plain method.What this means for an API user:
request.is_generation_only_requestis now aboolon everyLlmRequestyou can be handed. Before, on the subclass it evaluated to a bound method — always truthy — so any guard reading it treated EVERY request as generation-only. Nothing raised and nothing logged.The fix is
@propertyon the subclass, plus the eight in-tree callers and the test doubles moved off(). No in-tree behaviour change: each existing caller already used the spelling that reads correctly for the object it holds.Test Coverage
tests/unittest/_torch/executor/test_kv_connector_generation_only.py— builds a realLlmRequestof each request type and drives it throughKvCacheConnectorManager.get_num_new_matched_tokens. No test-list change:unittest/_torch/executoris already an entry inl0_cpu.ymland the file iscpu_only.How the change is guaranteed — the test run against an installed
tensorrt_llminnvcr.io/nvidia/pytorch:26.05-py3, toggling only the@propertyline and nothing else:tests/unittest/_torch/executor/test_kv_connector_generation_only.py:53Truethrough the subclass?tests/unittest/_torch/executor/test_request_utils.py:104tests/unittest/_torch/executor/test_pytorch_model_engine.py:475tests/unittest/_torch/speculative/hw_agnostic/test_sa.py:319tests/unittest/disaggregated/test_cache_reuse_adapter.py:493PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
If PR introduces API changes, an appropriate PR label is added - either
api-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title.Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.