Skip to content

Commit 8c5a927

Browse files
Minor fixes + updated tests and docs
Signed-off-by: Keval Morabia <[email protected]>
1 parent 46b099a commit 8c5a927

File tree

11 files changed

+200
-176
lines changed

11 files changed

+200
-176
lines changed

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Model Optimizer Changelog (Linux)
22
=================================
33

4+
0.40 (2025-12-xx)
5+
^^^^^^^^^^^^^^^^^
6+
7+
**New Features**
8+
9+
- Add MoE pruning support for ``num_moe_experts`` and ``moe_shared_expert_intermediate_size`` in Minitron pruning (``mcore_minitron``).
10+
411
0.39 (2025-11-07)
512
^^^^^^^^^^^^^^^^^
613

docs/source/guides/7_nas.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,8 @@ can be converted into searchable units:
363363
364364
# We convert Megatron-core / NeMo GPT or Mamba style models (e.g. Llama3.1, NeMo Mistral, NeMotron-H, etc.)
365365
# to automatically search over the MLP hidden size, number of attention heads, number of GQA groups,
366-
# number of mamba heads, mamba head dimension, and depth of the model.
366+
# number of mamba heads, mamba head dimension, MoE number of experts and shared expert intermediate size,
367+
# and depth of the model.
367368
megatron.core.models.gpt.GPTModel
368369
megatron.core.models.mamba.MambaModel
369370
nemo.collections.llm.gpt.model.base.GPTModel
@@ -640,7 +641,7 @@ The difference between NAS and pruning is summarized below.
640641
[Advanced] Adding a new NAS/Prune Algorithm
641642
===========================================
642643

643-
* Please refer to this `template <https://github.com/NVIDIA/TensorRT-Model-Optimizer/compare/template/new-nas-mode>`_
644+
* Please refer to this `template <https://github.com/NVIDIA/TensorRT-Model-Optimizer/compare/template/new-nas-mode>`_
644645
for adding a new NAS algorithm.
645646
* Please refer to `mcore_minitron.py <https://github.com/NVIDIA/TensorRT-Model-Optimizer/blob/main/modelopt/torch/prune/plugins/mcore_minitron.py>`_
646647
for an actual example of adding Minitron Pruning algorithm.

examples/pruning/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Pruning can involve removal (prune) of Linear and Conv layers, and Transformer a
66

77
This section focuses on applying Model Optimizer's state-of-the-art complementary pruning modes to enable you to search for the best subnet architecture from your provided base model:
88

9-
1. [Minitron](https://arxiv.org/pdf/2408.11796): A pruning method developed by NVIDIA Research for pruning GPT, Mamba and Hybrid Transformer Mamba models in NVIDIA NeMo or Megatron-LM framework. It uses the activation magnitudes to prune the embedding hidden size, mlp ffn hidden size, transformer attention heads, GQA query groups, mamba heads and head dimension, and number of layers of the model.
9+
1. [Minitron](https://arxiv.org/pdf/2408.11796): A pruning method developed by NVIDIA Research for pruning GPT, Mamba and Hybrid Transformer Mamba models in NVIDIA NeMo or Megatron-LM framework. It uses the activation magnitudes to prune the embedding hidden size, mlp ffn hidden size, transformer attention heads, GQA query groups, mamba heads and head dimension, MoE number of experts and shared expert intermediate size, and number of layers of the model.
1010
1. FastNAS: A pruning method recommended for Computer Vision models. Given a pretrained model, FastNAS finds the subnet which maximizes the score function while meeting the given constraints.
1111
1. GradNAS: A light-weight pruning method recommended for language models like Hugging Face BERT, GPT-J. It uses the gradient information to prune the model's linear layers and attention heads to meet the given constraints.
1212

@@ -89,11 +89,11 @@ If your model parameters are already sorted, you can skip the sorting step by se
8989

9090
| **Algorithm** | **Model** | **Pruning Constraints** |
9191
| :---: | :---: | :---: |
92-
| Minitron | Megatron-core / NeMo based GPT / Mamba / Hybrid Models<sup>1</sup> | Export config with width (`hidden_size`, `ffn_hidden_size`, `num_attention_heads`, `num_query_groups`, `mamba_num_heads`, `mamba_head_dim`) and/or depth (`num_layers`) values |
92+
| Minitron | Megatron-core / NeMo based GPT / Mamba / MoE / Hybrid Models<sup>1</sup> | Export config with width (`hidden_size`, `ffn_hidden_size`, `num_attention_heads`, `num_query_groups`, `mamba_num_heads`, `mamba_head_dim`, `num_moe_experts`, `moe_shared_expert_intermediate_size`) and/or depth (`num_layers`) values |
9393
| FastNAS | Computer Vision models | flops, parameters |
9494
| GradNAS | HuggingFace BERT, GPT-J | flops, parameters |
9595

96-
> *<sup>1.</sup>Only Pipeline Parallel models are supported. Hugging Face models can be converted to NeMo format and used subsequently.*
96+
> *<sup>1.</sup>Only Pipeline Parallel models are supported. Hugging Face models can be converted to Megatron-LM/NeMo format and used subsequently.*
9797
9898
## Pruning Guidelines
9999

@@ -122,7 +122,7 @@ Depth pruning reduces the number of layers (`num_layers`) in the model.
122122

123123
#### Width Pruning
124124

125-
Width pruning reduces model dimensions per layer such as `hidden_size`, `ffn_hidden_size`, `num_attention_heads`, `num_query_groups`, `mamba_num_heads`, and `mamba_head_dim`.
125+
Width pruning reduces model dimensions per layer such as `hidden_size`, `ffn_hidden_size`, `num_attention_heads`, `num_query_groups`, `mamba_num_heads`, `mamba_head_dim`, `num_moe_experts`, and `moe_shared_expert_intermediate_size`.
126126

127127
**Advantages:**
128128

0 commit comments

Comments
 (0)