Skip to content

Conversation

@yuantailing
Copy link
Member

@yuantailing yuantailing commented Oct 24, 2025

Before fix:

$ rm -r ~/.cache/huggingface/hub/models--nvidia--DeepSeek-R1-0528-FP4-v2
$ python3 -W ignore -c 'from tensorrt_llm._torch.model_config import ModelConfig; print(ModelConfig.from_pretrained("nvidia/DeepSeek-R1-0528-FP4-v2").quant_config.quant_algo)'
[TensorRT-LLM] TensorRT LLM version: 1.2.0rc2
config.json: 1.49kB [00:00, 1.04MB/s]
None

After fix:

$ rm -r ~/.cache/huggingface/hub/models--nvidia--DeepSeek-R1-0528-FP4-v2
$ python3 -W ignore -c 'from tensorrt_llm._torch.model_config import ModelConfig; print(ModelConfig.from_pretrained("nvidia/DeepSeek-R1-0528-FP4-v2").quant_config.quant_algo)'
[TensorRT-LLM] TensorRT LLM version: 1.2.0rc2
config.json: 1.49kB [00:00, 1.05MB/s]
hf_quant_config.json: 13.1kB [00:00, 2.71MB/s]
NVFP4

Summary by CodeRabbit

Refactor

  • Updated the quantization configuration loading API signature to reference checkpoint directories instead of model directories.
  • Enhanced configuration file resolution mechanism with improved caching for file lookups.

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

  • 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

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

@yuantailing yuantailing requested a review from a team as a code owner October 24, 2025 09:54
@yuantailing
Copy link
Member Author

/bot run

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 24, 2025

📝 Walkthrough

Walkthrough

Parameter renaming and refactoring of model configuration loading in model_config.py. The load_modelopt_quant_config method's model_dir parameter is renamed to checkpoint_dir. Configuration file resolution now uses transformers.utils.hub.cached_file() for proper Hugging Face Hub integration. A local caching helper function is introduced to wrap the external caching utility.

Changes

Cohort / File(s) Summary
Model config parameter and caching refactoring
tensorrt_llm/_torch/model_config.py
Updated load_modelopt_quant_config() method signature: parameter model_dircheckpoint_dir. Added local cached_file() helper wrapping transformers.utils.hub.cached_file(). Replaced direct path-based config file existence checks with cached_file() calls. Removed redundant model directory derivation logic. Updated all call sites to pass checkpoint_dir argument.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description is largely incomplete against the provided template requirements. While the author included a helpful before/after example demonstrating the issue and the fix, the two critical sections—Description (explaining the issue and solution) and Test Coverage (listing relevant tests)—are entirely empty with only placeholder comments. Additionally, the PR Checklist remains unchecked. Although the before/after example provides some contextual information about what was broken and fixed, this does not adequately substitute for the formal template sections that are expected to guide reviewers through the changes and ensure proper validation. The PR description needs to be completed according to the template. Fill in the Description section with a clear explanation of why the issue occurred and what the solution does, add the Test Coverage section specifying which tests validate these changes, and ensure the PR Checklist items are properly reviewed with the checkbox marked. The before/after example is valuable context but should accompany, not replace, these formal sections.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "[None][fix] Fix ModelConfig.from_pretrained get quant config file" clearly describes the main change in the changeset. It accurately indicates that the fix addresses an issue where ModelConfig.from_pretrained was not properly retrieving the quantization config file. The title is specific enough that a teammate reviewing the history would understand the primary change being made, even though it doesn't elaborate on the technical implementation details (such as the parameter name change from model_dir to checkpoint_dir).
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • 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

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

🧹 Nitpick comments (2)
tensorrt_llm/_torch/model_config.py (2)

279-280: Consider consistent error handling for missing config files.

This code uses transformers.utils.hub.cached_file directly, which will raise OSError if quant_cfg.json doesn't exist. In contrast, the cached_file helper introduced at lines 431-437 catches OSError and returns None for optional config files like hf_quant_config.json and dtypes.json.

If quant_cfg.json is required for MIXED_PRECISION quantization, this behavior is correct but could benefit from a more informative error message. Otherwise, consider using consistent error handling.

Apply this diff to provide a clearer error message if the file is required:

         if quant_config.quant_algo == QuantAlgo.MIXED_PRECISION:
-            mixed_quant_config_file = transformers.utils.hub.cached_file(
-                checkpoint_dir, 'quant_cfg.json')
+            try:
+                mixed_quant_config_file = transformers.utils.hub.cached_file(
+                    checkpoint_dir, 'quant_cfg.json')
+            except OSError as e:
+                raise ValueError(
+                    f"MIXED_PRECISION quantization requires 'quant_cfg.json' in {checkpoint_dir}"
+                ) from e

431-437: Consider adding a brief docstring for clarity.

The helper function is well-designed for safely resolving optional config files. Adding a brief docstring would improve readability.

Apply this diff to add a docstring:

         # Get cached file from path or repo id, return None if not exists.
         def cached_file(path_or_repo_id, file_name):
+            """
+            Safely retrieve a cached file from HF Hub or local path.
+            
+            Returns None if the file doesn't exist instead of raising an exception.
+            """
             try:
                 return transformers.utils.hub.cached_file(
                     path_or_repo_id, file_name)
             except OSError:
                 return None
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 602b059 and 9de9624.

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

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Use only spaces, no tabs; indent with 4 spaces.

Files:

  • tensorrt_llm/_torch/model_config.py
**/*.py

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.py: Python code must target Python 3.8+.
Indent Python code with 4 spaces; do not use tabs.
Maintain module namespace when importing; prefer 'from package.subpackage import foo' then 'foo.SomeClass()' instead of importing the class directly.
Python filenames should be snake_case (e.g., some_file.py).
Python classes use PascalCase names.
Functions and methods use snake_case names.
Local variables use snake_case; prefix 'k' for variables that start with a number (e.g., k_99th_percentile).
Global variables use upper SNAKE_CASE prefixed with 'G' (e.g., G_MY_GLOBAL).
Constants use upper SNAKE_CASE (e.g., MY_CONSTANT).
Avoid shadowing variables from an outer scope.
Initialize all externally visible members of a class in the constructor.
Prefer docstrings for interfaces that may be used outside a file; comments for in-function or file-local interfaces.
Use Google-style docstrings for classes and functions (Sphinx-parsable).
Document attributes and variables inline so they render under the class/function docstring.
Avoid reflection when a simpler, explicit approach suffices (e.g., avoid dict(**locals()) patterns).
In try/except, catch the most specific exceptions possible.
For duck-typing try/except, keep the try body minimal and use else for the main logic.

Files:

  • tensorrt_llm/_torch/model_config.py
**/*.{cpp,cxx,cc,h,hpp,hh,hxx,cu,cuh,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Prepend the NVIDIA Apache-2.0 copyright header with current year to the top of all source files (e.g., .cpp, .h, .cu, .py).

Files:

  • tensorrt_llm/_torch/model_config.py
🧬 Code graph analysis (1)
tensorrt_llm/_torch/model_config.py (1)
tensorrt_llm/models/modeling_utils.py (1)
  • QuantConfig (131-271)
⏰ 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 (3)
tensorrt_llm/_torch/model_config.py (3)

444-447: LGTM! Clean usage of walrus operator and helper function.

The code correctly uses the cached_file helper with the walrus operator to conditionally load the modelopt quantization config. The updated parameter name checkpoint_dir is passed correctly to load_modelopt_quant_config.


453-455: LGTM! Consistent pattern for optional config file.

The code follows the same clean pattern as the hf_quant_config.json check above, using the cached_file helper with a walrus operator for optional configuration files.


258-259: Parameter rename from model_dir to checkpoint_dir verified and approved.

The rename improves clarity by accurately reflecting the parameter's purpose (HF checkpoint directory or repo ID). Verification confirms:

  • Only one call site exists in the codebase (line 446-447), which is already updated to use positional arguments
  • No external keyword argument usage detected

The change is safe with no breaking dependencies.

@tensorrt-cicd
Copy link
Collaborator

PR_Github #22425 [ run ] triggered by Bot. Commit: 9de9624

@tensorrt-cicd
Copy link
Collaborator

PR_Github #22425 [ run ] completed with state SUCCESS. Commit: 9de9624
/LLM/main/L0_MergeRequest_PR pipeline #16899 completed with status: 'FAILURE'

@yuantailing
Copy link
Member Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #22492 [ run ] triggered by Bot. Commit: aa88059

@tensorrt-cicd
Copy link
Collaborator

PR_Github #22492 [ run ] completed with state SUCCESS. Commit: aa88059
/LLM/main/L0_MergeRequest_PR pipeline #16950 completed with status: 'FAILURE'

@yuantailing
Copy link
Member Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #22500 [ run ] triggered by Bot. Commit: aa88059

@tensorrt-cicd
Copy link
Collaborator

PR_Github #22500 [ run ] completed with state SUCCESS. Commit: aa88059
/LLM/main/L0_MergeRequest_PR pipeline #16957 completed with status: 'SUCCESS'

@yuantailing yuantailing merged commit 858d643 into NVIDIA:main Oct 27, 2025
5 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.

3 participants