Skip to navigation

nemo_automodel.components.models.hy_v4_flash.config

View as MarkdownOpen in Claude

Hugging Face checkpoint configuration for tencent/Hy4-flash (model_type hy_v4_flash).

Field names follow the released config.json (revision eccd3123eec73f2040f4c9ed0de1883593470510). The transformers reference (PR 50903) renames a few of them; the aliases it accepts are accepted here too so either spelling of the same checkpoint loads.

Module Contents

Classes

NameDescription
HYV4FlashConfigComposite image-text configuration (HYV4FlashForConditionalGeneration).
HYV4FlashRopeParametersRotary parameters of one attention type, as stored in rope_parameters.
HYV4FlashTextConfigText backbone: hyper-connected gated MLA with SWA / compressed-indexer layers, latent MoE and Engram.
HYV4FlashVisionConfigVision tower hyper-parameters (a 27-layer ViT plus the rmsnorm_mlp_adapter projector).

Functions

NameDescription
_model_flopsCall the FLOPs formula, imported on use because flops imports this module.

Data

AttentionType

EngramHeadVocabSizes

JsonValue

MlpType

_LAYER_TYPE_ALIASES

_RELEASED_LAYER_TYPE

API

class nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashConfig(
image_token_id: int = 120120,
video_token_id: int = 120124,
image_start_token_id: int = 120118,
image_end_token_id: int = 120119,
image_newline_token_id: int = 120121,
tie_word_embeddings: bool = False,
)

Bases: PretrainedConfig

Composite image-text configuration (HYV4FlashForConditionalGeneration).

model_type
= 'hy_v4_flash'
sub_configs
text_config
vision_config
staticmethod

Model FLOPs of one step of the text backbone; the vision tower is not counted.

class nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashRopeParameters

Bases: typing.TypedDict

Rotary parameters of one attention type, as stored in rope_parameters.

mrope_interleaved
NotRequired[bool]
mrope_section
list[int]
rope_theta
float
rope_type
Literal['default']
class nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashTextConfig(
vocab_size: int = 120832,
hidden_size: int = 3072,
intermediate_size: int = 13824,
moe_intermediate_size: int = 1536,
routed_expert_hidden_size: int = 1536,
num_hidden_layers: int = 42,
num_attention_heads: int = 32,
swa_num_attention_heads: int = 64,
hidden_act: typing.Literal['silu'] = 'silu',
max_position_embeddings: int = 1048576,
initializer_range: float = 0.006,
rms_norm_eps: float = 1e-05,
attention_bias: bool = False,
attention_dropout: float = 0.0,
n_routed_experts: int = 512,
n_shared_experts: int = 1,
num_experts_per_tok: int = 16,
routed_scaling_factor: float = 3.998,
norm_topk_prob: bool = True,
n_group: int = 1,
topk_group: int = 1,
swiglu_limit: float = 10.0,
q_lora_rank: int = 1024,
kv_lora_rank: int = 512,
qk_nope_head_dim: int = 192,
qk_rope_head_dim: int = 64,
v_head_dim: int = 256,
swa_qk_nope_head_dim: int = 192,
swa_qk_rope_head_dim: int = 64,
swa_v_head_dim: int = 256,
sliding_window: int = 512,
learnable_sink_init: float = 0.0,
layer_types: list[str] | None = None,
index_topk: int = 2048,
index_head_dim: int = 128,
index_n_heads: int = 16,
compressed_indexer_compress_ratio: int = 4,
hc_mult: int = 4,
hc_magnitude: float = 2.0,
hc_eps: float = 1e-06,
layer_rope_parameters: dict[str, nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashRopeParameters] | None = None,
engram_layer_ids: list[int] | None = None,
engram_max_ngram_size: int = 3,
engram_n_head_per_ngram: int = 8,
engram_n_embed_per_ngram: int = 768,
engram_pad_id: int = 120002,
engram_fp8_embedding: bool | None = None,
engram_seed: int = 0,
engram_lookup_table_size: int = 120818,
enable_lm_head_fp32: bool = True,
fast_op_fp32_linear_gemm: bool = True,
dtype: typing.Literal['bfloat16'] | None = 'bfloat16',
pad_token_id: int | None = 120002,
bos_token_id: int | None = 120000,
eos_token_id: int | list[int] | None = 120025,
tie_word_embeddings: bool = False,
)

Bases: PretrainedConfig

Text backbone: hyper-connected gated MLA with SWA / compressed-indexer layers, latent MoE and Engram.

Layer indices in engram_layer_ids are one-based: the reference builds the Engram block of decoder layer i (zero-based) when i + 1 in engram_layer_ids, so the released [2, 12, 22, 32] means zero-based layers 1, 11, 21 and 31, matching the model card.

attention_types
list[AttentionType]

Attention type of every decoder layer, independent of how layer_types is spelled.

attribute_map
= {'num_local_experts': 'n_routed_experts'}
base_config_key
= 'text_config'
engram_fp8_embedding
= bool(engram_fp8_embedding)
engram_layer_ids
engram_layer_indices
list[int]

Zero-based indices of the built decoder layers that carry an Engram block.

index_kpool
keys_to_ignore_at_inference
= ['past_key_values']
layer_types
mlp_layer_types
= self.mlp_layer_types[:num_hidden_layers]
model_type
= 'hy_v4_flash_text'
routed_expert_hidden_size
nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashTextConfig._validate() -> None
nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashTextConfig.attention_dims(
) -> tuple[int, int, int]

Return (qk_nope_head_dim, qk_rope_head_dim, v_head_dim) of the given attention type.

nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashTextConfig.attention_heads(
) -> int

Number of query heads of a layer of the given attention type.

staticmethod

Model FLOPs of one step (see hy_v4_flash.flops); picked up by get_flops_formula_for_hf_config.

class nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashVisionConfig(
hidden_size: int = 1152,
intermediate_size: int = 4304,
num_hidden_layers: int = 27,
num_attention_heads: int = 16,
num_channels: int = 3,
patch_size: int = 16,
spatial_merge_size: int = 2,
out_hidden_size: int = 3072,
rms_norm_eps: float = 1e-05,
rope_2d_theta: float = 10000.0,
hidden_act: typing.Literal['gelu'] = 'gelu',
max_image_size: int = 2048,
interpolate_mode: typing.Literal['bilinear'] = 'bilinear',
)

Bases: PretrainedConfig

Vision tower hyper-parameters (a 27-layer ViT plus the rmsnorm_mlp_adapter projector).

base_config_key
= 'vision_config'
model_type
= 'hy_v4_flash_vision'
nemo_automodel.components.models.hy_v4_flash.config._model_flops(
gbs: int,
seq_len: int | None
) -> float

Call the FLOPs formula, imported on use because flops imports this module.

nemo_automodel.components.models.hy_v4_flash.config.AttentionType: TypeAlias = Literal['indexed_attention', 'sliding_attention']
nemo_automodel.components.models.hy_v4_flash.config.EngramHeadVocabSizes: TypeAlias = dict[str, list[list[int]]]
nemo_automodel.components.models.hy_v4_flash.config.JsonValue: TypeAlias = 'str | int | float | bool | None | list[JsonValue] | dict[str, JsonValue]'
nemo_automodel.components.models.hy_v4_flash.config.MlpType: TypeAlias = Literal['dense', 'sparse']
nemo_automodel.components.models.hy_v4_flash.config._LAYER_TYPE_ALIASES: dict[str, AttentionType] = {'deepseek_sparse_attention': 'indexed_attention', 'indexed_attention': 'indexed...
nemo_automodel.components.models.hy_v4_flash.config._RELEASED_LAYER_TYPE = {'indexed_attention': 'deepseek_sparse_attention', 'sliding_attention': 'sliding...