[#8384][fix] use dict.get() instead of getattr() for rope_scaling dict access#11575
[#8384][fix] use dict.get() instead of getattr() for rope_scaling dict access#11575wojciech-wais wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
📝 WalkthroughWalkthroughFixes a bug where Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tensorrt_llm/_torch/modules/qk_norm_attention.py (1)
1-1:⚠️ Potential issue | 🟡 MinorUpdate the copyright year to 2026.
The file was meaningfully modified in this PR but the copyright header still reads
2025. As per coding guidelines, the year must be updated on modified files.📝 Proposed fix
-# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.As per coding guidelines: "Include NVIDIA copyright header on ALL new files and update year on modified files."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tensorrt_llm/_torch/modules/qk_norm_attention.py` at line 1, Update the copyright year in the file header: find the SPDX header line containing "SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES" and change the year from 2025 to 2026 so the header reads 2026.
🧹 Nitpick comments (1)
tensorrt_llm/_torch/modules/qk_norm_attention.py (1)
48-49: RedundantNonedefault in.get("rope_type", None).
dict.get()already returnsNonewhen the key is absent; passing it explicitly adds noise.rope_scaling.get("rope_type")is idiomatic.♻️ Proposed nit
- if rope_scaling is None or rope_scaling.get("rope_type", - None) != "yarn": + if rope_scaling is None or rope_scaling.get("rope_type") != "yarn":🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tensorrt_llm/_torch/modules/qk_norm_attention.py` around lines 48 - 49, The condition uses a redundant explicit None default in rope_scaling.get("rope_type", None); change it to rope_scaling.get("rope_type") so the check becomes if rope_scaling is None or rope_scaling.get("rope_type") != "yarn": — update the expression in the qk_norm_attention logic where rope_scaling is inspected to remove the unnecessary None argument.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@tensorrt_llm/_torch/modules/qk_norm_attention.py`:
- Line 1: Update the copyright year in the file header: find the SPDX header
line containing "SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION &
AFFILIATES" and change the year from 2025 to 2026 so the header reads 2026.
---
Nitpick comments:
In `@tensorrt_llm/_torch/modules/qk_norm_attention.py`:
- Around line 48-49: The condition uses a redundant explicit None default in
rope_scaling.get("rope_type", None); change it to rope_scaling.get("rope_type")
so the check becomes if rope_scaling is None or rope_scaling.get("rope_type") !=
"yarn": — update the expression in the qk_norm_attention logic where
rope_scaling is inspected to remove the unnecessary None argument.
|
Thank you for your contribution! |
rope_scaling from HuggingFace PretrainedConfig is a dict, not an object. Using getattr() on a dict doesn't access dict keys - it always returns the default value. This caused YaRN RoPE scaling to never be activated: - rope_type check always returned None instead of 'yarn' - factor always returned 1.0 instead of the configured scaling factor Fixes NVIDIA#8384 Signed-off-by: Wojciech Wais <wojciech.wais@gmail.com>
7206392 to
ff8d8cb
Compare
They should be addressed now. |
|
There’s a tiny checkbox at the PR description, waiting for you to click. And other PRs as well? 😄 |
|
LGTM; |
rope_scaling from HuggingFace PretrainedConfig is a dict, not an object. Using getattr() on a dict doesn't access dict keys - it always returns the default value. This caused YaRN RoPE scaling to never be activated:
Fixes #8384
Summary by CodeRabbit
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
/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.
Details
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 thestage-listparameter 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.mdand the
scripts/test_to_stage_mapping.pyhelper.kill
killKill all running builds associated with pull request.
skip
skip --comment COMMENTSkip 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-pipelineReuse 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.