interplane.Get Omega
Read in your language

aien-sovereign-core

Autonomous sovereign intelligence engine and runtime core for NVIDIA DGX Spark

Brought by drakestapleton

branch main Branches Tags History

aien-sovereign-core / 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
3from .arch import kvexp_arch
4from .model import KvExpandedNemotronHModel
5
6ARCHITECTURES = [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.
15try:
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
31except Exception:
32 pass