Model

ankit/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-NVFP4

Blame for configuration_radio.py at 951ba44

Line blame for configuration_radio.py
LineCommitAuthorDateCode
1Add files using upload-large-folder toolbf6c919ankit# Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14"""RADIO vision encoder configuration."""
15
16from huggingface_hub.dataclasses import strict
17from transformers.configuration_utils import PreTrainedConfig
18from transformers.image_utils import OPENAI_CLIP_MEAN, OPENAI_CLIP_STD
19from transformers.utils import auto_docstring
20
21
22__all__ = ["RadioConfig"]
23
24
25@auto_docstring(checkpoint="nvidia/C-RADIOv4-H")
26@strict
27class RadioConfig(PreTrainedConfig):
28 r"""
29 mlp_ratio (`float`, *optional*, defaults to 4.0):
30 Ratio of the hidden size of the MLP relative to `hidden_size`.
31 use_swiglu_ffn (`bool`, *optional*, defaults to `False`):
32 Whether to use a SwiGLU feed-forward network in the encoder layers instead of the standard MLP.
33 layerscale_value (`float`, *optional*, defaults to 1.0):
34 Initial value for the LayerScale parameters. C-RADIO has no LayerScale; the default of `1.0` makes the
35 (inherited) LayerScale an identity operation.
36 max_img_size (`int`, *optional*, defaults to 2048):
37 Maximum supported image size (in pixels) used to size the position embedding table of the CPE patch generator.
38 num_cls_tokens (`int`, *optional*, defaults to 3):
39 Number of learned class (summary) tokens prepended to the patch sequence.
40 num_registers (`int`, *optional*, defaults to 7):
41 Number of learned register tokens prepended to the patch sequence.
42 summary_idxs (`list[int]`, *optional*, defaults to `[0, 1]`):
43 Indices of the class tokens to gather and flatten into the `summary` output embedding.
44 norm_mean (`tuple[float, float, float]`, *optional*, defaults to `OPENAI_CLIP_MEAN`):
45 Per-channel mean used by the input conditioner to normalize pixel values.
46 norm_std (`tuple[float, float, float]`, *optional*, defaults to `OPENAI_CLIP_STD`):
47 Per-channel standard deviation used by the input conditioner to normalize pixel values.
48 video_temporal_patch_size (`int`, *optional*):
49 Number of temporally-stacked frames per patch. When set, the patch generator also builds a
50 `video_patch_projection` for temporally-packed video patches; `None` disables the video path.
51 """
52
53 model_type = "radio"
54
55 hidden_size: int = 1280
56 num_hidden_layers: int = 32
57 num_attention_heads: int = 16
58 mlp_ratio: float = 4.0
59 hidden_act: str = "gelu"
60 layer_norm_eps: float = 1e-6
61 attention_probs_dropout_prob: float = 0.0
62 hidden_dropout_prob: float = 0.0
63 drop_path_rate: float = 0.0
64 use_swiglu_ffn: bool = False
65 qkv_bias: bool = True
66 # C-RADIO has no layerscale; 1.0 makes the (inherited) layerscale an identity op.
67 layerscale_value: float = 1.0
68 # patch / image
69 num_channels: int = 3
70 patch_size: int = 16
71 image_size: int = 224
72 # CPE patch generator
73 max_img_size: int = 2048
74 num_cls_tokens: int = 3
75 num_registers: int = 7
76 video_temporal_patch_size: int | None = None
77 summary_idxs: list[int] | None = None
78 # input conditioner
79 norm_mean: list[float] | tuple[float, float, float] = tuple(OPENAI_CLIP_MEAN)
80 norm_std: list[float] | tuple[float, float, float] = tuple(OPENAI_CLIP_STD)
81 initializer_range: float = 0.02
82
83 def __post_init__(self, **kwargs):
84 if self.summary_idxs is None:
85 self.summary_idxs = [0, 1]
86 self.norm_mean = list(self.norm_mean)
87 self.norm_std = list(self.norm_std)
88 super().__post_init__(**kwargs)
89
90 @property
91 def num_summary_tokens(self) -> int:
92 """Number of skipped prefix tokens (cls + registers) before spatial features."""
93 return self.num_cls_tokens + self.num_registers