Skip to content

[#8384][fix] use dict.get() instead of getattr() for rope_scaling dict access - #11575

Merged
karljang merged 3 commits into
NVIDIA:mainfrom
wojciech-wais:fix/rope-scaling-dict-access
Jul 29, 2026
Merged

[#8384][fix] use dict.get() instead of getattr() for rope_scaling dict access#11575
karljang merged 3 commits into
NVIDIA:mainfrom
wojciech-wais:fix/rope-scaling-dict-access

Conversation

@wojciech-wais

@wojciech-wais wojciech-wais commented Feb 18, 2026

Copy link
Copy Markdown
Contributor

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 #8384

Summary by CodeRabbit

  • Refactor
    • Improved internal parameter handling for attention mechanisms to enhance code maintainability and robustness.

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

@wojciech-wais
wojciech-wais requested a review from a team as a code owner February 18, 2026 21:28
@wojciech-wais
wojciech-wais requested a review from xxi-nv February 18, 2026 21:28
@coderabbitai

coderabbitai Bot commented Feb 18, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Fixes a bug where getattr() was incorrectly used to access dictionary keys in rope_scaling configuration. Replaces attribute access with proper dictionary access using .get() method to correctly retrieve the "factor" and "rope_type" values.

Changes

Cohort / File(s) Summary
Bug Fix: Dictionary Access Correction
tensorrt_llm/_torch/modules/qk_norm_attention.py
Changed rope_scaling attribute access from getattr() to dictionary .get() method for "factor" and "rope_type" keys, ensuring correct retrieval of configuration values.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR successfully addresses issue #8384 by replacing getattr() with dict.get() to correctly read rope_scaling dictionary keys, enabling YaRN RoPE scaling to function as intended.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the rope_scaling dict access issue in qk_norm_attention.py. The modification only affects the specific problem identified in issue #8384 with no extraneous changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title accurately and specifically describes the main change: replacing getattr() with dict.get() for rope_scaling dictionary access, which is the core fix in the PR.
Description check ✅ Passed PR description clearly explains the issue (dict vs object access), the solution (using dict.get instead of getattr), and references the linked issue #8384. However, the Description and Test Coverage sections are empty.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 | 🟡 Minor

Update 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: Redundant None default in .get("rope_type", None).

dict.get() already returns None when 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.

@svc-trtllm-gh-bot svc-trtllm-gh-bot added the Community want to contribute PRs initiated from Community label Feb 18, 2026
@karljang karljang changed the title [#8384] fix: use dict.get() instead of getattr() for rope_scaling dict access [#8384][fix] use dict.get() instead of getattr() for rope_scaling dict access Feb 24, 2026
@karljang

Copy link
Copy Markdown
Collaborator

Thank you for your contribution!
Before we proceed, could you please address the failed checks?

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>
@wojciech-wais
wojciech-wais force-pushed the fix/rope-scaling-dict-access branch from 7206392 to ff8d8cb Compare February 24, 2026 14:20
@wojciech-wais

Copy link
Copy Markdown
Contributor Author

Thank you for your contribution! Before we proceed, could you please address the failed checks?

They should be addressed now.

@karljang

Copy link
Copy Markdown
Collaborator

There’s a tiny checkbox at the PR description, waiting for you to click. And other PRs as well? 😄

@karljang

Copy link
Copy Markdown
Collaborator

LGTM;
@xxi-nv, could you please review this PR.

@karljang

Copy link
Copy Markdown
Collaborator

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61960 [ run ] triggered by Bot. Commit: 21c1b29 Link to invocation

@wojciech-wais
wojciech-wais requested a review from a team as a code owner July 27, 2026 17:55
@karljang

Copy link
Copy Markdown
Collaborator

/bot kill

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61966 [ kill ] triggered by Bot. Commit: 3699eda Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61960 [ run ] completed with state ABORTED. Commit: 21c1b29

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61966 [ kill ] completed with state SUCCESS. Commit: 3699eda
Successfully killed previous jobs for commit 3699eda

Link to invocation

@yunruis

yunruis commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

LGTM; approved

@karljang

Copy link
Copy Markdown
Collaborator

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62145 [ run ] triggered by Bot. Commit: 3699eda Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62145 [ run ] completed with state SUCCESS. Commit: 3699eda
/LLM/main/L0_MergeRequest_PR pipeline #50322 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

CI Agent Failure Analysis

Link to invocation

@karljang

Copy link
Copy Markdown
Collaborator

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62266 [ run ] triggered by Bot. Commit: 3699eda Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62266 [ run ] completed with state FAILURE. Commit: 3699eda
/LLM/main/L0_MergeRequest_PR pipeline #50437 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

CI Agent Failure Analysis

Link to invocation

@karljang

Copy link
Copy Markdown
Collaborator

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62413 [ run ] triggered by Bot. Commit: 3699eda Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62413 [ run ] completed with state SUCCESS. Commit: 3699eda
/LLM/main/L0_MergeRequest_PR pipeline #50572 completed with status: 'SUCCESS'

CI Report

Link to invocation

@karljang
karljang merged commit 2e1a997 into NVIDIA:main Jul 29, 2026
7 checks passed
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.

[Bug]: getattr used on dict for rope_scaling config, leading to incorrect factor

6 participants