mit-han-lab / torchquantum

A PyTorch-based framework for Quantum Classical Simulation, Quantum Machine Learning, Quantum Neural Networks, Parameterized Quantum Circuits with support for easy deployments on real quantum computers.
https://torchquantum.org
MIT License
1.3k stars 197 forks source link

ImportError: cannot import name 'SetLayer0' from 'torchquantum.layer' #196

Closed manu123416 closed 7 months ago

manu123416 commented 1 year ago

I am getting an import error as below: ImportError: cannot import name 'SetLayer0' from 'torchquantum.layer' https://github.com/mit-han-lab/torchquantum/blob/main/examples/param_shift_onchip_training/param_shift.py Please help me in resolving the error.

GenericP3rson commented 11 months ago

Hi! It seems like a typo, trying to import "SetLayer0" instead of "SethLayer0". However, I can't quite replicate at the moment. Is it resolved or are you still running into that issue? If you are still running into the issue, does changing SetLayer0 to SethLayer0 resolve it?

GenericP3rson commented 10 months ago

Hey! I looked into this bug a bit more. For now, if you change the import to from torchquantum.layer.layers import SethLayer0, it should temporarily fix the issue. I’ve also added a more permanent fix in https://github.com/mit-han-lab/torchquantum/pull/206; once the PR is merged, the code should run as is!

Thanks for opening this issue, and feel free to reach out if you have any additional questions!

GenericP3rson commented 7 months ago

I’m marking this as resolved as it should be fixed in the most recent release! Feel free to reach out with any other questions!