Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion tensorrt_llm/_torch/models/modeling_laguna.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# limitations under the License.
"""Laguna / Laguna-XS model for TensorRT-LLM PyTorch backend."""

import math
from typing import Dict, List, Optional, Type

import torch
Expand Down Expand Up @@ -304,7 +305,14 @@ def _build_rope_from_flat_dict(config, rp_dict: dict) -> RopeParams:
rp.beta_slow = float(rp_dict.get("beta_slow", 1.0))
attention_factor = rp_dict.get("attention_factor")
if attention_factor is not None:
rp.mscale = float(attention_factor)
attention_factor = float(attention_factor)
# attention_factor is the FINAL YaRN scaling (HF semantics).
# 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?

((attention_factor - 1.0) / (0.1 * math.log(rp.scale))) if rp.scale > 1 else 1.0
)
rp.original_max_positions = int(
rp_dict.get("original_max_position_embeddings", config.max_position_embeddings)
)
Expand Down
Loading