[None][feat] Add PyTorch reset_prefix_cache API#15313
Conversation
Signed-off-by: milesial <milesial@users.noreply.github.com>
c9a58d5 to
4a3554b
Compare
|
/bot run |
|
PR_Github #53931 [ run ] triggered by Bot. Commit: |
|
PR_Github #53931 [ run ] completed with state
|
|
/bot run |
|
PR_Github #53969 [ run ] triggered by Bot. Commit: |
|
PR_Github #53969 [ run ] completed with state
|
|
/bot run |
📝 WalkthroughWalkthroughAdds Changesreset_prefix_cache feature and RL endpoint refactor
Sequence Diagram(s)sequenceDiagram
participant Client
participant OpenAIServer
participant _TorchLLM
participant BaseWorker
participant PyExecutor
Client->>OpenAIServer: POST /reset_prefix_cache
OpenAIServer->>_TorchLLM: reset_prefix_cache()
_TorchLLM->>_TorchLLM: validate encode_only / executor present
alt collective RPC supported
_TorchLLM->>BaseWorker: _collective_rpc("reset_prefix_cache")
else
_TorchLLM->>BaseWorker: executor.reset_prefix_cache()
end
BaseWorker->>PyExecutor: engine.control_action(reset_prefix_cache)
PyExecutor->>PyExecutor: raise RuntimeError if active or queued requests
PyExecutor-->>BaseWorker: kv_cache_manager.reset_reuse_state()
BaseWorker-->>OpenAIServer: success
OpenAIServer-->>Client: {"status": "success"}
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tensorrt_llm/_torch/pyexecutor/py_executor.py`:
- Around line 5240-5243: The guard condition in reset_prefix_cache() method only
checks active_requests and waiting_queue but misses requests that may be pending
in executor_request_queue or request_accumulated. Extend the RuntimeError
condition to also verify that executor_request_queue and request_accumulated are
empty, ensuring the precondition truly enforces that no queued work exists
before allowing the kv_cache_manager.reset_reuse_state() call to proceed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: a0779ce2-f81f-47d7-b3ce-336288610ad6
📒 Files selected for processing (9)
tensorrt_llm/_torch/pyexecutor/py_executor.pytensorrt_llm/executor/base_worker.pytensorrt_llm/llmapi/llm.pytensorrt_llm/llmapi/rlhf_utils.pytensorrt_llm/serve/openai_server.pytests/unittest/_torch/executor/test_py_executor.pytests/unittest/_torch/ray_orchestrator/single_gpu/test_llm_update_weights.pytests/unittest/api_stability/references/llm.yamltests/unittest/llmapi/test_llm.py
💤 Files with no reviewable changes (1)
- tensorrt_llm/llmapi/rlhf_utils.py
|
/bot run |
|
PR_Github #55336 [ run ] triggered by Bot. Commit: |
|
PR_Github #55336 [ run ] completed with state
|
|
/bot run |
1 similar comment
|
/bot run |
|
/bot run |
|
PR_Github #55591 [ run ] triggered by Bot. Commit: |
|
PR_Github #55591 [ run ] completed with state
|
|
/bot run |
|
PR_Github #55621 [ run ] triggered by Bot. Commit: |
|
PR_Github #55621 [ run ] completed with state
|
Description
This relands #14970 after CI fixes for the RLHF Ray worker extension conflict.
Following vLLM
reset_prefix_cacheand SGLangflush_cache, add a python API + HTTP endpoint to reset the local KV cache state.This is useful during benchmarking to reset the state between runs in a concurrency sweep for example.
Test Coverage
Added unit tests to
tests/unittest/llmapi/test_llm.pyPR 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.
Summary by CodeRabbit
Release Notes
New Features
reset_prefix_cache()method to LLM API for invalidating local KV cache prefix-reuse state in PyTorch backend./reset_prefix_cachePOST endpoint to OpenAI server.Improvements