Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-yardsticks/blob/main/yardsticks/modular-nemotron-h-kvexp/model.py # aien-yardsticks aien-dev/aien-yardsticks Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers 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 3 from __future__ import annotations 4 5 from typing import Any 6 7 from max.graph import DeviceRef 8 from max.pipelines.architectures.nemotron_h.model import NemotronHModel 9 10 from .config import KvExpandedNemotronHConfig 11 12 13 class 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