> This page is for version 0.4.0 · 26.04.
> For other versions, use one of these documentation indexes:
> - Nightly (default): https://docs.nvidia.com/nemo/automodel/nightly/llms.txt
> - Latest: https://docs.nvidia.com/nemo/automodel/latest/llms.txt
> - 0.7.0 · 26.10: https://docs.nvidia.com/nemo/automodel/v0.7/llms.txt
> - 0.5.0 · 26.06: https://docs.nvidia.com/nemo/automodel/v0.5/llms.txt
> - 0.4.0 · 26.04: https://docs.nvidia.com/nemo/automodel/v0.4/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/automodel/llms.txt.

# nemo_automodel.components.models.hy_v4_flash.config

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

| Name                                                                                                      | Description                                                                                           |
| --------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| [`HYV4FlashConfig`](#nemo_automodel-components-models-hy_v4_flash-config-HYV4FlashConfig)                 | Composite image-text configuration (`HYV4FlashForConditionalGeneration`).                             |
| [`HYV4FlashRopeParameters`](#nemo_automodel-components-models-hy_v4_flash-config-HYV4FlashRopeParameters) | Rotary parameters of one attention type, as stored in `rope_parameters`.                              |
| [`HYV4FlashTextConfig`](#nemo_automodel-components-models-hy_v4_flash-config-HYV4FlashTextConfig)         | Text backbone: hyper-connected gated MLA with SWA / compressed-indexer layers, latent MoE and Engram. |
| [`HYV4FlashVisionConfig`](#nemo_automodel-components-models-hy_v4_flash-config-HYV4FlashVisionConfig)     | Vision tower hyper-parameters (a 27-layer ViT plus the `rmsnorm_mlp_adapter` projector).              |

### Functions

| Name                                                                                | Description                                                                  |
| ----------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| [`_model_flops`](#nemo_automodel-components-models-hy_v4_flash-config-_model_flops) | Call the FLOPs formula, imported on use because `flops` imports this module. |

### Data

[`AttentionType`](#nemo_automodel-components-models-hy_v4_flash-config-AttentionType)

[`EngramHeadVocabSizes`](#nemo_automodel-components-models-hy_v4_flash-config-EngramHeadVocabSizes)

[`JsonValue`](#nemo_automodel-components-models-hy_v4_flash-config-JsonValue)

[`MlpType`](#nemo_automodel-components-models-hy_v4_flash-config-MlpType)

[`_LAYER_TYPE_ALIASES`](#nemo_automodel-components-models-hy_v4_flash-config-_LAYER_TYPE_ALIASES)

[`_RELEASED_LAYER_TYPE`](#nemo_automodel-components-models-hy_v4_flash-config-_RELEASED_LAYER_TYPE)

### API

```python
class nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashConfig(
    text_config: dict[str, nemo_automodel.components.models.hy_v4_flash.config.JsonValue] | nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashTextConfig | None = None,
    vision_config: dict[str, nemo_automodel.components.models.hy_v4_flash.config.JsonValue] | nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashVisionConfig | None = None,
    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,
    kwargs: nemo_automodel.components.models.hy_v4_flash.config.JsonValue = {}
)
```

**Bases:** `PretrainedConfig`

Composite image-text configuration (`HYV4FlashForConditionalGeneration`).

**`model_type`** `= 'hy_v4_flash'`

---

**`sub_configs`**

---

**`text_config`**

---

**`vision_config`**

---

```python
nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashConfig.flops_formula(
    config: nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashConfig,
    gbs: int = 1,
    seq_len: int | None = None
) -> float
```

staticmethod

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

```python
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']`

---

```python
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,
    mlp_layer_types: list[nemo_automodel.components.models.hy_v4_flash.config.MlpType] | None = None,
    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,
    rope_parameters: dict[str, nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashRopeParameters] | None = None,
    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_layer_head_vocab_sizes: nemo_automodel.components.models.hy_v4_flash.config.EngramHeadVocabSizes | None = None,
    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,
    kwargs: nemo_automodel.components.models.hy_v4_flash.config.JsonValue = {}
)
```

**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`**

---

```python
nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashTextConfig._validate() -> None
```

```python
nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashTextConfig.attention_dims(
    attention_type: nemo_automodel.components.models.hy_v4_flash.config.AttentionType
) -> tuple[int, int, int]
```

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

```python
nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashTextConfig.attention_heads(
    attention_type: nemo_automodel.components.models.hy_v4_flash.config.AttentionType
) -> int
```

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

```python
nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashTextConfig.flops_formula(
    config: nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashTextConfig,
    gbs: int = 1,
    seq_len: int | None = None
) -> float
```

staticmethod

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

```python
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',
    kwargs: nemo_automodel.components.models.hy_v4_flash.config.JsonValue = {}
)
```

**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'`

---

```python
nemo_automodel.components.models.hy_v4_flash.config._model_flops(
    config: nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashTextConfig | nemo_automodel.components.models.hy_v4_flash.config.HYV4FlashConfig,
    gbs: int,
    seq_len: int | None
) -> float
```

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

```python
nemo_automodel.components.models.hy_v4_flash.config.AttentionType: TypeAlias = Literal['indexed_attention', 'sliding_attention']
```

```python
nemo_automodel.components.models.hy_v4_flash.config.EngramHeadVocabSizes: TypeAlias = dict[str, list[list[int]]]
```

```python
nemo_automodel.components.models.hy_v4_flash.config.JsonValue: TypeAlias = 'str | int | float | bool | None | list[JsonValue] | dict[str, JsonValue]'
```

```python
nemo_automodel.components.models.hy_v4_flash.config.MlpType: TypeAlias = Literal['dense', 'sparse']
```

```python
nemo_automodel.components.models.hy_v4_flash.config._LAYER_TYPE_ALIASES: dict[str, AttentionType] = {'deepseek_sparse_attention': 'indexed_attention', 'indexed_attention': 'indexed...
```

```python
nemo_automodel.components.models.hy_v4_flash.config._RELEASED_LAYER_TYPE = {'indexed_attention': 'deepseek_sparse_attention', 'sliding_attention': 'sliding...
```