From 15bc8cbd74e2bd340f8dcf86006c78016042ff3b Mon Sep 17 00:00:00 2001 From: Yuhao Yang <47235274+yhyang201@users.noreply.github.com> Date: Wed, 10 Dec 2025 02:51:26 +0800 Subject: [PATCH] fix rope parameter initialization error caused by transformers v5.0 update (#14745) --- python/sglang/srt/configs/model_config.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/python/sglang/srt/configs/model_config.py b/python/sglang/srt/configs/model_config.py index 531614ad1..44406239d 100644 --- a/python/sglang/srt/configs/model_config.py +++ b/python/sglang/srt/configs/model_config.py @@ -80,6 +80,16 @@ def get_nsa_index_n_heads(config: PretrainedConfig) -> int: return config.index_n_heads +def handle_rope_parameters(config: PretrainedConfig): + if hasattr(config, "rope_scaling"): + rope_scaling = config.rope_scaling + if isinstance(rope_scaling, dict): + for k, v in rope_scaling.items(): + if not hasattr(config, k): + setattr(config, k, v) + return + + class ModelConfig: def __init__( self, @@ -127,6 +137,8 @@ class ModelConfig: **kwargs, ) self.hf_text_config = get_hf_text_config(self.hf_config) + handle_rope_parameters(self.hf_text_config) + handle_rope_parameters(self.hf_config) self.hf_generation_config = get_generation_config( self.model_path, trust_remote_code=trust_remote_code,