diff --git a/python/sglang/srt/configs/nano_nemotron_vl.py b/python/sglang/srt/configs/nano_nemotron_vl.py index 326a79c02..888f94a1b 100644 --- a/python/sglang/srt/configs/nano_nemotron_vl.py +++ b/python/sglang/srt/configs/nano_nemotron_vl.py @@ -60,6 +60,13 @@ class NemotronH_Nano_VL_V2_Config(PretrainedConfig): use_thumbnail: bool = True, **kwargs, ): + # Round-trip: `to_dict()` emits `raw_vision_config` (V2's storage + # name) but `from_dict()` rebuilds via this `vision_config` kwarg. + # Without this alias, the V3->V2 alias rebuild in `get_config` loses + # the vision config across the round-trip. + if vision_config is None: + vision_config = kwargs.pop("raw_vision_config", None) + super().__init__(**kwargs) # Handle both cases: when loading from JSON (llm_config is dict) and when called internally by transformers (llm_config; vision_config are None) diff --git a/python/sglang/srt/models/nano_nemotron_vl.py b/python/sglang/srt/models/nano_nemotron_vl.py index b210b1818..bfd6cc128 100644 --- a/python/sglang/srt/models/nano_nemotron_vl.py +++ b/python/sglang/srt/models/nano_nemotron_vl.py @@ -39,6 +39,7 @@ from sglang.srt.model_loader.weight_utils import default_weight_loader from sglang.srt.models.nemotron_h import NemotronHForCausalLM from sglang.srt.models.parakeet import ProjectedParakeet from sglang.srt.models.radio import RadioModel +from sglang.srt.models.utils import WeightsMapper from sglang.srt.multimodal.evs import EVS, EVSConfig from sglang.srt.multimodal.evs.evs_module import VideoEVSDataItem from sglang.srt.utils import add_prefix @@ -47,6 +48,15 @@ logger = logging.getLogger(__name__) class NemotronH_Nano_VL_V2(EVS): + # The loader reads `hf_to_sglang_mapper` off the outer model class when + # applying name rewrites to the quant config's `quantized_layers` keys; + # the inner NemotronHForCausalLM mapper is not consulted there. + hf_to_sglang_mapper = WeightsMapper( + orig_to_new_prefix={ + "language_model.backbone.": "language_model.model.", + }, + ) + @staticmethod def create_evs_config(config: NemotronH_Nano_VL_V2_Config): return EVSConfig(video_pruning_rate=config.video_pruning_rate)