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

torch.save fails with pickling error on mct quantized model #841

Closed
irenaby opened this issue Oct 24, 2023 · 0 comments · Fixed by #861
Closed

torch.save fails with pickling error on mct quantized model #841

irenaby opened this issue Oct 24, 2023 · 0 comments · Fixed by #861
Assignees

Comments

@irenaby
Copy link
Collaborator

irenaby commented Oct 24, 2023

Issue Type

Bug

Source

pip (model-compression-toolkit)

MCT Version

1.10.0

OS Platform and Distribution

Ubuntu 20.04

Python version

3.10

Describe the issue

torch.save fails with pickling error on mct quantized model

Expected behaviour

No response

Code to reproduce the issue

import torch
import torchvision as tv
import model_compression_toolkit as mct

model = tv.models.get_model('alexnet')
model.eval()
def gen():
    yield [torch.rand(1, 3, 224, 224)]
qmodel, qinfo = mct.ptq.pytorch_post_training_quantization_experimental(model, gen)
torch.save(qmodel, '/tmp/qmodel.pt')

Log output

Traceback (most recent call last):
  File "/Vols/vol_design/tools/swat/users/irenab/ml-frameworks-uni-converter/uni/fx_rename/fx_parser/tests/mct_bug.py", line 37, in <module>
    torch.save(qmodel, '/tmp/qmodel.pt')
  File "/data/projects/swat/envs/irenab/py3.10_torch2.0/lib/python3.10/site-packages/torch/serialization.py", line 441, in save
    _save(obj, opened_zipfile, pickle_module, pickle_protocol)
  File "/data/projects/swat/envs/irenab/py3.10_torch2.0/lib/python3.10/site-packages/torch/serialization.py", line 653, in _save
    pickler.dump(obj)
_pickle.PicklingError: Can't pickle <function <lambda> at 0x7fb0557251b0>: attribute lookup <lambda> on model_compression_toolkit.core.pytorch.default_framework_info failed
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