nemo_automodel.components.models.qwen2.state_dict_adapter#

State dict adapter for Qwen2 model.

The model uses separate q/k/v and gate/up projections that match HuggingFace key names exactly, so the adapter is a passthrough (only tied-weight handling in from_hf).

Module Contents#

Classes#

Qwen2StateDictAdapter

State dict adapter for Qwen2 models.

Data#

API#

nemo_automodel.components.models.qwen2.state_dict_adapter.logger#

‘getLogger(…)’

class nemo_automodel.components.models.qwen2.state_dict_adapter.Qwen2StateDictAdapter(config: transformers.Qwen2Config)#

State dict adapter for Qwen2 models.

Uses separate projections that match HuggingFace key names exactly, so from_hf / to_hf are simple passthroughs (only tied-weight handling in from_hf).

.. rubric:: Example

from transformers import Qwen2Config

config = Qwen2Config.from_pretrained(“Qwen/Qwen2.5-7B”) adapter = Qwen2StateDictAdapter(config)

Convert HF checkpoint to custom format#

custom_state_dict = adapter.from_hf(hf_state_dict)

Convert custom checkpoint back to HF format#

hf_state_dict = adapter.to_hf(custom_state_dict)

Initialization

Initialize adapter with Qwen2 config.

from_hf(
hf_state_dict: dict[str, Any],
**kwargs,
) dict[str, Any]#
to_hf(
state_dict: dict[str, Any],
exclude_key_regex: Optional[str] = None,
**kwargs,
) dict[str, Any]#