Skip to content

[None][fix] laguna: honour attention_factor as final YaRN scaling coefficient#16379

Open
joerowell wants to merge 1 commit into
NVIDIA:mainfrom
joerowell:joerowell/laguna-yarn-attention-factor
Open

[None][fix] laguna: honour attention_factor as final YaRN scaling coefficient#16379
joerowell wants to merge 1 commit into
NVIDIA:mainfrom
joerowell:joerowell/laguna-yarn-attention-factor

Conversation

@joerowell

@joerowell joerowell commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

_build_rope_from_flat_dict set rp.mscale = attention_factor, but create_sinusoidal_positions_yarn routes mscale through 0.1mscaleln(factor)+1, so the HF final scaling got the log applied twice (factor 64 +12.2%, factor 32 +8.9%). Invert so create_sinusoidal reproduces attention_factor exactly, and import math for the log.

This doesn't actually appear to have caused too much divergence in practice, but it's worth addressing.

Summary by CodeRabbit

  • Bug Fixes
    • Improved YaRN RoPE scaling behavior for Laguna attention.
    • Added safeguards for scaling values at or below 1.0.
    • Updated scaling calculations to better match Hugging Face semantics.

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)

  • If PR introduces API changes, an appropriate PR label is added - either api-compatible or api-breaking. For api-breaking, include BREAKING in the PR title.

  • 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

To see a list of available CI bot commands, please comment /bot help.

@joerowell
joerowell requested a review from a team as a code owner July 14, 2026 16:06
@joerowell
joerowell requested a review from aswinvisva July 14, 2026 16:06
@joerowell joerowell changed the title laguna: honor attention_factor as final YaRN scaling coefficient laguna: honour attention_factor as final YaRN scaling coefficient Jul 14, 2026
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Laguna’s YaRN RoPE construction now converts the final attention factor into rp.mscale using a log-based inversion, guarded for scales at or below 1.0.

Changes

Laguna RoPE scaling

Layer / File(s) Summary
YaRN attention factor inversion
tensorrt_llm/_torch/models/modeling_laguna.py
Adds math and derives rp.mscale from rp.scale to match HuggingFace YaRN semantics, while preserving a guard for rp.scale <= 1.0.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: aswinvisva, dombrown

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title matches the main change and follows the required [None][fix] summary format.
Description check ✅ Passed The issue and solution are explained and the checklist is filled, but the Test Coverage section is empty.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tensorrt_llm/_torch/models/modeling_laguna.py`:
- Around line 309-313: Update the attention_factor assignment in the RoPE
configuration logic to explicitly coerce the value from rp_dict to float before
performing arithmetic. Preserve the existing inversion formula and rp.scale
conditional while ensuring quoted numeric attention_factor values are handled
consistently with the other explicitly cast RoPE fields.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 87bd2df7-b0ac-49e0-a15a-197ddc5c29c2

📥 Commits

Reviewing files that changed from the base of the PR and between 544199a and 5ab2459.

📒 Files selected for processing (1)
  • tensorrt_llm/_torch/models/modeling_laguna.py

Comment thread tensorrt_llm/_torch/models/modeling_laguna.py Outdated
@DomBrown DomBrown changed the title laguna: honour attention_factor as final YaRN scaling coefficient [None][fix] laguna: honour attention_factor as final YaRN scaling coefficient Jul 14, 2026
@joerowell
joerowell force-pushed the joerowell/laguna-yarn-attention-factor branch 2 times, most recently from c9f2cc7 to 73ee70f Compare July 14, 2026 16:22
@DomBrown

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #59237 [ run ] triggered by Bot. Commit: 73ee70f Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #59237 [ run ] completed with state FAILURE. Commit: 73ee70f
/LLM/main/L0_MergeRequest_PR pipeline #47731 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

…ficient

_build_rope_from_flat_dict set rp.mscale = attention_factor, but create_sinusoidal_positions_yarn routes mscale through 0.1*mscale*ln(factor)+1, so the HF final scaling got the log applied twice (factor 64 +12.2%, factor 32 +8.9%). Invert so create_sinusoidal reproduces attention_factor exactly, and import math for the log.

Signed-off-by: Joe Rowell <joerowell4@gmail.com>
@DomBrown
DomBrown force-pushed the joerowell/laguna-yarn-attention-factor branch from 73ee70f to f07c341 Compare July 24, 2026 08:18
@DomBrown

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61543 [ run ] triggered by Bot. Commit: f07c341 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61543 [ run ] completed with state SUCCESS. Commit: f07c341
/LLM/main/L0_MergeRequest_PR pipeline #49755 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

@aswinvisva aswinvisva left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

# create_sinusoidal_positions_yarn applies get_mscale(factor, rp.mscale)
# = 0.1*rp.mscale*ln(factor)+1 (mscale_all_dim=0), so setting mscale to the
# final value routes it through the log twice. Invert to reproduce it exactly.
rp.mscale = (

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Out of curiosity - I see from the PR description that this did not lead to too much of an accuracy issue (?). How did you find this in the first place?

@DomBrown

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61688 [ run ] triggered by Bot. Commit: f07c341 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61688 [ run ] completed with state SUCCESS. Commit: f07c341
/LLM/main/L0_MergeRequest_PR pipeline #49894 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

@DomBrown

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61698 [ run ] triggered by Bot. Commit: f07c341 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61698 [ run ] completed with state FAILURE. Commit: f07c341
/LLM/main/L0_MergeRequest_PR pipeline #49903 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

@DomBrown

Copy link
Copy Markdown
Collaborator

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61701 [ run ] triggered by Bot. Commit: f07c341 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61701 [ run ] completed with state SUCCESS. Commit: f07c341
/LLM/main/L0_MergeRequest_PR pipeline #49906 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

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.

6 participants