YARDSTICK ONLY. Never part of AIEN. Nothing here ships in AIEN.
This is the Nemotron-H KV-head-expansion comparison adapter for Modular MAX, kept so AIEN can be measured against MAX. Modular MAX was removed from AIEN on 2026-10-15. This adapter is a frozen record only and is no longer run; the install, serve and test steps below are historical, so do not follow them. It was moved here, with its git history, from
aien-dev/aien-sovereign-core(commit5fdab70, pathmodular/nemotron_h_kvexp) because AIEN repos may contain no Python. The Python in this folder is scheduled for replacement by Rust (see the "Replace the Python yardstick with Rust" issue in this repo).
KV-Head Expanded Nemotron-H Architecture for Modular MAX
Custom architecture adapter enabling high-throughput serving of NVIDIA Nemotron-H models (such as nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-BF16) on Modular MAX.
Architecture Rationale
Modular MAX employs optimized FlashAttention kernels for Grouped-Query Attention (GQA). In current MAX versions, the maximum supported GQA group size is 8 (group = num_attention_heads / num_key_value_heads <= 8).
Nemotron-3.5-Lightning-30B utilizes a GQA configuration where:
- Query heads (
n_heads): 32 - Key-Value heads (
n_kv): 2 - GQA group ratio: 32 / 2 = 16
Because 16 > 8, loading the standard checkpoint triggers an unsupported group size error in the MAX attention kernel.
This adapter resolves the kernel limitation by calculating the minimum integer expansion factor:
expansion = math.ceil((n_heads / n_kv) / MAX_NVIDIA_GQA_GROUP)
For Nemotron-H (group 16), expansion = 2. Each KV head is replicated across the channel dimension during state dictionary weight loading:
- Replicated KV heads: 2 * 2 = 4
- Effective GQA group ratio: 32 / 4 = 8
This satisfies the FlashAttention kernel constraint without altering model activations, attention math, or output distributions.
Key Features
- Native Dynamic Expansion: Replicates KV heads on the fly during safe tensor loading and state dict conversion.
- Offline PEFT LoRA Folding: Set
ATLAS_LORA_DIRto fold LoRA adapters (A and B matrices) directly into base weights prior to QKV fusion, eliminating runtime LoRA overhead. - Lazy Registration Override: Overrides default
NemotronHForCausalLMregistration within the MAX pipeline registry to ensure transparent resolution from standard model checkpoints.
Installation & Usage
Install as an editable package:
pip install -e .
Serve using the MAX CLI:
max serve \
--model nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-BF16 \
--served-model-name nemotron-lightning \
--custom-architectures $(pwd) \
--port 18006 \
--max-batch-size 8 \
--max-length 32768 \
--kv-cache-format bfloat16
Testing
Run unit tests via standard Python unittest:
python3 -m unittest discover -s tests -v
License
Licensed under the Apache License, Version 2.0.
Benchmarks (NVIDIA DGX Spark / Grace Blackwell GB10)
Benchmarked on ARM64 Grace Neoverse V2 cores using realistic Nemotron-30B layer dimensions (4608x4096 expanded to 5120x4096):
| Metric | Measured Value |
|---|---|
| Latency per Layer | 5.49 ms |
| Full Model Expansion (52 layers) | 285.63 ms |
| Memory Copy Throughput | 12.80 GB/s |
Load-time expansion overhead is under 300 ms for the entire 30B model, introducing negligible startup delay while enabling high-throughput serving on Modular MAX.