Bug: AttributeError: 'GptOssConfig' object has no attribute 'rope_scaling_factor' with transformers >= 5.x

オープン 初心者向け
#23,406 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@NimaVaziri がすでに取り組んでいます。

2026年12月4日 から。

  • #23407 @NimaVaziri による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python, pytorch

調査の方向性

設定マッピングが古いGPT-OSSフィールドにアクセスしている tensorrt_llm/_torch/models/modeling_gpt_oss.py の605〜617行付近を読んでください。HuggingFace GptOssConfig が rope_scaling とエキスパート数をどのように表現しているかを確認し、報告された再現手順を python3 -m dynamo.trtllm、openai/gpt-oss-120b、テンソル並列数2で実行してください。標準的なHuggingFace設定が AttributeError なしで読み込まれ、古い設定マッピングも引き続き機能すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Pytorch
Bug Description

Loading standard HuggingFace openai/gpt-oss-120b with transformers>=5.x (tested on transformers==5.10.4 with tensorrt_llm==1.4.0rc2 in nvcr.io/nvidia/ai-dynamo/tensorrtllm-runtime:1.7.0, and verified still present on main) fails during GptOssForCausalLM.__init__ with:

File ".../tensorrt_llm/_torch/models/modeling_gpt_oss.py", line 611, in __init__
    model_config.pretrained_config.rope_scaling_factor,
AttributeError: 'GptOssConfig' object has no attribute 'rope_scaling_factor'
Root Cause

In tensorrt_llm/_torch/models/modeling_gpt_oss.py (lines 605–617 on main):

# Map config to HF format.
if hasattr(model_config.pretrained_config, 'num_experts'):
    model_config.pretrained_config.num_local_experts = model_config.pretrained_config.num_experts
    model_config.pretrained_config.num_experts_per_tok = model_config.pretrained_config.experts_per_token
    model_config.pretrained_config.rope_scaling = {
        'factor':
        model_config.pretrained_config.rope_scaling_factor,
        'beta_fast':
        model_config.pretrained_config.rope_ntk_beta,
        'beta_slow':
        model_config.pretrained_config.rope_ntk_alpha,
        'original_max_position_embeddings':
        model_config.pretrained_config.initial_context_length,
    }

The guard hasattr(model_config.pretrained_config, 'num_experts') assumes that only legacy non-HF OpenAI GPT-OSS configs expose num_experts. However, in newer HuggingFace transformers (5.10.4), standard GptOssConfig exposes num_experts alongside standard HF num_local_experts, num_experts_per_tok, and rope_scaling (dict)—without experts_per_token or rope_scaling_factor.

Minimal Reproduction

Inside nvcr.io/nvidia/ai-dynamo/tensorrtllm-runtime:1.7.0 (transformers==5.10.4, tensorrt_llm==1.4.0rc2):

from transformers import GptOssConfig
c = GptOssConfig()
print(hasattr(c, "num_experts"))         # True  (128)
print(hasattr(c, "num_local_experts"))   # True  (128)
print(hasattr(c, "rope_scaling"))        # True  ({'rope_type': 'yarn', 'factor': 32.0, ...})
print(hasattr(c, "rope_scaling_factor")) # False -> triggers AttributeError at modeling_gpt_oss.py:611

Running python3 -m dynamo.trtllm --model-path <openai/gpt-oss-120b> --tensor-parallel-size 2 crashes during AutoModelForCausalLM.from_config(...) with the traceback above.

Proposed Fix

Guard the legacy non-HF config mapping so it only runs when rope_scaling_factor (and experts_per_token) are actually present:

if (
    hasattr(model_config.pretrained_config, 'num_experts')
    and hasattr(model_config.pretrained_config, 'rope_scaling_factor')
):
Verification

Verified on 2× NVIDIA H100 80GB HBM3 (nvcr.io/nvidia/ai-dynamo/tensorrtllm-runtime:1.7.0, openai/gpt-oss-120b, TP=2): applying this guard eliminates the AttributeError, allowing GptOssForCausalLM.__init__, weight loading, intra-node TP group init, and KVCM2 initialization to succeed cleanly.

主要言語
Python
スター
15.2k
フォーク
3k
平均マージ
2日 21時間
マージ済み PR(30日)
477

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

NVIDIA/TensorRT-LLM のほかの issue

NVIDIA/TensorRT-LLM の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。