[NemotronH] V3 Omni wrapper: WeightsMapper + config round-trip (#25023)

Co-authored-by: Yihao Wang <42559837+AgainstEntropy@users.noreply.github.com>
This commit is contained in:
Serge Panev
2026-05-26 20:34:05 +00:00
committed by GitHub
co-authored by Yihao Wang
parent 2b1e53c98d
commit 499eecce22
2 changed files with 17 additions and 0 deletions
@@ -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)
@@ -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)