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

[Fix] QNG optimizer not compatible with qadence training function #21

Open
DanieleCucurachi opened this issue Jun 18, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@DanieleCucurachi
Copy link
Collaborator

Description

QNG has been recently added to qinfo_tools. While it works smoothly with simple training loops, as shown here, it is not compatible with train(), function defined in qadence to automate the definition of the training process with gradient-based optimizers.

In particular, the error seems to be related to Python's pickle module having trouble pickling a local object:

Traceback (most recent call last):
  File ".../qadence/ml_tools/saveload.py", line 76, in write_checkpoint
    torch.save(
  File ".../torch/serialization.py", line 628, in save
    _save(obj, opened_zipfile, pickle_module, pickle_protocol, _disable_byteorder_record)
  File ".../torch/serialization.py", line 840, in _save
    pickler.dump(obj)
AttributeError: Can't pickle local object 'Parametric.__init__.<locals>.parse_values'
@DanieleCucurachi DanieleCucurachi added the bug Something isn't working label Jun 18, 2024
@inafergra
Copy link
Collaborator

inafergra commented Jun 18, 2024

Thanks for finding this @DanieleCucurachi. As discussed, I believe the issue is in the serialization of the optimizer's state_dict, as the QNG's state_dict holds a quantum circuit. We probably need to add some logic to correctly serialize it. I will take a look into it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants