KEMBAR78
[None][fix] Fix the incorrect header file import in dataType.h by Fan-Yunfan · Pull Request #7133 · NVIDIA/TensorRT-LLM · GitHub
Skip to content

Conversation

@Fan-Yunfan
Copy link
Contributor

@Fan-Yunfan Fan-Yunfan commented Aug 21, 2025

Problem

Today, while reading the dataType.h file, I noticed that the methods defined in this file use TLLM_THROW and throw std::runtime_error to handle cases where the input is an unknown nvinfer1::DataType.

To use these two exception handling functions, the header file tensorrt_llm/common/logger.h is included. However, the TLLM_THROW macro are actually defined in tensorrt_llm/common/tllmException.h. The reason no compilation error occurred is that the logger.h includes the assert.h, which in turn includes tllmException.h.

Given that the dataType.h file does not use any logging-related macros or functions from tensorrt_llm/common/logger.h, I believe it would be more intuitive and reasonable to replace the included header from logger.h to tllmException.h.

This would avoid ambiguity and potential issues caused by indirect inclusion.

Current Implementation

cpp/include/tensorrt_llm/common/dataType.h

#pragma once

#include "tensorrt_llm/common/logger.h"
#include <NvInferRuntime.h>
#include <map>

Solution

Replace #include "tensorrt_llm/common/logger.h" with #include "tensorrt_llm/common/tllmException.h".

#pragma once

- #include "tensorrt_llm/common/logger.h"
+ #include "tensorrt_llm/common/tllmException.h"
#include <NvInferRuntime.h>
#include <map>

Additional info

tllmException.h import <stdexcept> as same, so don't worry throw std::runtime_error will occur compilation error.

#pragma once

#include "tensorrt_llm/common/stringUtils.h"

#include <array>
#include <cstddef>
#include <stdexcept>
#include <string>

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 21, 2025

📝 Walkthrough

Walkthrough

Updated a single include in cpp/include/tensorrt_llm/common/dataType.h to reference tensorrt_llm/common/tllmException.h instead of tensorrt_llm/common/logger.h. No other code or public declarations changed.

Changes

Cohort / File(s) Summary
Header include update
cpp/include/tensorrt_llm/common/dataType.h
Replaced include of tensorrt_llm/common/logger.h with tensorrt_llm/common/tllmException.h; functional code unchanged.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ 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.
    • 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.
  • 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 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/Issue comments)

Type @coderabbitai help to get the list of available commands.

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.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

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

🧹 Nitpick comments (4)
cpp/include/tensorrt_llm/common/dataType.h (4)

20-22: Stop relying on transitive includes; add missing headers and remove unused .

The file uses size_t, std::string, and std::runtime_error but does not include their owning headers. Add , , and , and drop the unused to make the header self-sufficient. If you adopt the later suggestion to replace std::runtime_error with TLLM_THROW, can be omitted.

Apply:

 #include "tensorrt_llm/common/tllmException.h"
-#include <NvInferRuntime.h>
-#include <map>
+#include <NvInferRuntime.h>
+#include <cstddef>   // size_t
+#include <stdexcept> // std::runtime_error
+#include <string>    // std::string

17-17: Add include guards per repo guideline (keep #pragma once if you like).

Coding guidelines require header guards named TRTLLM__H. Add them to avoid multiple inclusion and to align with the standard across the tree.

Apply:

-#pragma once
+#ifndef TRTLLM_DATA_TYPE_H
+#define TRTLLM_DATA_TYPE_H
+#pragma once
@@
 } // namespace tensorrt_llm::common
+
+#endif // TRTLLM_DATA_TYPE_H

Also applies to: 87-87


2-2: Consider updating the copyright year to 2025.

This file is being modified in 2025; project guidelines state using the current year in headers. If the repo uses a central script for this, feel free to ignore and let the script run.

- * Copyright (c) 1993-2023, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 1993-2025, NVIDIA CORPORATION.  All rights reserved.

81-81: Prefer TLLM_THROW over throwing std::runtime_error directly for consistency.

Keeps error handling uniform with the rest of this header and leverages the same formatting/exception type as other branches.

-    default: throw std::runtime_error("Unsupported data type"); break;
+    default: TLLM_THROW("Unsupported data type"); break;
📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9a2b44d and 0a2683b.

📒 Files selected for processing (1)
  • cpp/include/tensorrt_llm/common/dataType.h (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{cpp,cxx,cc,cu,h,hpp,hxx,hh,cuh}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.{cpp,cxx,cc,cu,h,hpp,hxx,hh,cuh}: In C++, close namespaces with a comment naming the namespace (e.g., } // namespace foo)
Prefer const/constexpr variables over #define for constants
Declare variables const if not modified after initialization
Use Allman brace style in C++
C++ filenames use lowerCamelCase and must be case-insensitively unique within a build target
C++ type names use UpperCamelCase
Local variables, methods, and namespaces use lowerCamelCase
Global non-static variables not in anonymous namespace use gPrefix lowerCamelCase (e.g., gExample)
Static globals or globals in anonymous namespaces use sPrefix lowerCamelCase
Locally visible static variables start with 's' (e.g., static std::once_flag sFlag;)
Member variables use mPrefix lowerCamelCase; public members may omit but are encouraged to use 'm'
Constants (enums, global/static/function-scope magic numbers) use kPREFIXED_UPPER_SNAKE (e.g., kDIGIT_NUM)
If macros are unavoidable, use UPPER_SNAKE_CASE (prefer constants over #define)
Constructor parameter that conflicts with a public member name gets trailing underscore (foo_)
Literal suffixes should be uppercase (e.g., 1234L not 1234l)
C++: use spaces only; indent 4 spaces
Run clang-format (LLVM style) before submitting; wrap lines at 120 characters
If formatting must be bypassed, use // clang-format off/on around the section
Prefer smart pointers; use unique_ptr for sole ownership, shared_ptr for shared; weak_ptr only in exceptional cases
Do not use deprecated pre-C++11 smart pointers
Use C++ style comments; avoid C comments except special inline cases; prefer // single-line
Capitalize and punctuate full-sentence comments
Follow Doxygen rules: use //! for comments and //!< for members in C++
Disable code with #if/#endif and mnemonic conditions; avoid commented-out code; avoid dead code
Do not throw exceptions across library boundaries
Use least-forceful casts; avoid removing const/volatile; avoid C-style and functional casts (except constructors); p...

Files:

  • cpp/include/tensorrt_llm/common/dataType.h
**/*.{h,hpp,hxx,hh,cuh,cpp,cxx,cc,cu}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Parameter names must be consistent between declarations and definitions

Files:

  • cpp/include/tensorrt_llm/common/dataType.h
**/*.{h,hpp,hxx,hh,cuh}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Header files must use include guards named TRTLLM__H without underscores prefix/suffix (e.g., TRTLLM_FOO_BAR_HELLO_H)

Files:

  • cpp/include/tensorrt_llm/common/dataType.h
**/*.{cpp,cxx,cc,cu,h,hpp,hxx,hh,cuh,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Prepend NVIDIA copyright header (current year) to all source files

Files:

  • cpp/include/tensorrt_llm/common/dataType.h
🧠 Learnings (1)
📓 Common learnings
Learnt from: galagam
PR: NVIDIA/TensorRT-LLM#6487
File: tests/unittest/_torch/auto_deploy/unit/singlegpu/test_ad_trtllm_bench.py:1-12
Timestamp: 2025-08-06T13:58:07.506Z
Learning: In TensorRT-LLM, test files (files under tests/ directories) do not require NVIDIA copyright headers, unlike production source code files. Test files typically start directly with imports, docstrings, or code.
⏰ 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 (1)
cpp/include/tensorrt_llm/common/dataType.h (1)

19-19: Directly including tllmException.h is the correct fix.

This header uses TLLM_THROW and does not rely on any logging facilities, so removing the transitive dependency on logger.h tightens coupling and avoids fragile includes. Looks good.

@svc-trtllm-gh-bot svc-trtllm-gh-bot added the Community want to contribute PRs initiated from Community label Aug 21, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 27, 2025

@Fan-Yunfan I'll review the changes in your PR and the fix you've implemented in commit 1ece984.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Fan-Yunfan
Copy link
Contributor Author

@coderabbitai review

I pushed a fix in commit a8c1956, please review it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 27, 2025

🧩 Analysis chain

@Fan-Yunfan I've reviewed your fix in commit a8c1956. The change is correct and well-reasoned:

✅ What the fix addresses:

  • dataType.h uses TLLM_THROW macro and std::runtime_error which are defined in tllmException.h
  • The previous include of logger.h was indirect - it worked only because logger.h includes tllmException.h
  • Your change makes the dependency explicit and direct

✅ Benefits of this change:

  • Clarity: Makes it obvious which header provides the exception functionality
  • Maintainability: Removes fragile dependency on indirect includes
  • Correctness: Directly includes what the file actually uses

✅ Code review:

  • The header replacement is clean and minimal
  • All exception-related symbols (TLLM_THROW, std::runtime_error) are properly available from tllmException.h
  • No functional changes to the API or behavior
  • Follows good C++ practices for explicit dependencies

This is a solid improvement that eliminates a potential maintenance hazard. The fix is ready to merge!

🐰✨
╱| ╱|
( ◕ ◕ )
╲ ▽ ╱
╲ ╱
╲ ╱


🏁 Script executed:

#!/bin/bash
# First, let's examine the current dataType.h file to see the changes
cat cpp/include/tensorrt_llm/common/dataType.h

Length of output: 3249


🏁 Script executed:

#!/bin/bash
# Let's check the git log to see what commits are in this PR
git log --oneline -10

Length of output: 0


🏁 Script executed:

#!/bin/bash
# Let's look at the specific commit mentioned by the user
git show a8c19567fc3e7b27596fc2bf78234ed0f3747dbc

Length of output: 265669


🏁 Script executed:

#!/bin/bash
# Let's also check what symbols are actually used in dataType.h that might require tllmException.h
rg -n "TLLM_THROW|throw|exception" cpp/include/tensorrt_llm/common/dataType.h

Length of output: 483


🏁 Script executed:

#!/bin/bash
# Let's verify what's in tllmException.h to confirm it has the required definitions
head -20 cpp/include/tensorrt_llm/common/tllmException.h

Length of output: 754


🏁 Script executed:

#!/bin/bash
# Let's also check if logger.h was indirectly including tllmException.h as mentioned
head -20 cpp/include/tensorrt_llm/common/logger.h

Length of output: 740


@Fan-Yunfan I've reviewed your fix in commit a8c1956. The change is correct and well-reasoned:

✅ What the fix addresses:

  • dataType.h uses TLLM_THROW macro and std::runtime_error which are defined in tllmException.h
  • The previous include of logger.h was indirect - it worked only because logger.h includes tllmException.h
  • Your change makes the dependency explicit and direct

✅ Benefits of this change:

  • Clarity: Makes it obvious which header provides the exception functionality
  • Maintainability: Removes fragile dependency on indirect includes
  • Correctness: Directly includes what the file actually uses

✅ Code review:

  • The header replacement is clean and minimal
  • All exception-related symbols (TLLM_THROW, std::runtime_error) are properly available from tllmException.h
  • No functional changes to the API or behavior
  • Follows good C++ practices for explicit dependencies

This is a solid improvement that eliminates a potential maintenance hazard. The fix is ready to merge!

🐰✨
╱| ╱|
( ◕ ◕ )
╲ ▽ ╱
╲ ╱
╲ ╱

✅ Actions performed

Comments resolved.

@Fan-Yunfan
Copy link
Contributor Author

/bot help

@github-actions
Copy link

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.

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.

@Fan-Yunfan
Copy link
Contributor Author

@EmmaQiaoCh Hello~ I noticed that this PR involves code from your previous contributions. Could you please take a look when you have some free time? Thank you! ~

@karljang
Copy link
Collaborator

@tongyuantongyu,
LGTM, but could you help review this PR~ 😄

@tongyuantongyu
Copy link
Member

@tongyuantongyu (Yuan Tong), LGTM, but could you help review this PR~ 😄

I don't mind making this change in a larger PR, but I feel it's too trivial on its own and not worth a dedicate PR.

@karljang karljang self-requested a review September 10, 2025 19:35
@karljang karljang enabled auto-merge (squash) September 10, 2025 19:35
@karljang
Copy link
Collaborator

@Fan-Yunfan , thanks for your contribution! What makes things complete are these small changes anyway~
Please understand above comment, I think, it's due to some congestion in our CI pipeline lately.

@karljang
Copy link
Collaborator

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18404 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

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

@karljang karljang merged commit e311773 into NVIDIA:main Sep 11, 2025
5 checks passed
@Fan-Yunfan
Copy link
Contributor Author

Fan-Yunfan commented Sep 11, 2025

@Fan-Yunfan , thanks for your contribution! What makes things complete are these small changes anyway~ Please understand above comment, I think, it's due to some congestion in our CI pipeline lately.

Thank you for your kindness 🌹, and I apologize for my previous misunderstanding. After your reminder, I’ve realized that each CI pipeline run does indeed take a significant amount of time—around 8 hours per check.

Combining multiple minor code changes into a single PR to trigger the CI pipeline only once is also a common practice in many engineering optimization strategies.

Next time, if I have similar small or incremental code changes, I will consolidate them into one PR to avoid repeated CI pipeline runs and save time.

Your kindness and encouragement are also a great motivation that supports my continued contributions to open source. Thank you once again! 🌹🌹🌹

@karljang
Copy link
Collaborator

Thank you for your understanding and contributions!

Wong4j pushed a commit to Wong4j/TensorRT-LLM that referenced this pull request Sep 20, 2025
…A#7133)

Signed-off-by: fanyunfan <2569548856@qq.com>
Co-authored-by: fanyunfan <2569658856@qq.com>
Co-authored-by: Yunfan Fan <46273019+fyf2016@users.noreply.github.com>
Co-authored-by: Kanghwan <861393+karljang@users.noreply.github.com>
MrGeva pushed a commit to nv-auto-deploy/TensorRT-LLM that referenced this pull request Sep 21, 2025
…A#7133)

Signed-off-by: fanyunfan <2569548856@qq.com>
Co-authored-by: fanyunfan <2569658856@qq.com>
Co-authored-by: Yunfan Fan <46273019+fyf2016@users.noreply.github.com>
Co-authored-by: Kanghwan <861393+karljang@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community want to contribute PRs initiated from Community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants