From 8e797a47f0eaf51de5c985e4a00ac4cecb3c6862 Mon Sep 17 00:00:00 2001 From: Rain Jiang <96632942+rainj-me@users.noreply.github.com> Date: Thu, 23 Oct 2025 21:37:56 -0700 Subject: [PATCH] fix: the hardcode hf repo name comparison for deepseek-ocr (#12031) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- python/sglang/srt/utils/hf_transformers_utils.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/python/sglang/srt/utils/hf_transformers_utils.py b/python/sglang/srt/utils/hf_transformers_utils.py index cf2e26ae0..f1b6f63ba 100644 --- a/python/sglang/srt/utils/hf_transformers_utils.py +++ b/python/sglang/srt/utils/hf_transformers_utils.py @@ -197,10 +197,14 @@ def get_config( config = AutoConfig.from_pretrained( model, trust_remote_code=trust_remote_code, revision=revision, **kwargs ) - if "deepseek-ai/DeepSeek-OCR" in model: + if ( + getattr(config, "auto_map", None) is not None + and config.auto_map.get("AutoModel") + == "modeling_deepseekocr.DeepseekOCRForCausalLM" + ): config.model_type = "deepseek-ocr" - # Due to an unknown reason, Hugging Face’s AutoConfig mistakenly recognizes the configuration of deepseek-ocr as deepseekvl2. - # This is a temporary workaround and will require further optimization. + # TODO: Remove this workaround when AutoConfig correctly identifies deepseek-ocr. + # Hugging Face's AutoConfig currently misidentifies it as deepseekvl2. except ValueError as e: if not "deepseek_v32" in str(e):