interplane.Get Omega
Read in your language

aien-yardsticks

aien-dev/aien-yardsticks

Brought by drakestapleton

branch main Branches Tags History

aien-yardsticks / yardsticks / modular-nemotron-h-kvexp / model.py

33 lines · 1108 bytes Raw Blame History
1"""Pipeline model subclass that uses the KV-expanded config."""
2
3from __future__ import annotations
4
5from typing import Any
6
7from max.graph import DeviceRef
8from max.pipelines.architectures.nemotron_h.model import NemotronHModel
9
10from .config import KvExpandedNemotronHConfig
11
12
13class KvExpandedNemotronHModel(NemotronHModel):
14 """NemotronHModel whose config replicates KV heads (GQA group <= 8).
15
16 The built-in ``_create_model_config`` hardcodes ``NemotronHConfig.from_hf``,
17 so we must override it to route through the expanded config. Everything else
18 (graph build, state pools, batching) is inherited unchanged.
19 """
20
21 model_config_cls = KvExpandedNemotronHConfig
22
23 def _create_model_config(self, state_dict: dict[str, Any]):
24 device_ref = DeviceRef.from_device(self.devices[0])
25 model_config = KvExpandedNemotronHConfig.from_hf(
26 self.pipeline_config,
27 self.huggingface_config,
28 self.dtype,
29 self.kv_params,
30 [device_ref],
31 )
32 model_config.populate_fp8_layers(state_dict)
33 return model_config