Skip to content

Conversation

@ajrasane
Copy link
Contributor

@ajrasane ajrasane commented Dec 5, 2025

What does this PR do?

Type of change:
New Feature

Overview:

  • Enable ONNX export for auto quantized models
  • Update documentation and changelog

Usage

python torch_quant_to_onnx.py --quantize_mode=auto \
	--onnx_save_path=./vit_base_patch16_224.nvfp4_fp8.onnx \
	--calibration_data_size 64 \
	--auto_quantization_formats NVFP4_AWQ_LITE_CFG FP8_DEFAULT_CFG \
	--batch_size 128

Testing

python evaluate.py --onnx_path=vit_base_patch16_224.nvfp4_fp8.onnx \
	--model_name=vit_base_patch16_224 \
	--results_path=./results.txt \
	--batch_size 128

Accuracy results

The top1 accuracy of the model is 84.15%
The top5 accuracy of the model is 97.396%

Reference accuracy for fp16

The top1 accuracy of the model is 85.102%
The top5 accuracy of the model is 97.526%

Before your PR is "Ready for review"

  • Make sure you read and follow Contributor guidelines and your commits are signed.
  • Is this change backward compatible?: Yes
  • Did you write any new necessary tests?: No
  • Did you add or update any necessary documentation?: Yes
  • Did you update Changelog?: Yes

@ajrasane ajrasane requested review from a team as code owners December 5, 2025 22:38
@codecov
Copy link

codecov bot commented Dec 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.46%. Comparing base (53a2dde) to head (6c9f7b1).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #656      +/-   ##
==========================================
- Coverage   74.50%   74.46%   -0.05%     
==========================================
  Files         183      183              
  Lines       18400    18415      +15     
==========================================
+ Hits        13709    13712       +3     
- Misses       4691     4703      +12     

☔ 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.

@ajrasane ajrasane force-pushed the ajrasane/mixed_precision_e2e branch from 23e00a2 to f403387 Compare December 8, 2025 21:07
@gcunhase
Copy link
Contributor

gcunhase commented Dec 9, 2025

We should add perf and accuracy numbers for the baseline and quantized models in the README file as well.

@vishalpandya1990
Copy link
Contributor

A basic query: Is onnx_ptq the right place of "PyTorch PTQ => ONNX export" examples? I was under the impression that onnx_ptq exemplifies PTQ techniques for input ONNX models.

@gcunhase
Copy link
Contributor

gcunhase commented Dec 9, 2025

A basic query: Is onnx_ptq the right place of "PyTorch PTQ => ONNX export" examples? I was under the impression that onnx_ptq exemplifies PTQ techniques for input ONNX models.

Right now, onnx_ptq includes PyTorch PTQ => ONNX examples as well, but I agree that it might be better to separate those 2 workflows. WDYT @ajrasane?

Signed-off-by: ajrasane <[email protected]>
@ajrasane ajrasane requested a review from a team as a code owner December 9, 2025 23:54
@ajrasane ajrasane force-pushed the ajrasane/mixed_precision_e2e branch from 0211848 to 9758f0c Compare December 10, 2025 00:00
@ajrasane ajrasane requested a review from a team as a code owner December 10, 2025 00:00
@kevalmorabia97
Copy link
Collaborator

You'll need to change test from onnx_ptq to torch_onnx as well in https://github.com/NVIDIA/Model-Optimizer/blob/main/.github/workflows/example_tests.yml#L119-L147 since we dont have any other onnx_ptq test remaining after this change

@kevalmorabia97 kevalmorabia97 removed the request for review from vishalpandya1990 December 10, 2025 05:43
@ajrasane ajrasane force-pushed the ajrasane/mixed_precision_e2e branch from 9758f0c to ee0d90f Compare December 10, 2025 21:26
| :--- | :---: | :---: |
| Torch autocast (FP16) | 85.11% | 97.53% |
| NVFP4 Quantized | 84.558% | 97.36% |
| Auto Quantized (FP8 + NVFP4, 4.78 effective bits) | 84.726% | 97.434% |
Copy link
Contributor

Choose a reason for hiding this comment

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

NVFP4 Quantized is NVFP4 + FP16-AutoCast? Same question for Auto Quantized.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

Copy link
Contributor

@gcunhase gcunhase left a comment

Choose a reason for hiding this comment

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

Thanks for dividing the examples into 2 folders.

I posted a couple more comments and we'd still need to add the perf numbers to show the accuracy-runtime trade-offs.

Approving for now.

@ajrasane ajrasane force-pushed the ajrasane/mixed_precision_e2e branch from ee0d90f to 11de7ce Compare December 11, 2025 06:13
@ajrasane ajrasane enabled auto-merge (squash) December 11, 2025 06:14
@ajrasane ajrasane force-pushed the ajrasane/mixed_precision_e2e branch from 11de7ce to 6c9f7b1 Compare December 11, 2025 06:22
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.

6 participants