[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:
co-authored by
Yihao Wang
parent
2b1e53c98d
commit
499eecce22
@@ -60,6 +60,13 @@ class NemotronH_Nano_VL_V2_Config(PretrainedConfig):
|
|||||||
use_thumbnail: bool = True,
|
use_thumbnail: bool = True,
|
||||||
**kwargs,
|
**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)
|
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)
|
# 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.nemotron_h import NemotronHForCausalLM
|
||||||
from sglang.srt.models.parakeet import ProjectedParakeet
|
from sglang.srt.models.parakeet import ProjectedParakeet
|
||||||
from sglang.srt.models.radio import RadioModel
|
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 import EVS, EVSConfig
|
||||||
from sglang.srt.multimodal.evs.evs_module import VideoEVSDataItem
|
from sglang.srt.multimodal.evs.evs_module import VideoEVSDataItem
|
||||||
from sglang.srt.utils import add_prefix
|
from sglang.srt.utils import add_prefix
|
||||||
@@ -47,6 +48,15 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class NemotronH_Nano_VL_V2(EVS):
|
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
|
@staticmethod
|
||||||
def create_evs_config(config: NemotronH_Nano_VL_V2_Config):
|
def create_evs_config(config: NemotronH_Nano_VL_V2_Config):
|
||||||
return EVSConfig(video_pruning_rate=config.video_pruning_rate)
|
return EVSConfig(video_pruning_rate=config.video_pruning_rate)
|
||||||
|
|||||||
Reference in New Issue
Block a user