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

Quantizing from cli using config file fails #1838

Open
jens-totemic opened this issue Apr 27, 2024 · 1 comment · May be fixed by #1865
Open

Quantizing from cli using config file fails #1838

jens-totemic opened this issue Apr 27, 2024 · 1 comment · May be fixed by #1865

Comments

@jens-totemic
Copy link

jens-totemic commented Apr 27, 2024

I'm running

onnxruntime quantize --onnx_model ONNX_MODEL --c ort_config.json  -o ONNX_MODEL_quantized

and this fails with

Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniconda/base/envs/rag/bin/optimum-cli", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/homebrew/Caskroom/miniconda/base/envs/rag/lib/python3.12/site-packages/optimum/commands/optimum_cli.py", line 163, in main
    service.run()
  File "/opt/homebrew/Caskroom/miniconda/base/envs/rag/lib/python3.12/site-packages/optimum/commands/onnxruntime/quantize.py", line 99, in run
    qconfig = ORTConfig.from_pretained(self.args.config).quantization
              ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'ORTConfig' has no attribute 'from_pretained'. Did you mean: 'from_pretrained'?

It looks like there's a typo in quantize.py. But unfortunately, even when fixing the misspelled function name, the command fails:

  File "/opt/homebrew/Caskroom/miniconda/base/envs/rag/lib/python3.12/site-packages/optimum/commands/optimum_cli.py", line 163, in main
    service.run()
  File "/opt/homebrew/Caskroom/miniconda/base/envs/rag/lib/python3.12/site-packages/optimum/commands/onnxruntime/quantize.py", line 102, in run
    q.quantize(save_dir=save_dir, quantization_config=qconfig)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/rag/lib/python3.12/site-packages/optimum/onnxruntime/quantization.py", line 310, in quantize
    use_qdq = quantization_config.is_static and quantization_config.format == QuantFormat.QDQ
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'is_static'

After investigating this further, the problem seems to be that the quantize( function is expecting a QuantizationConfig but instead a dict object is supplied. I didn't see a straight forward way how to convert the loaded dict into the required QuantizationConfig

@IlyasMoutawwakil
Copy link
Member

looking into it !

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 a pull request may close this issue.

2 participants