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

Đang mở Phù hợp với người mới
#23,406 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@NimaVaziri đang làm issue này rồi.

Từ ngày 4/12/2026.

  • #23407 của @NimaVaziri — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python, pytorch
Lĩnh vực
backend, machine-learning

Hướng nghiên cứu

Đọc tensorrt_llm/_torch/models/modeling_gpt_oss.py quanh các dòng 605–617, nơi ánh xạ cấu hình truy cập các trường GPT-OSS cũ. Kiểm tra cách HuggingFace GptOssConfig biểu diễn rope_scaling và số lượng chuyên gia, sau đó chạy quy trình tái hiện đã được báo cáo với python3 -m dynamo.trtllm, openai/gpt-oss-120b và tensor parallelism bằng 2. Hoàn thành khi các cấu hình HuggingFace tiêu chuẩn được tải mà không gặp AttributeError và ánh xạ cấu hình cũ vẫn hoạt động.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
15.2k
Fork
3k
Merge trung bình
2 ngày 21 giờ
Pull request đã merge (30 ngày)
477

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của NVIDIA/TensorRT-LLM

Tất cả issue của NVIDIA/TensorRT-LLM

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.