[TRTLLM-14604][fix] add auth for RL endpoints - #17434
Conversation
Signed-off-by: Erin Ho <14718778+hchings@users.noreply.github.com>
WalkthroughChangesRL control endpoints
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant FastAPI
participant OpenAIServer
participant AsyncLLM
Client->>FastAPI: Send bearer-authenticated RL request
FastAPI->>OpenAIServer: Validate token and request
OpenAIServer->>AsyncLLM: Dispatch collective RPC
AsyncLLM-->>OpenAIServer: Return RPC result
OpenAIServer-->>Client: Return HTTP response
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/unittest/llmapi/test_rl_control_auth.py (1)
70-118: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd invalid-credential and empty-tags tests.
- Test
Authorization: Bearer wrongand{"tags": []}. Assert401or422, respectively, and nocollective_rpcdispatch.- Add
unittest/llmapi/test_rl_control_auth.pytotests/integration/test_lists/test-db/l0_cpu.yml. No currenttest-db/orqa/list includes this file.- Run
pytest tests/unittest/.Coverage remains insufficient for invalid credentials and the
min_length=1constraint.🤖 Prompt for 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. In `@tests/unittest/llmapi/test_rl_control_auth.py` around lines 70 - 118, Extend test_rl_control_routes_require_auth with an invalid-token case using Authorization: Bearer wrong, asserting 401 and no collective_rpc dispatch, and add an empty-tags case for release_memory asserting 422 with no dispatch to cover the min_length=1 constraint. Register tests/unittest/llmapi/test_rl_control_auth.py in tests/integration/test_lists/test-db/l0_cpu.yml, then run pytest tests/unittest/.Sources: Coding guidelines, Path instructions
🤖 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/serve/openai_protocol.py`:
- Line 1382: Update the tags field declaration to use the modern list[str]
annotation instead of List[str], and add a clear description argument to Field
so the generated RL endpoint request schema documents the field’s purpose.
---
Nitpick comments:
In `@tests/unittest/llmapi/test_rl_control_auth.py`:
- Around line 70-118: Extend test_rl_control_routes_require_auth with an
invalid-token case using Authorization: Bearer wrong, asserting 401 and no
collective_rpc dispatch, and add an empty-tags case for release_memory asserting
422 with no dispatch to cover the min_length=1 constraint. Register
tests/unittest/llmapi/test_rl_control_auth.py in
tests/integration/test_lists/test-db/l0_cpu.yml, then run pytest
tests/unittest/.
🪄 Autofix
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: 978eaf53-4115-4bb4-8bc9-4841c4ed1593
📒 Files selected for processing (3)
tensorrt_llm/serve/openai_protocol.pytensorrt_llm/serve/openai_server.pytests/unittest/llmapi/test_rl_control_auth.py
|
|
||
| class MemoryUpdateRequest(OpenAIBaseModel): | ||
| tags: List[str] = Field(default=["model", "kv_cache"]) | ||
| tags: List[str] = Field(min_length=1) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Document and modernize the Pydantic field.
Use list[str] and add a description to Field. This improves the generated request schema for RL endpoint clients.
Proposed fix
- tags: List[str] = Field(min_length=1)
+ tags: list[str] = Field(
+ min_length=1,
+ description="Memory resource tags to release or resume.",
+ )📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| tags: List[str] = Field(min_length=1) | |
| tags: list[str] = Field( | |
| min_length=1, | |
| description="Memory resource tags to release or resume.", | |
| ) |
🤖 Prompt for 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.
In `@tensorrt_llm/serve/openai_protocol.py` at line 1382, Update the tags field
declaration to use the modern list[str] annotation instead of List[str], and add
a clear description argument to Field so the generated RL endpoint request
schema documents the field’s purpose.
Source: Coding guidelines
Dev Engineer Review
rl_control_api_keyandAsyncLLM./release_memory,/resume_memory, and/update_weightsonly when enabled.MemoryUpdateRequest.tagsto require at least one item.OpenAIServercallers and confirm secure handling of missing or invalid bearer tokens.QA Engineer Review
test_rl_control_routes_require_keytest_rl_control_routes_require_async_llmtest_rl_control_routes_disabled_by_defaulttest_rl_control_routes_require_authtest_rl_control_routes_accept_valid_tokentest_release_memory_requires_tagstests/integration/test_lists/.Description
Test Coverage
PR 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.