Skip to content

Conversation

yibinl-nvidia
Copy link
Collaborator

@yibinl-nvidia yibinl-nvidia commented Jul 30, 2025

Summary by CodeRabbit

  • New Features
    • Added support for a new "eclair" model type, integrating a RADIO vision encoder with an MBart decoder.
    • Introduced a command-line flag (--eclair_radio) to enable the new model variant.
    • Enhanced the multimodal engine builder to support "eclair" models, including ONNX export and TensorRT engine creation.
  • Bug Fixes
    • Improved vocabulary size alignment for language model heads to support tensor parallelism.
  • Chores
    • Added "timm" as a new dependency for multimodal model support.

Description

Cherry-pick changes from #5686.

Test Coverage

GitHub Bot Help

/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...

Provide a user friendly way for developers to interact with a Jenkins server.

Run /bot [-h|--help] to print this help message.

See details below for each supported subcommand.

run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental)]

Launch build/test pipelines. All previously running jobs will be killed.

--reuse-test (optional)pipeline-id (OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.

--disable-reuse-test (OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.

--disable-fail-fast (OPTIONAL) : Disable fail fast on build/tests/infra failures.

--skip-test (OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.

--stage-list "A10-PyTorch-1, xxx" (OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.

--gpu-type "A30, H100_PCIe" (OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.

--test-backend "pytorch, cpp" (OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.

--only-multi-gpu-test (OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.

--disable-multi-gpu-test (OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.

--add-multi-gpu-test (OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.

--post-merge (OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.

--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" (OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".

--detailed-log (OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.

--debug (OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in the stage-list parameter to access the appropriate container environment. Note: Does NOT update GitHub check status.

For guidance on mapping tests to stage names, see docs/source/reference/ci-overview.md
and the scripts/test_to_stage_mapping.py helper.

kill

kill

Kill all running builds associated with pull request.

skip

skip --comment COMMENT

Skip testing for latest commit on pull request. --comment "Reason for skipping build/test" is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

reuse-pipeline

reuse-pipeline

Reuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

Copy link
Contributor

coderabbitai bot commented Jul 30, 2025

📝 Walkthrough

Walkthrough

The changes introduce support for a new "eclair" model variant, integrating a RADIO vision encoder with an MBart decoder. This includes new command-line flags, model configuration and weight conversion logic, model loading and initialization routines, and engine building processes. Additional dependencies and utility imports are added to support the new model.

Changes

Cohort / File(s) Change Summary
Eclair Model Support in Checkpoint Conversion
examples/models/core/enc_dec/convert_checkpoint.py
Adds --eclair_radio flag and logic to handle a new model variant combining a RADIO vision encoder with an MBart decoder. Modifies config parsing, weight conversion (including vocab padding), model instantiation, and checkpoint loading to accommodate the new pathway.
Eclair Model Engine Building
tensorrt_llm/tools/multimodal_builder.py
Adds "eclair" to the --model_type argument. Implements build_eclair_engine for building the eclair model engine, including a custom RadioWithNeck module, model/processor setup, ONNX export, and TensorRT engine creation. Updates engine builder logic to support the new model type.
Vocabulary Padding in Decoder Model
tensorrt_llm/models/enc_dec/model.py
Imports pad_vocab_size and applies it to pad the decoder's vocabulary size for the language model head in pipeline parallelism scenarios. Removes redundant default setting for residual_scaling.
Dependency Update for Eclair Model
examples/models/core/multimodal/requirements-eclair.txt
Adds the timm package as a new dependency required for the eclair model.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant CheckpointConverter
    participant EngineBuilder
    participant RadioWithNeck
    participant VisionEncoderDecoderModel
    participant Processor

    User->>CLI: Run with --eclair_radio or --model_type eclair
    CLI->>CheckpointConverter: Parse args, detect eclair_radio
    CheckpointConverter->>CheckpointConverter: Parse config, adjust for eclair_radio
    CheckpointConverter->>CheckpointConverter: Pad vocab, adjust weights
    CheckpointConverter->>RadioWithNeck: Instantiate vision encoder
    CheckpointConverter->>VisionEncoderDecoderModel: Initialize decoder
    CheckpointConverter->>Processor: Setup processor, extend tokenizer
    CheckpointConverter->>VisionEncoderDecoderModel: Load weights, adjust embeddings
    CLI->>EngineBuilder: Build engine with model_type eclair
    EngineBuilder->>build_eclair_engine: Call build_eclair_engine(args)
    build_eclair_engine->>RadioWithNeck: Load and wrap RADIO model
    build_eclair_engine->>VisionEncoderDecoderModel: Replace encoder, adjust decoder
    build_eclair_engine->>Processor: Load processor, resize embeddings
    build_eclair_engine->>EngineBuilder: Export ONNX, build TensorRT engine
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

  • chzblych

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@yibinl-nvidia yibinl-nvidia changed the title Cherry-pick changes from [feat] add support for Eclairv2 model [feat] add support for Eclairv2 model - cherry-pick changes Jul 30, 2025
@yibinl-nvidia yibinl-nvidia self-assigned this Jul 30, 2025
@yibinl-nvidia
Copy link
Collaborator Author

yibinl-nvidia commented Jul 30, 2025

/bot run

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: 2

🧹 Nitpick comments (5)
examples/models/core/multimodal/requirements-eclair.txt (1)

1-1: Consider pinning the timm version for reproducibility.

While the timm dependency is appropriate for the RADIO vision encoder, consider specifying a version to ensure reproducible builds and avoid potential compatibility issues.

-timm
+timm>=0.9.0,<1.0.0
tensorrt_llm/tools/multimodal_builder.py (2)

35-46: Consider maintaining alphabetical order in model type choices.

The new "eclair" model type should be placed between "cogvlm" and "fuyu" to maintain alphabetical ordering consistency.

        choices=[
            'blip2', 'llava', 'llava_next', 'llava_onevision',
            'llava_onevision_lmms', 'vila', 'nougat', 'cogvlm', 'fuyu',
            'pix2struct', 'neva', 'kosmos-2', 'video-neva', 'phi-3-vision',
            'phi-4-multimodal', 'mllama', 'internvl', 'qwen2_vl',
-            'internlm-xcomposer2', 'qwen2_audio', 'pixtral', 'eclair'
+            'internlm-xcomposer2', 'qwen2_audio', 'eclair', 'pixtral'
        ],

1748-1785: Consider adding architecture documentation.

The RadioWithNeck class implements a specific vision encoder architecture, but lacks documentation about its design choices. Consider adding docstrings to explain:

  • Why 1280→1024 channel reduction is used
  • The purpose of the (1,4) kernel convolution
  • The expected input/output tensor shapes
     class RadioWithNeck(torch.nn.Module):
+        """Custom vision encoder combining RADIO with additional neck layers.
+        
+        Architecture:
+        - RADIO encoder (v2.5-h) for feature extraction
+        - Conv1d: 1280→1024 channel reduction
+        - LayerNorm
+        - Conv2d: (1,4) kernel for spatial downsampling
+        - LayerNorm
+        
+        Input: (B, 3, H, W) image tensor
+        Output: (B, H*W/256, 1024) feature tensor
+        """
 
         def __init__(self):
examples/models/core/enc_dec/convert_checkpoint.py (2)

1514-1514: Document the HTTP 403 workaround.

The line torch.hub._validate_not_a_forked_repo = lambda a, b, c: True is overriding an internal torch.hub function to avoid HTTP 403 errors. This workaround should be properly documented with a comment explaining why it's necessary and any potential risks.

-                    torch.hub._validate_not_a_forked_repo = lambda a, b, c: True  # avoid HTTP 403 error
+                    # WORKAROUND: Override torch.hub validation to avoid HTTP 403 errors
+                    # when loading RADIO model from NVlabs repository
+                    torch.hub._validate_not_a_forked_repo = lambda a, b, c: True

1507-1545: Consider extracting RadioWithNeck class to a separate module.

The RadioWithNeck class definition inside the get_model function makes the code harder to maintain and test. Consider moving this class to a separate module for better organization and reusability.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0e16d1f and f1fe84b.

📒 Files selected for processing (4)
  • examples/models/core/enc_dec/convert_checkpoint.py (11 hunks)
  • examples/models/core/multimodal/requirements-eclair.txt (1 hunks)
  • tensorrt_llm/models/enc_dec/model.py (2 hunks)
  • tensorrt_llm/tools/multimodal_builder.py (3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)

**/*.py: The code developed for TensorRT-LLM should conform to Python 3.8+.
Indent Python code with 4 spaces. Do not use tabs.
Always maintain the namespace when importing in Python, even if only one class or function from a module is used.
Python filenames should use snake_case (e.g., some_file.py).
Python classes should use PascalCase (e.g., class SomeClass).
Python functions and methods should use snake_case (e.g., def my_awesome_function():).
Python local variables should use snake_case. Prefix k for variable names that start with a number (e.g., k_99th_percentile).
Python global variables should use upper snake_case and prefix G (e.g., G_MY_GLOBAL).
Python constants should use upper snake_case (e.g., MY_CONSTANT).
Avoid shadowing variables declared in an outer scope in Python.
Initialize all externally visible members of a Python class in the constructor.
For interfaces that may be used outside a file, prefer docstrings over comments in Python.
Comments in Python should be reserved for code within a function, or interfaces that are local to a file.
Use Google style docstrings for Python classes and functions, which can be parsed by Sphinx.
Attributes and variables in Python can be documented inline; attribute docstrings will be rendered under the docstring for the class.
Avoid using reflection in Python when functionality can be easily achieved without reflection.
When using try-except blocks in Python, limit the except to the smallest set of errors possible.
When using try-except blocks to handle multiple possible variable types in Python, keep the body of the try as small as possible, using the else block to implement the logic.

Files:

  • tensorrt_llm/models/enc_dec/model.py
  • tensorrt_llm/tools/multimodal_builder.py
  • examples/models/core/enc_dec/convert_checkpoint.py
**/*.{cpp,h,cu,py}

📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)

All TensorRT-LLM Open Source Software code should contain an NVIDIA copyright header that includes the current year. This includes .cpp, .h, .cu, .py, and any other source files which are compiled or interpreted.

Files:

  • tensorrt_llm/models/enc_dec/model.py
  • tensorrt_llm/tools/multimodal_builder.py
  • examples/models/core/enc_dec/convert_checkpoint.py
🧠 Learnings (2)
tensorrt_llm/models/enc_dec/model.py (2)

Learnt from: moraxu
PR: #6303
File: tests/integration/test_lists/qa/examples_test_list.txt:494-494
Timestamp: 2025-07-28T17:06:08.621Z
Learning: In TensorRT-LLM testing, it's common to have both CLI flow tests (test_cli_flow.py) and PyTorch API tests (test_llm_api_pytorch.py) for the same model. These serve different purposes: CLI flow tests validate the traditional command-line workflow, while PyTorch API tests validate the newer LLM API backend. Both are legitimate and should coexist.

Learnt from: CR
PR: NVIDIA/TensorRT-LLM#0
File: CODING_GUIDELINES.md:0-0
Timestamp: 2025-07-30T06:11:42.362Z
Learning: Applies to **/*.py : The code developed for TensorRT-LLM should conform to Python 3.8+.

tensorrt_llm/tools/multimodal_builder.py (1)

Learnt from: moraxu
PR: #6303
File: tests/integration/test_lists/qa/examples_test_list.txt:494-494
Timestamp: 2025-07-28T17:06:08.621Z
Learning: In TensorRT-LLM testing, it's common to have both CLI flow tests (test_cli_flow.py) and PyTorch API tests (test_llm_api_pytorch.py) for the same model. These serve different purposes: CLI flow tests validate the traditional command-line workflow, while PyTorch API tests validate the newer LLM API backend. Both are legitimate and should coexist.

🪛 Ruff (0.12.2)
examples/models/core/enc_dec/convert_checkpoint.py

1594-1594: Local variable device is assigned to but never used

Remove assignment to unused variable device

(F841)


1598-1598: Local variable checkpoint_path is assigned to but never used

Remove assignment to unused variable checkpoint_path

(F841)

🔇 Additional comments (12)
tensorrt_llm/models/enc_dec/model.py (2)

23-24: LGTM! Proper import addition for vocabulary padding.

The addition of pad_vocab_size import is appropriate and follows the existing import pattern in the utilities section.


1160-1164: LGTM! Correct implementation of vocabulary size padding for tensor parallelism.

The vocabulary padding logic correctly uses pad_vocab_size to ensure the vocabulary size is divisible by the tensor parallel size, which is essential for proper tensor parallelism support. This change aligns well with the checkpoint conversion logic mentioned in the AI summary.

tensorrt_llm/tools/multimodal_builder.py (2)

28-28: LGTM!

The import for safetensors is appropriate and follows the existing import organization pattern.


147-148: LGTM!

The conditional branch for the "eclair" model type is correctly implemented and follows the existing pattern.

examples/models/core/enc_dec/convert_checkpoint.py (8)

17-17: Import statement looks good.

The addition of NougatProcessor to the imports is appropriate for the new eclair_radio model support.


21-21: Import follows namespace convention.

Good adherence to the coding guideline of maintaining namespace when importing (from tensorrt_llm._utils import pad_vocab_size).


34-36: Constant definition is clear and follows naming conventions.

The constant ECLAIR_RADIO_MAX_POSITION_EMBEDDINGS = 20000 follows the upper snake_case naming convention for constants as specified in the coding guidelines.


626-636: Configuration parsing updates are well-structured.

The changes to parse_bart_config function properly handle the eclair_radio model:

  • Correctly uses the full model config for decoder when args.eclair_radio is true
  • Maintains consistency with nougat model handling pattern
  • Appropriately overrides n_positions with the defined constant

Also applies to: 638-639, 775-776, 779-782


968-983: Vocabulary padding implementation is correct and necessary.

The addition of vocabulary padding logic ensures proper tensor parallelism when the vocabulary size is not divisible by mapping.tp_size. The implementation correctly:

  • Uses the pad_vocab_size utility to calculate padded size
  • Applies zero padding to the weight tensor
  • Updates the vocab_size for subsequent reshaping

Note: The local import torch at line 968 is acceptable for lazy loading but could be moved to the top-level imports for consistency.


1546-1583: Tokenizer configuration is comprehensive and well-structured.

The get_processor function properly configures the tokenizer with:

  • Special tokens for different output modes (plain, markdown, OCR, etc.)
  • Coordinate tokens for bounding box support (1024x1280 resolution)
  • Class tokens for document element classification

The implementation correctly adds tokens and updates the tokenizer attributes.


1669-1670: Checkpoint conversion logic properly handles eclair_radio model.

The updates to skip encoder conversion for eclair_radio models are consistent with the handling of nougat and pix2struct models, which is appropriate since eclair_radio uses a vision encoder that doesn't require the standard text encoder conversion.

Also applies to: 1806-1807, 1816-1817


1879-1881: Command-line argument follows established pattern.

The new --eclair_radio argument is properly added with the same description as --nougat, maintaining consistency in the CLI interface.

@yibinl-nvidia
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13574 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13574 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #10175 completed with status: 'FAILURE'

@yibinl-nvidia
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13580 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13580 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #10180 completed with status: 'FAILURE'

@yibinl-nvidia
Copy link
Collaborator Author

/bot run --disable-fail-fast

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: 0

♻️ Duplicate comments (2)
tensorrt_llm/tools/multimodal_builder.py (1)

1746-1810: Address the previously identified issues.

The same issues identified in the previous review still need to be addressed:

  1. Network dependency: The torch.hub.load call requires network access and could fail
  2. Hard-coded dimensions: Image dimensions (2048, 1648) should be configurable
  3. Temporary fix needs tracking: Add TODO comment for the fused attention workaround
  4. Dtype inconsistency: Model uses bfloat16 but dummy input uses float16

Please refer to the previous review comments for the detailed implementation suggestions.

examples/models/core/enc_dec/convert_checkpoint.py (1)

1594-1594: Remove unused variables flagged by static analysis.

The variables device (line 1594) and checkpoint_path (lines 1598-1601) are assigned but never used. These should be removed to clean up the code.

-            device, d_model = model.device, model.config.decoder.d_model
+            d_model = model.config.decoder.d_model

             with torch.inference_mode():
-                # Inspect checkpoint shapes
-                checkpoint_path = os.path.join(args.model_dir,
-                                               "model.safetensors")

Also applies to: 1598-1601

🧹 Nitpick comments (1)
examples/models/core/enc_dec/convert_checkpoint.py (1)

506-618: Well-implemented eclair model setup with some cleanup opportunities.

The eclair_radio model implementation is comprehensive and follows good practices:

  • Clear separation of RadioWithNeck encoder module
  • Proper processor setup with special tokens
  • Correct integration with nougat-base architecture

Consider these improvements:

  1. Remove commented code (lines 1600-1602): Clean up the commented safetensors inspection code
  2. Add error handling for the torch.hub.load and safetensors loading operations
  3. Document the HTTP 403 workaround (line 1514): Add a comment explaining why the validation override is needed
-                # with safetensors.safe_open(checkpoint_path, framework="pt") as f:
-                #     if "decoder.model.decoder.embed_tokens.weight" in f.keys():
-                #         embed_shape = f.get_tensor("decoder.model.decoder.embed_tokens.weight").shape
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f1fe84b and 42d77e4.

📒 Files selected for processing (4)
  • examples/models/core/enc_dec/convert_checkpoint.py (11 hunks)
  • examples/models/core/multimodal/requirements-eclair.txt (1 hunks)
  • tensorrt_llm/models/enc_dec/model.py (2 hunks)
  • tensorrt_llm/tools/multimodal_builder.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • examples/models/core/multimodal/requirements-eclair.txt
  • tensorrt_llm/models/enc_dec/model.py
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)

**/*.py: The code developed for TensorRT-LLM should conform to Python 3.8+.
Indent Python code with 4 spaces. Do not use tabs.
Always maintain the namespace when importing in Python, even if only one class or function from a module is used.
Python filenames should use snake_case (e.g., some_file.py).
Python classes should use PascalCase (e.g., class SomeClass).
Python functions and methods should use snake_case (e.g., def my_awesome_function():).
Python local variables should use snake_case, and prefix k for variable names that start with a number (e.g., k_99th_percentile).
Python global variables should use upper snake_case and prefix G (e.g., G_MY_GLOBAL).
Python constants should use upper snake_case (e.g., MY_CONSTANT).
Avoid shadowing variables declared in an outer scope in Python.
Initialize all externally visible members of a Python class in the constructor.
For interfaces that may be used outside a file, prefer docstrings over comments in Python.
Comments in Python should be reserved for code within a function, or interfaces that are local to a file.
Use Google style docstrings for classes and functions in Python, which can be parsed by Sphinx.
Attributes and variables in Python can be documented inline; attribute docstrings will be rendered under the docstring for the class.
Avoid using reflection in Python when functionality can be easily achieved without it.
When using try-except blocks in Python, limit the except to the smallest set of errors possible.
When using try-except blocks to handle multiple possible variable types in Python, keep the body of the try as small as possible, using the else block to implement the logic.

Files:

  • tensorrt_llm/tools/multimodal_builder.py
  • examples/models/core/enc_dec/convert_checkpoint.py
**/*.{cpp,h,hpp,cc,cxx,cu,py}

📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)

All TensorRT-LLM Open Source Software code should contain an NVIDIA copyright header that includes the current year. This includes .cpp, .h, .cu, .py, and any other source files which are compiled or interpreted.

Files:

  • tensorrt_llm/tools/multimodal_builder.py
  • examples/models/core/enc_dec/convert_checkpoint.py
🧠 Learnings (1)
tensorrt_llm/tools/multimodal_builder.py (2)

Learnt from: moraxu
PR: #6303
File: tests/integration/test_lists/qa/examples_test_list.txt:494-494
Timestamp: 2025-07-28T17:06:08.621Z
Learning: In TensorRT-LLM testing, it's common to have both CLI flow tests (test_cli_flow.py) and PyTorch API tests (test_llm_api_pytorch.py) for the same model. These serve different purposes: CLI flow tests validate the traditional command-line workflow, while PyTorch API tests validate the newer LLM API backend. Both are legitimate and should coexist.

Learnt from: amitz-nv
PR: #5616
File: tensorrt_llm/executor/worker.py:375-384
Timestamp: 2025-07-17T09:01:27.402Z
Learning: In tensorrt_llm/executor/worker.py, the LoRA adapter cache optimization logic that checks is_adapter_in_cpu_cache() and conditionally passes None for weights/config has a known race condition issue that cannot be solved with simple error handling or verification checks. This is a known limitation that requires a more comprehensive solution.

🪛 Ruff (0.12.2)
examples/models/core/enc_dec/convert_checkpoint.py

1594-1594: Local variable device is assigned to but never used

Remove assignment to unused variable device

(F841)


1598-1598: Local variable checkpoint_path is assigned to but never used

Remove assignment to unused variable checkpoint_path

(F841)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Pre-commit Check
🔇 Additional comments (9)
tensorrt_llm/tools/multimodal_builder.py (3)

28-28: LGTM!

The safetensors import addition is appropriate and necessary for the new eclair model loading functionality.


34-46: LGTM!

The addition of 'eclair' to the model_type choices is correctly implemented and follows the existing pattern.


147-148: LGTM!

The elif condition for eclair model type is correctly implemented and follows the existing pattern in the build method.

examples/models/core/enc_dec/convert_checkpoint.py (6)

17-17: LGTM! New imports support eclair model functionality.

The NougatProcessor and pad_vocab_size imports are correctly added to support the new eclair model variant with proper processor setup and vocabulary padding for tensor parallelism.

Also applies to: 21-21


34-36: LGTM! Well-defined constant for eclair model configuration.

The ECLAIR_RADIO_MAX_POSITION_EMBEDDINGS constant is properly defined and used consistently throughout the codebase for position embedding sizing in the eclair model.


626-637: LGTM! Configuration parsing properly handles eclair model.

The configuration parsing changes correctly handle the eclair_radio model by:

  • Using root config instead of decoder-specific config when needed
  • Following the established pattern similar to nougat model handling
  • Properly overriding position embeddings with the defined constant

The logic is consistent and follows the expected behavior for vision encoder + mbart decoder models.

Also applies to: 638-638, 775-775, 780-782


1669-1670: LGTM! Consistent encoder conversion exclusion logic.

The conditions properly exclude encoder conversion for eclair_radio models, following the established pattern for nougat models. This is correct since eclair_radio uses a RADIO vision encoder that doesn't require the standard checkpoint conversion process.

Also applies to: 1805-1806, 1816-1817


968-983: LGTM! Proper vocabulary padding for tensor parallelism alignment.

The lm_head weight padding logic correctly handles cases where vocabulary size is not divisible by tensor parallelism size:

  • Uses the appropriate pad_vocab_size utility function
  • Pads with zeros to maintain model correctness
  • Updates vocab_size for consistent downstream operations

This is essential for proper tensor parallelism alignment.


1879-1881: LGTM! Clear command line argument for eclair model.

The --eclair_radio argument is properly defined with appropriate help text that accurately describes the model architecture as using a vision encoder with mbart decoder.

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13624 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13624 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #10220 completed with status: 'FAILURE'

@yibinl-nvidia
Copy link
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13700 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13700 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #10291 completed with status: 'FAILURE'

@yibinl-nvidia
Copy link
Collaborator Author

/bot run --disable-fail-fast

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: 0

♻️ Duplicate comments (1)
examples/models/core/enc_dec/convert_checkpoint.py (1)

1594-1594: Remove unused variables flagged by static analysis.

The variables device (line 1594) and checkpoint_path (line 1598) are assigned but never used. These should be removed to clean up the code.

Apply this diff to remove the unused variables:

-            device, d_model = model.device, model.config.decoder.d_model
+            d_model = model.config.decoder.d_model

             with torch.inference_mode():
-                # Inspect checkpoint shapes
-                checkpoint_path = os.path.join(args.model_dir,
-                                               "model.safetensors")
-                # with safetensors.safe_open(checkpoint_path, framework="pt") as f:
-                #     if "decoder.model.decoder.embed_tokens.weight" in f.keys():
-                #         embed_shape = f.get_tensor("decoder.model.decoder.embed_tokens.weight").shape
                 safetensors.torch.load_model(model,
                                              os.path.join(
                                                  args.model_dir,
                                                  "model.safetensors"),
                                              strict=False)

Also applies to: 1598-1601

🧹 Nitpick comments (1)
examples/models/core/enc_dec/convert_checkpoint.py (1)

509-544: Consider improving the RadioWithNeck class implementation.

While the implementation is functional, consider these improvements:

  1. Add docstrings to document the class and its forward method
  2. Replace the torch.hub hack with a more robust solution for HTTP 403 errors
  3. Define magic numbers as constants (1280, 1024, kernel sizes, etc.)

Example improvements:

+# Vision encoder dimensions
+RADIO_FEATURE_DIM = 1280
+NECK_HIDDEN_DIM = 1024
+CONV2D_KERNEL_SIZE = (1, 4)
+CONV2D_STRIDE = (1, 4)

 class RadioWithNeck(torch.nn.Module):
+    """Vision encoder that combines RADIO model with neck layers for feature processing."""

     def __init__(self):
         super().__init__()
-        torch.hub._validate_not_a_forked_repo = lambda a, b, c: True  # avoid HTTP 403 error
+        # TODO: Replace with proper authentication or offline model loading
+        torch.hub._validate_not_a_forked_repo = lambda a, b, c: True
         self.model_encoder = torch.hub.load("NVlabs/RADIO", "radio_model", version="radio_v2.5-h")
         self.model_encoder.summary_idxs = torch.tensor(4)

-        self.conv1 = torch.nn.Conv1d(1280, 1024, 1)
-        self.layer_norm1 = torch.nn.LayerNorm(1024, eps=1e-6, elementwise_affine=True)
+        self.conv1 = torch.nn.Conv1d(RADIO_FEATURE_DIM, NECK_HIDDEN_DIM, 1)
+        self.layer_norm1 = torch.nn.LayerNorm(NECK_HIDDEN_DIM, eps=1e-6, elementwise_affine=True)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 42d77e4 and 5c76e24.

📒 Files selected for processing (4)
  • examples/models/core/enc_dec/convert_checkpoint.py (11 hunks)
  • examples/models/core/multimodal/requirements-eclair.txt (1 hunks)
  • tensorrt_llm/models/enc_dec/model.py (2 hunks)
  • tensorrt_llm/tools/multimodal_builder.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • examples/models/core/multimodal/requirements-eclair.txt
  • tensorrt_llm/models/enc_dec/model.py
  • tensorrt_llm/tools/multimodal_builder.py
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)

**/*.py: Python code should conform to Python 3.8+.
Indent Python code with 4 spaces. Do not use tabs.
Always maintain the namespace when importing in Python, even if only one class or function from a module is used.
Python filenames should use snake_case (e.g., some_file.py).
Python classes should use PascalCase (e.g., class SomeClass).
Python functions and methods should use snake_case (e.g., def my_awesome_function():).
Python local variables should use snake_case. Prefix k for variable names that start with a number (e.g., k_99th_percentile = ...).
Python global variables should use upper snake_case and prefix G (e.g., G_MY_GLOBAL = ...).
Python constants should use upper snake_case (e.g., MY_CONSTANT = ...).
Avoid shadowing variables declared in an outer scope in Python.
Initialize all externally visible members of a Python class in the constructor.
For interfaces that may be used outside a Python file, prefer docstrings over comments.
Comments in Python should be reserved for code within a function, or interfaces that are local to a file.
Use Google style docstrings for Python classes and functions, which can be parsed by Sphinx.
Attributes and variables in Python can be documented inline; attribute docstrings will be rendered under the docstring for the class.
Avoid using reflection in Python when functionality can be easily achieved without it.
When using try-except blocks in Python, limit the except to the smallest set of errors possible.
When using try-except blocks to handle multiple possible variable types in Python, keep the body of the try as small as possible, using the else block to implement the logic.

Files:

  • examples/models/core/enc_dec/convert_checkpoint.py
**/*.{cpp,h,hpp,cc,cxx,cu,py}

📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)

All TensorRT-LLM Open Source Software code should contain an NVIDIA copyright header that includes the current year. This includes .cpp, .h, .cu, .py, and any other source files which are compiled or interpreted.

Files:

  • examples/models/core/enc_dec/convert_checkpoint.py
🪛 Ruff (0.12.2)
examples/models/core/enc_dec/convert_checkpoint.py

1594-1594: Local variable device is assigned to but never used

Remove assignment to unused variable device

(F841)


1598-1598: Local variable checkpoint_path is assigned to but never used

Remove assignment to unused variable checkpoint_path

(F841)

🔇 Additional comments (5)
examples/models/core/enc_dec/convert_checkpoint.py (5)

17-17: LGTM! Required imports for eclair_radio functionality.

The new imports are properly used later in the code - NougatProcessor for processor setup and pad_vocab_size for vocabulary padding in tensor parallelism.

Also applies to: 21-21


34-36: LGTM! Well-defined constant for eclair_radio configuration.

The constant follows proper naming conventions and provides a clear, reusable value for the maximum position embeddings in the eclair_radio model.


626-642: LGTM! Configuration parsing properly handles eclair_radio model.

The changes correctly follow the established pattern for handling vision encoder + decoder models like nougat, with appropriate conditional logic and configuration overrides for the eclair_radio variant.

Also applies to: 775-782


968-983: LGTM! Proper vocabulary padding for tensor parallelism compatibility.

The implementation correctly pads the vocabulary size and lm_head.weight tensor with zeros when needed for tensor parallelism, following established patterns for distributed training compatibility.


1669-1670: LGTM! Consistent conditional logic for eclair_radio model handling.

The conditional checks correctly group eclair_radio with nougat to skip encoder conversion, following the established pattern for vision encoder + decoder models.

Also applies to: 1805-1806, 1816-1817

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13729 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13729 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #10316 completed with status: 'FAILURE'

@yibinl-nvidia yibinl-nvidia requested a review from a team as a code owner August 6, 2025 19:11
@yibinl-nvidia yibinl-nvidia force-pushed the aw632-eclair-v2 branch 2 times, most recently from 5c76e24 to be2c4d5 Compare August 6, 2025 22:00
@yibinl-nvidia
Copy link
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #14561 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #14561 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #11000 completed with status: 'SUCCESS'

@yibinl-nvidia yibinl-nvidia changed the title [feat] add support for Eclairv2 model - cherry-pick changes [TRTLLM-6420][feat] add support for Eclairv2 model - cherry-pick changes and minor changes Aug 8, 2025
@yibinl-nvidia yibinl-nvidia requested a review from a team August 8, 2025 18:44
@yibinl-nvidia yibinl-nvidia changed the title [TRTLLM-6420][feat] add support for Eclairv2 model - cherry-pick changes and minor changes [TRTLLM-6420][feat] add support for Eclairv2 model - cherry-pick changes and minor fix Aug 8, 2025
@nv-guomingz nv-guomingz requested a review from a team as a code owner August 9, 2025 01:22
@nv-guomingz nv-guomingz requested a review from 2ez4bz August 9, 2025 01:22
@nv-guomingz
Copy link
Collaborator

/bot reuse-pipeline

@nv-guomingz nv-guomingz enabled auto-merge (squash) August 9, 2025 01:22
@nv-guomingz nv-guomingz disabled auto-merge August 9, 2025 01:22
@nv-guomingz nv-guomingz enabled auto-merge (squash) August 9, 2025 01:23
@nv-guomingz nv-guomingz disabled auto-merge August 9, 2025 01:24
@tensorrt-cicd
Copy link
Collaborator

PR_Github #14660 [ reuse-pipeline ] triggered by Bot

@nv-guomingz nv-guomingz enabled auto-merge (squash) August 9, 2025 01:31
@tensorrt-cicd
Copy link
Collaborator

PR_Github #14660 [ reuse-pipeline ] completed with state SUCCESS
Reusing PR_Github #14561 for commit 80438b2

@nv-guomingz nv-guomingz merged commit 9778788 into NVIDIA:main Aug 9, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants