Skip to content

[OMNIML-2917] handle lm_head and other un-quantized modules correctly - #504

Merged
shengliangxu merged 12 commits into
mainfrom
shengliangx/handle-lm-head
Nov 14, 2025
Merged

shengliangxu merged 12 commits into
mainfrom
shengliangx/handle-lm-head

Conversation

@shengliangxu

Copy link
Copy Markdown
Collaborator

What does this PR do?

Type of change:

Bug fix.

Overview:

This is change set 2 from working on OMNIML-2917.

Two correlated changes:

  1. when we just quantize the langauge_model submodule, correctly disable quantization of all other modules, we do not need to hard code anything

  2. When we export quantized model to hf unified format, we hard code the exclusion of "lm_head". With the change set 1 where we use the full model for export config generation, we can natually exclude lm_head if it is not quantized. Therefore, remove the hard coded lm_head inclusion in the exclusion list.

Testing

Correctly exported Llama 3.1 70B, Qwen3 VL MoE, Nemotron Super, Llama4 Scout

This is change set 2 from working on OMNIML-2917.

Two correlated changes:

1. when we just quantize the langauge_model submodule, correctly disable
   quantization of all other modules, we do not need to hard code
   anything

2. When we export quantized model to hf unified format, we hard code the
   exclusion of "lm_head". With the change set 1 where we use the full
   model for export config generation, we can natually exclude lm_head
   if it is not quantized. Therefore, remove the hard coded lm_head
   inclusion in the exclusion list.

Signed-off-by: Shengliang Xu <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Nov 4, 2025

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@codecov

codecov Bot commented Nov 4, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.37%. Comparing base (8188a01) to head (97c786d).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #504   +/-   ##
=======================================
  Coverage   74.37%   74.37%           
=======================================
  Files         182      182           
  Lines       18219    18219           
=======================================
  Hits        13550    13550           
  Misses       4669     4669           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shengliangxu
shengliangxu marked this pull request as ready for review November 4, 2025 17:52
@shengliangxu
shengliangxu requested review from a team as code owners November 4, 2025 17:52

@Edwardf0t1 Edwardf0t1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, left a few minor comments.

Also, could we also test the Nemotron-Nano-VL v2 model: https://huggingface.co/nvidia/NVIDIA-Nemotron-Nano-12B-v2-VL-BF16?

Comment thread modelopt/torch/export/model_utils.py Resolved
Comment thread modelopt/torch/export/model_utils.py Resolved
Signed-off-by: Shengliang Xu <[email protected]>
@shengliangxu

Copy link
Copy Markdown
Collaborator Author

LGTM, left a few minor comments.

Also, could we also test the Nemotron-Nano-VL v2 model: https://huggingface.co/nvidia/NVIDIA-Nemotron-Nano-12B-v2-VL-BF16?

Have a successful run with the excluded modules in config:

        "ignore": [
            "language_model.backbone.layers.0.mixer.conv1d",
            "language_model.backbone.layers.11.mixer.conv1d",
            "language_model.backbone.layers.13.mixer.conv1d",
            "language_model.backbone.layers.15.mixer.conv1d",
            "language_model.backbone.layers.18.mixer.conv1d",
            "language_model.backbone.layers.2.mixer.conv1d",
            "language_model.backbone.layers.20.mixer.conv1d",
            "language_model.backbone.layers.22.mixer.conv1d",
            "language_model.backbone.layers.24.mixer.conv1d",
            "language_model.backbone.layers.27.mixer.conv1d",
            "language_model.backbone.layers.29.mixer.conv1d",
            "language_model.backbone.layers.31.mixer.conv1d",
            "language_model.backbone.layers.33.mixer.conv1d",
            "language_model.backbone.layers.36.mixer.conv1d",
            "language_model.backbone.layers.38.mixer.conv1d",
            "language_model.backbone.layers.4.mixer.conv1d",
            "language_model.backbone.layers.40.mixer.conv1d",
            "language_model.backbone.layers.42.mixer.conv1d",
            "language_model.backbone.layers.45.mixer.conv1d",
            "language_model.backbone.layers.47.mixer.conv1d",
            "language_model.backbone.layers.49.mixer.conv1d",
            "language_model.backbone.layers.51.mixer.conv1d",
            "language_model.backbone.layers.54.mixer.conv1d",
            "language_model.backbone.layers.56.mixer.conv1d",
            "language_model.backbone.layers.58.mixer.conv1d",
            "language_model.backbone.layers.6.mixer.conv1d",
            "language_model.backbone.layers.60.mixer.conv1d",
            "language_model.backbone.layers.9.mixer.conv1d",
            "language_model.lm_head",
            "mlp1*",
            "vision_model*"
        ],

Note the "language_model.lm_head" line, it is correct while the previous code will have a line of "lm_head", which is in fact incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants