Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to using Model Optimizer (formerly AMMO) in PTQ workflow #9178

Merged
merged 15 commits into from
May 15, 2024

Conversation

janekl
Copy link
Collaborator

@janekl janekl commented May 13, 2024

What does this PR do ?

Summary:

  • use Model Optimizer library (formerly AMMO) for LLM PTQ workflow
  • restore PTQ tests failing due to setting apply_rope_fusion = True by default
  • update documentation

Collection: NLP

Changelog

  • Add specific line by line info of high level changes in this PR.

Usage

  • You can potentially add a usage example below
# Add a code snippet demonstrating how to use this 

GitHub Actions CI

The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.

The GitHub Actions CI will run automatically when the "Run CICD" label is added to the PR.
To re-run CI remove and add the label again.
To run CI on an untrusted fork, a NeMo user with write access must first click "Approve and run".

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?
  • Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
    • Reviewer: Does the PR have correct import guards for all optional libraries?

PR Type:

  • New Feature
  • Bugfix
  • Documentation

If you haven't finished some of the above items you can still open "Draft" PR.

Who can review?

Anyone in the community is free to review the PR once the checks have passed.
Contributor guidelines contains specific people who can review PRs to various areas.

Additional Information

  • Related to # (issue)

@janekl janekl added Run CICD and removed Run CICD labels May 13, 2024
@janekl janekl changed the title Jlasek/ammo2modelopt Update to nvidia-modelopt in PTQ workflow May 13, 2024
@janekl janekl changed the title Update to nvidia-modelopt in PTQ workflow Update to using Model Optimizer (formerly AMMO) in PTQ workflow May 13, 2024
@@ -197,7 +202,7 @@ def forward_loop():
print(f"Calibrating batch {i}")
model.predict_step(batch, i)

model = atq.quantize(model, self.atq_config, forward_loop)
model = mtq.quantize(model, self.quant_cfg, forward_loop)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please note that def forward_loop(model): ... is recommended over def forward_loop(): ... and the latter one will be deprecated soon

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed

# AMMO installation
pip install nvidia-ammo~=0.9.0 --extra-index-url https://pypi.nvidia.com --no-cache-dir
# ModelOpt installation
pip install nvidia-modelopt[all]~=0.11.0 --extra-index-url https://pypi.nvidia.com --no-cache-dir
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe you dont need onnx or deployment dependencies here

Suggested change
pip install nvidia-modelopt[all]~=0.11.0 --extra-index-url https://pypi.nvidia.com --no-cache-dir
pip install nvidia-modelopt[torch]~=0.11.0 --extra-index-url https://pypi.nvidia.com --no-cache-dir

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@janekl janekl removed the Run CICD label May 13, 2024
pablo-garay
pablo-garay previously approved these changes May 14, 2024
Copy link
Collaborator

Choose a reason for hiding this comment

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

megatron_gpt_quantization may be a more appropriate and consistent name

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe.. WDYT @ericharper ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Background is that the script is supposed to support multiple models -- gpt, llama, gemma etc. by specifying decoder_type param -- so I decided to rename it megatron_llama_quantization.py -> megatron_quantization.py.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let's postpone final decision after merge as this name also is tied to the one used in NeMo-Launcher

@pablo-garay
Copy link
Collaborator

Can we look to merge this PR soon? @janekl @kevalmorabia97

@kevalmorabia97
Copy link
Collaborator

@pablo-garay no objection from my side. I don't have permissions to approve but this LGTM

janekl and others added 11 commits May 15, 2024 13:15
Signed-off-by: Jan Lasek <janek.lasek@gmail.com>
Signed-off-by: Jan Lasek <janek.lasek@gmail.com>
Signed-off-by: Jan Lasek <janek.lasek@gmail.com>
Signed-off-by: Jan Lasek <janek.lasek@gmail.com>
Signed-off-by: Jan Lasek <janek.lasek@gmail.com>
Signed-off-by: janekl <janekl@users.noreply.github.com>
Signed-off-by: Jan Lasek <janek.lasek@gmail.com>
Signed-off-by: Jan Lasek <janek.lasek@gmail.com>
Signed-off-by: Jan Lasek <janek.lasek@gmail.com>
Signed-off-by: Jan Lasek <janek.lasek@gmail.com>
Signed-off-by: Jan Lasek <janek.lasek@gmail.com>
janekl and others added 3 commits May 15, 2024 13:15
Signed-off-by: janekl <janekl@users.noreply.github.com>
Signed-off-by: Jan Lasek <janek.lasek@gmail.com>
Signed-off-by: Jan Lasek <janek.lasek@gmail.com>
Signed-off-by: Jan Lasek <janek.lasek@gmail.com>
@janekl janekl added Run CICD and removed Run CICD labels May 15, 2024
Copy link
Collaborator

@oyilmaz-nvidia oyilmaz-nvidia left a comment

Choose a reason for hiding this comment

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

LGTM.

@oyilmaz-nvidia oyilmaz-nvidia merged commit 6cb618a into main May 15, 2024
132 of 133 checks passed
@oyilmaz-nvidia oyilmaz-nvidia deleted the jlasek/ammo2modelopt branch May 15, 2024 13:01
pablo-garay pushed a commit that referenced this pull request May 15, 2024
* Update PTQ to use nvidia-modelopt

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Restore PTQ tests

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Update docs

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Comment on apply_rope_fusion

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Support for calibration PP > 1

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Apply isort and black reformatting

Signed-off-by: janekl <janekl@users.noreply.github.com>

* Fix cicd-main.yml indent

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Set data/tensor parallel groups

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Install only torch dependecies

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Follow up on recent modelopt changes

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Model support matrix

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Apply isort and black reformatting

Signed-off-by: janekl <janekl@users.noreply.github.com>

* Rename PTQ script as it should be model-agnostic

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Remove unused import

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Update setup instructions

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

---------

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>
Signed-off-by: janekl <janekl@users.noreply.github.com>
Co-authored-by: janekl <janekl@users.noreply.github.com>
BoxiangW pushed a commit to BoxiangW/NeMo that referenced this pull request Jun 5, 2024
…IA#9178)

* Update PTQ to use nvidia-modelopt

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Restore PTQ tests

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Update docs

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Comment on apply_rope_fusion

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Support for calibration PP > 1

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Apply isort and black reformatting

Signed-off-by: janekl <janekl@users.noreply.github.com>

* Fix cicd-main.yml indent

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Set data/tensor parallel groups

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Install only torch dependecies

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Follow up on recent modelopt changes

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Model support matrix

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Apply isort and black reformatting

Signed-off-by: janekl <janekl@users.noreply.github.com>

* Rename PTQ script as it should be model-agnostic

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Remove unused import

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Update setup instructions

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

---------

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>
Signed-off-by: janekl <janekl@users.noreply.github.com>
Co-authored-by: janekl <janekl@users.noreply.github.com>
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
rohitrango pushed a commit to rohitrango/NeMo that referenced this pull request Jun 25, 2024
…IA#9178)

* Update PTQ to use nvidia-modelopt

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Restore PTQ tests

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Update docs

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Comment on apply_rope_fusion

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Support for calibration PP > 1

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Apply isort and black reformatting

Signed-off-by: janekl <janekl@users.noreply.github.com>

* Fix cicd-main.yml indent

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Set data/tensor parallel groups

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Install only torch dependecies

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Follow up on recent modelopt changes

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Model support matrix

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Apply isort and black reformatting

Signed-off-by: janekl <janekl@users.noreply.github.com>

* Rename PTQ script as it should be model-agnostic

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Remove unused import

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

* Update setup instructions

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>

---------

Signed-off-by: Jan Lasek <janek.lasek@gmail.com>
Signed-off-by: janekl <janekl@users.noreply.github.com>
Co-authored-by: janekl <janekl@users.noreply.github.com>
@ko3n1g ko3n1g mentioned this pull request Jul 18, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants