Skip to content

[TRTLLM-11318][feat] move VisualGen APIs to a separate dir#12538

Open
zhenhuaw-me wants to merge 1 commit intoNVIDIA:mainfrom
zhenhuaw-me:move-visualgen-apis
Open

[TRTLLM-11318][feat] move VisualGen APIs to a separate dir#12538
zhenhuaw-me wants to merge 1 commit intoNVIDIA:mainfrom
zhenhuaw-me:move-visualgen-apis

Conversation

@zhenhuaw-me
Copy link
Member

@zhenhuaw-me zhenhuaw-me commented Mar 25, 2026

Summary by CodeRabbit

  • Refactor

    • Visual Generation API has been reorganized into a dedicated module at tensorrt_llm.visual_gen. Users importing from the top-level tensorrt_llm package are unaffected.
  • Chores

    • Added license headers and updated code ownership assignments.

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)

  • 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.

Signed-off-by: Zhenhua Wang <zhenhuaw@nvidia.com>
@zhenhuaw-me
Copy link
Member Author

/bot run

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 25, 2026

📝 Walkthrough

Walkthrough

This pull request relocates the VisualGen and VisualGenParams classes from tensorrt_llm/llmapi/visual_gen to a new standalone tensorrt_llm/visual_gen package. All import statements throughout the codebase, top-level exports, documentation, and configuration have been updated to reflect the new module location.

Changes

Cohort / File(s) Summary
Module Exports
tensorrt_llm/__init__.py, tensorrt_llm/llmapi/__init__.py, tensorrt_llm/visual_gen/__init__.py
Removed VisualGen and VisualGenParams exports from llmapi; added new visual_gen/__init__.py to expose these classes and MediaOutput from the new package location; updated top-level tensorrt_llm exports to import from visual_gen instead of llmapi.
Import Updates
tensorrt_llm/bench/benchmark/visual_gen.py, tensorrt_llm/serve/openai_server.py, tensorrt_llm/serve/visual_gen_utils.py, tests/unittest/_torch/visual_gen/test_visual_gen_args.py
Updated imports to reference VisualGen and VisualGenParams from tensorrt_llm.visual_gen instead of tensorrt_llm.llmapi.visual_gen.
Configuration & Documentation
.github/CODEOWNERS, docs/source/models/visual-generation.md, tensorrt_llm/visual_gen/visual_gen.py
Added CODEOWNERS entry assigning /tensorrt_llm/visual_gen to the LLM API development team; updated documentation to reflect new module path; added Apache-2.0 license header to visual_gen.py.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The PR description is incomplete—it contains only the template with empty placeholder sections and no actual implementation details, rationale, or test coverage information. Fill in the Description section explaining why VisualGen APIs were moved and the benefits. Provide specific test coverage details and verify all checklist items are addressed.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: moving VisualGen APIs to a separate directory, matching the actual refactoring across multiple files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tensorrt_llm/__init__.py`:
- Line 136: The file header year was not updated when this file was modified;
open the module that exports VisualGen and VisualGenParams (the top of
tensorrt_llm/__init__.py where VisualGen, VisualGenParams are imported) and
update the copyright header year range (replace 2024 with the current year) to
reflect the modification year.

In `@tensorrt_llm/serve/openai_server.py`:
- Line 40: Replace direct class/function imports with module-level imports and
update all usages to reference the module namespace: change "from
tensorrt_llm.llmapi import MultimodalEncoder, tracing" to "import
tensorrt_llm.llmapi as llmapi" and update references to llmapi.MultimodalEncoder
and llmapi.tracing.extract_trace_headers(...); similarly import the visual_gen
module (e.g., "import tensorrt_llm.visual_gen as visual_gen") and replace
VisualGen and VisualGenParams usages with visual_gen.VisualGen and
visual_gen.VisualGenParams so all symbols are accessed through their module
namespaces.

In `@tensorrt_llm/serve/visual_gen_utils.py`:
- Line 12: This file (tensorrt_llm/serve/visual_gen_utils.py) is missing the
required NVIDIA Apache/SPDX header; add the standard NVIDIA Apache 2.0 header
block (including SPDX-License-Identifier: Apache-2.0 and the copyright notice
with the year of the latest meaningful modification) at the top of the file
above the existing imports (e.g., above the line importing VisualGenParams),
ensuring the header format matches other TensorRT-LLM source files.

In `@tensorrt_llm/visual_gen/__init__.py`:
- Line 17: The __all__ export list in __init__.py is not sorted in isort-style
order; update the module-level __all__ to an alphabetically sorted list of the
exported names (VisualGen, VisualGenParams, MediaOutput) so it satisfies Ruff
RUF022 — locate the __all__ declaration in tensorrt_llm.visual_gen.__init__ and
reorder the entries into isort-style alphabetical order.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f025dcb3-6d47-4ad3-850f-cd14ee11a2f6

📥 Commits

Reviewing files that changed from the base of the PR and between 2b5c434 and 28bbad5.

📒 Files selected for processing (10)
  • .github/CODEOWNERS
  • docs/source/models/visual-generation.md
  • tensorrt_llm/__init__.py
  • tensorrt_llm/bench/benchmark/visual_gen.py
  • tensorrt_llm/llmapi/__init__.py
  • tensorrt_llm/serve/openai_server.py
  • tensorrt_llm/serve/visual_gen_utils.py
  • tensorrt_llm/visual_gen/__init__.py
  • tensorrt_llm/visual_gen/visual_gen.py
  • tests/unittest/_torch/visual_gen/test_visual_gen_args.py
💤 Files with no reviewable changes (1)
  • tensorrt_llm/llmapi/init.py

from .python_plugin import PluginBase
from .sampling_params import SamplingParams
from .version import __version__
from .visual_gen import VisualGen, VisualGenParams
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Update the copyright year on this modified file.

The file changed in this PR (Line 136), but the header at Line 1 still ends at 2024.

📝 Proposed fix
-# SPDX-FileCopyrightText: Copyright (c) 2022-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-FileCopyrightText: Copyright (c) 2022-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
As per coding guidelines, "Add NVIDIA copyright header on ALL new files, and update year on modified files".
📝 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.

Suggested change
from .visual_gen import VisualGen, VisualGenParams
# SPDX-FileCopyrightText: Copyright (c) 2022-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tensorrt_llm/__init__.py` at line 136, The file header year was not updated
when this file was modified; open the module that exports VisualGen and
VisualGenParams (the top of tensorrt_llm/__init__.py where VisualGen,
VisualGenParams are imported) and update the copyright header year range
(replace 2024 with the current year) to reflect the modification year.

from tensorrt_llm.llmapi import DisaggregatedParams as LlmDisaggregatedParams
from tensorrt_llm.llmapi import (MultimodalEncoder, VisualGen, VisualGenParams,
tracing)
from tensorrt_llm.llmapi import MultimodalEncoder, tracing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Use module-level imports instead of importing classes directly.

Line 40 and Line 89 import symbols directly from packages, which conflicts with the repo’s namespace-import rule. Please import modules and reference symbols through module namespaces.

Proposed direction
-from tensorrt_llm.llmapi import MultimodalEncoder, tracing
+from tensorrt_llm import llmapi
...
-from tensorrt_llm.visual_gen import VisualGen, VisualGenParams
+from tensorrt_llm import visual_gen

Then update usages, e.g.:

  • MultimodalEncoderllmapi.MultimodalEncoder
  • tracing.extract_trace_headers(...)llmapi.tracing.extract_trace_headers(...)
  • VisualGen / VisualGenParamsvisual_gen.VisualGen / visual_gen.VisualGenParams

As per coding guidelines, "When importing in Python, always maintain the namespace. Import the module, not individual classes or functions..."

Also applies to: 89-89

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tensorrt_llm/serve/openai_server.py` at line 40, Replace direct
class/function imports with module-level imports and update all usages to
reference the module namespace: change "from tensorrt_llm.llmapi import
MultimodalEncoder, tracing" to "import tensorrt_llm.llmapi as llmapi" and update
references to llmapi.MultimodalEncoder and
llmapi.tracing.extract_trace_headers(...); similarly import the visual_gen
module (e.g., "import tensorrt_llm.visual_gen as visual_gen") and replace
VisualGen and VisualGenParams usages with visual_gen.VisualGen and
visual_gen.VisualGenParams so all symbols are accessed through their module
namespaces.

ImageGenerationRequest,
VideoGenerationRequest,
)
from tensorrt_llm.visual_gen import VisualGenParams
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add the required NVIDIA Apache header to this modified Python file.

This file is modified in this PR (Line 12) but lacks the required SPDX/Apache header block.

📝 Proposed fix
+ # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+ # SPDX-License-Identifier: Apache-2.0
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License");
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+
  import asyncio
  import base64
  import os
As per coding guidelines, "All TensorRT-LLM source files should contain an NVIDIA copyright header with the year of the latest meaningful modification."
📝 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.

Suggested change
from tensorrt_llm.visual_gen import VisualGenParams
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import asyncio
import base64
import os
from tensorrt_llm.visual_gen import VisualGenParams
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tensorrt_llm/serve/visual_gen_utils.py` at line 12, This file
(tensorrt_llm/serve/visual_gen_utils.py) is missing the required NVIDIA
Apache/SPDX header; add the standard NVIDIA Apache 2.0 header block (including
SPDX-License-Identifier: Apache-2.0 and the copyright notice with the year of
the latest meaningful modification) at the top of the file above the existing
imports (e.g., above the line importing VisualGenParams), ensuring the header
format matches other TensorRT-LLM source files.

# limitations under the License.
from .visual_gen import MediaOutput, VisualGen, VisualGenParams

__all__ = ["VisualGen", "VisualGenParams", "MediaOutput"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Sort __all__ to satisfy Ruff RUF022.

__all__ at Line 17 is not sorted in isort-style order.

🔧 Proposed fix
-__all__ = ["VisualGen", "VisualGenParams", "MediaOutput"]
+__all__ = ["MediaOutput", "VisualGen", "VisualGenParams"]
📝 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.

Suggested change
__all__ = ["VisualGen", "VisualGenParams", "MediaOutput"]
__all__ = ["MediaOutput", "VisualGen", "VisualGenParams"]
🧰 Tools
🪛 Ruff (0.15.6)

[warning] 17-17: __all__ is not sorted

Apply an isort-style sorting to __all__

(RUF022)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tensorrt_llm/visual_gen/__init__.py` at line 17, The __all__ export list in
__init__.py is not sorted in isort-style order; update the module-level __all__
to an alphabetically sorted list of the exported names (VisualGen,
VisualGenParams, MediaOutput) so it satisfies Ruff RUF022 — locate the __all__
declaration in tensorrt_llm.visual_gen.__init__ and reorder the entries into
isort-style alphabetical order.

@tensorrt-cicd
Copy link
Collaborator

PR_Github #40319 [ run ] triggered by Bot. Commit: 28bbad5 Link to invocation

@tensorrt-cicd
Copy link
Collaborator

PR_Github #40319 [ run ] completed with state SUCCESS. Commit: 28bbad5
/LLM/main/L0_MergeRequest_PR pipeline #31429 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants