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 / arch.py

48 lines · 1963 bytes Raw Blame History
1"""Register the KV-expanded Nemotron-H architecture (overrides the built-in)."""
2
3from __future__ import annotations
4
5from max.graph.weights import WeightsFormat
6from max.pipelines.context import TextContext
7from max.pipelines.lib import SupportedArchitecture
8from max.pipelines.modeling.types import PipelineTask
9
10# Nemotron-3's chat template is Qwen-format; importing the qwen3_5 parsers here
11# registers the "qwen3_5" reasoning/tool parsers the architecture names below.
12from max.pipelines.architectures.qwen3_5.reasoning import ( # noqa: F401
13 Qwen3_5ReasoningParser,
14)
15from max.pipelines.architectures.qwen3_5.tool_parser import ( # noqa: F401
16 Qwen3_5ToolParser,
17)
18from max.pipelines.architectures.nemotron_h.tokenizer import NemotronHTokenizer
19
20from .config import KvExpandedNemotronHConfig
21from .model import KvExpandedNemotronHModel
22from .weight_adapters import convert_kvexp_nemotron_h_state_dict
23
24kvexp_arch = SupportedArchitecture(
25 # Same name as the built-in -> allowed to override so the checkpoint's
26 # config.json architectures[0] == "NemotronHForCausalLM" resolves here.
27 name="NemotronHForCausalLM",
28 task=PipelineTask.TEXT_GENERATION,
29 example_repo_ids=[
30 "nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-BF16",
31 ],
32 default_weights_format=WeightsFormat.safetensors,
33 default_encoding=KvExpandedNemotronHConfig.DEFAULT_ENCODING,
34 supported_encodings=KvExpandedNemotronHConfig.SUPPORTED_ENCODINGS,
35 pipeline_model=KvExpandedNemotronHModel,
36 tokenizer=NemotronHTokenizer,
37 context_type=TextContext,
38 weight_adapters={
39 WeightsFormat.safetensors: convert_kvexp_nemotron_h_state_dict,
40 },
41 # SSM recurrent state is not reconstructable from a token prefix.
42 required_arguments={"enable_prefix_caching": False},
43 config=KvExpandedNemotronHConfig,
44 multi_gpu_supported=False,
45 reasoning_parser="qwen3_5",
46 tool_parser="qwen3_5",
47 supports_device_graph_capture=True,
48)