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

Open Beginner friendly
#23,406 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@NimaVaziri is already working on this.

Since Dec 4, 2026.

  • #23407 by @NimaVaziri — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python, pytorch

Research direction

Read tensorrt_llm/_torch/models/modeling_gpt_oss.py around lines 605–617, where the config mapping accesses legacy GPT-OSS fields. Check how HuggingFace GptOssConfig represents rope_scaling and expert counts, then run the reported python3 -m dynamo.trtllm reproduction with openai/gpt-oss-120b and tensor parallelism 2. Done when standard HuggingFace configs load without the AttributeError and the legacy config mapping still works.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Python
Stars
15.2k
Forks
3k
Avg merge
2d 21h
Merged PRs (30d)
477

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NVIDIA/TensorRT-LLM

All issues in NVIDIA/TensorRT-LLM

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.