[Bug]: Gemma 3 global layers run without their linear RoPE scaling (factor 8) on transformers 5.x
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 35/100
调研方向
Read RopeParams.from_config and the TestFromConfigPerLayerType regression test in tests/unittest/_torch/attention/test_rotary_embedding.py. Reproduce the reported CPU only case with transformers 5.5.4 and check that the normalized full_attention parameters yield 1000000.0 linear 8.0; completion is a regression test that catches the reported none and 1.0 result. An open linked pull request already addresses this issue.
由索引模型根据 Issue 内容生成。
描述
System Info
TensorRT-LLM main (3f692ac), PyTorch backend, transformers 5.5.4 (the version in requirements.txt). The config path is CPU-only, so no GPU is needed to reproduce it.
Who can help?
No response
Information
- The official example scripts
- My own modified scripts
Reproduction
On transformers 5.x, PretrainedConfig.rope_scaling is an alias of rope_parameters. For Gemma 3 that is a dict keyed by layer type:
from transformers import Gemma3TextConfig
from tensorrt_llm._torch.attention.backends.interface import RopeParams
# text_config of google/gemma-3-4b-it (same scaling in 12B and 27B)
cfg = Gemma3TextConfig(hidden_size=2560, num_attention_heads=8, num_key_value_heads=4,
head_dim=256, num_hidden_layers=34, max_position_embeddings=131072,
rope_theta=1e6, rope_local_base_freq=1e4,
rope_scaling={"rope_type": "linear", "factor": 8.0})
print(cfg.rope_scaling)
# {'sliding_attention': {'rope_type': 'default', 'rope_theta': 10000.0},
# 'full_attention': {'rope_type': 'linear', 'factor': 8.0, 'rope_theta': 1000000.0}}
rp = RopeParams.from_config(cfg)
print(rp.theta, rp.scale_type.name, rp.scale)
Expected behavior
1000000.0 linear 8.0. HF's Gemma3RotaryEmbedding divides the full-attention inv_freq by 8.
actual behavior
1000000.0 none 1.0.
Gemma3Attention builds every global (full-attention) layer from this RopeParams, so Gemma 3 4B/12B/27B (and fine-tunes such as MedGemma) run their global layers with RoPE angles 8x too large at every position. Sliding layers are not affected, because they override theta and scaling. The existing GPU test test_gemma3_allclose_to_hf[27B] does not catch this: it uses 8 tokens, atol=0.4, and a "most elements close" check, with a single global layer.
additional notes
Root cause: in RopeParams.from_config, from_config correctly picks rope_parameters["full_attention"] into normalized_rope_parameters. But it then reads scaling from getattr(config, "rope_scaling"). That is the outer per-layer-type dict, which is not None, so the fallback to the normalized entry never runs. rope_type and factor are both missing from the outer dict, so the scaling becomes none with a factor of 1.0.
Fix: when rope_scaling is None or is the per-layer-type rope_parameters itself, use the normalized entry. A fix with a CPU-only regression test (TestFromConfigPerLayerType in tests/unittest/_torch/attention/test_rotary_embedding.py) follows in a PR.
Before submitting a new issue...
- Make sure you already searched for relevant issues, and checked the documentation and examples for answers to frequently asked questions.
- 主要语言
- Python
- 星标
- 15.2k
- 派生
- 3k
- 平均合并
- 2 天 21 小时
- 30 天内合并 PR
- 477
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
NVIDIA/TensorRT-LLM 的其他 Issue
-
Bug: AttributeError: 'GptOssConfig' object has no attribute 'rope_scaling_factor' with transformers >= 5.x可能已有人在做 @NimaVaziri 今天认领。 未关闭Pytorch
难度 2/5 1-3 小时 新手友好度 78/100
NVIDIA/TensorRT-LLM#23406 ·
维护者通常 1 天内回复
-
Inference runtime Windows
难度 2/5 1-3 小时 新手友好度 65/100
NVIDIA/TensorRT-LLM#23394 ·
维护者通常 1 天内回复
-
[Bug]: MMLU subsampling changes when evaluators are interleaved可能已有人在做 @LeNeLeNeWo 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
NVIDIA/TensorRT-LLM#23273 ·
维护者通常 1 天内回复
-
Trace-replay Pareto window includes the drain when sessions finish out of admission order可能已有人在做 @sbeierle 于 3 天前认领。 未关闭Testing
难度 2/5 1-3 小时 新手友好度 86/100
NVIDIA/TensorRT-LLM#23077 ·
维护者通常 1 天内回复
-
LongBench V2 blog command breaks on inline comments after continuations可能已有人在做 @ddlw 于 26 天前认领。 未关闭Doc
难度 1/5 1 小时以内 新手友好度 91/100
NVIDIA/TensorRT-LLM#21879 ·
维护者通常 1 天内回复
查看 NVIDIA/TensorRT-LLM 的全部 Issue
相似的 Issue
-
bug(operator): VolterraOperator built inside jax.jit with a concrete decay raises TracerBoolConversionError可能已有人在做 @jejjohnson 今天认领。 未关闭type:bug
难度 2/5 1-3 小时 新手友好度 72/100
jejjohnson/integrix#144 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
finos/ai-governance-framework#459 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
autowarefoundation/autoware_carla_scenario#2963 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
freelawproject/litigant-portal#1307 ·
维护者通常 2 天内回复
-
type/bug
难度 1/5 1 小时以内 新手友好度 86/100
h2oai/h2o-llmstudio#1163 ·
维护者通常 1 天内回复