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/__init__.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 / __init__.py` 32 lines ยท 1333 bytes Raw Blame History 1 """KV-head-expanded Nemotron-H adapter for MAX (see config.py for rationale).""" 2 3 from .arch import kvexp_arch 4 from .model import KvExpandedNemotronHModel 5 6 ARCHITECTURES = [kvexp_arch] 7 8 # MAX registers built-in architectures *lazily*: ``register_lazy(name, ...)`` 9 # records a pending entry, and the first lookup calls ``_materialize_lazy`` -> 10 # ``register(builtin)`` WITHOUT ``allow_override``. Since our arch already 11 # registered under the same name, that raises: 12 # "Refusing to override existing architecture for 'NemotronHForCausalLM'". 13 # We are imported before materialization, so wrap ``register`` to ignore the 14 # built-in re-registration for this name and keep ours. 15 try: 16 from max.pipelines import PIPELINE_REGISTRY 17 18 _orig_register = PIPELINE_REGISTRY.register 19 20 def _register_kvexp_aware(architecture, *args, **kwargs): 21 if ( 22 architecture.name == "NemotronHForCausalLM" 23 and architecture.pipeline_model is not KvExpandedNemotronHModel 24 and (architecture.name, architecture.task) in PIPELINE_REGISTRY._architectures_by_task 25 ): 26 # Built-in lazily materializing after our override; keep ours. 27 return 28 return _orig_register(architecture, *args, **kwargs) 29 30 PIPELINE_REGISTRY.register = _register_kvexp_aware 31 except Exception: 32 pass