qutip / qutip-qip

The QuTiP quantum information processing package
https://qutip-qip.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
105 stars 63 forks source link

Generation QIR from QuTiP not working #188

Open PariaNaghavi opened 1 year ago

PariaNaghavi commented 1 year ago
          To provide an example for generating qir from qutip, I have been referring to the [documentations](https://qutip-qip.readthedocs.io/en/latest/qip-simulator.html?highlight=qir#import-and-export-quantum-circuits); However, I encountered some issues. Specifically, it appears that the current version of qutip-qip (0.3.0) does not provide access to the `.qir` attribute nor the `circuit_to_qir` function. When attempting to import the [qir.py](https://github.com/qutip/qutip-qip/blob/master/src/qutip_qip/qir.py) locally, it is missing dependency on `pyqir.parser` which is gone in the current version of pyqir (0.7.0). This may be due to version incompatibility between the two libraries with the recent updates. 

Next, I adjusted the code to use the pyqir-generator instead of the parser, but I reached the following error about SNOT gate “not implemented in the QIR base profile and may require a custom declaration".

To replicate: Please see here Current outcome: An error due to missing .qir attribute and circuit_to_qir function in qutip-qip version and the missing dependency pyqir.parser Expected outcome: To generate qir, as shown in docs Notes: I would appreciate any suggestions or insights that might help in addressing these issues. Please let me know if there is any additional information or assistance that I can provide to fix this issue. Environment: QuTiP-QIP version: 0.0.3 pyqir version: 0.7.0 Python version: 3.9

Originally posted by @PariaNaghavi in https://github.com/qutip/qutip-qip/issues/125#issuecomment-1382605820

BoxiLi commented 1 year ago

Hi @PariaNaghavi

Sorry for the delay.

Two points:

BoxiLi commented 1 year ago

@cgranade Is it ok to drop the support of 0.6 and only support 0.7? Or should we try to keep it working both for 0.7 and 0.6? It seems quite cumbersome to support both because it is not just a change of version but rather the packages pyqir-generator and pyqir-parser are replaced by pyqir.

PariaNaghavi commented 1 year ago

Thank you @BoxiLi.

BoxiLi commented 1 year ago

With these changes (https://github.com/BoxiLi/qutip-qip/commit/d24b7b6c60a680644ec0f10dc775373bde1f2788) on qir.py and replacing qutip.qip with qutip_qip. I'm able to run through most of your ipynb.

PariaNaghavi commented 1 year ago

Thank you for the updates to the file. When I attempted to execute the updated qir.py file, I encountered an import error for Measurement from qutip_qip.operations. Any hints on how I can resolve this? Screen Shot 2023-01-18 at 18 30 02

BoxiLi commented 1 year ago

You might be using an old version of the source code, not the one on the current master branch?

You can try from qutip_qip.circuit import Measurement, Gate.

PariaNaghavi commented 1 year ago

It works. Thank you! Just a gentle follow up, would you consider pushing the changes in qir.py on main?

BoxiLi commented 1 year ago

Yes, will soon make a PR on that.

BoxiLi commented 1 year ago

@cgranade Hi, could you maybe help us get the test updated for the new pyqir? I can get the code to work in (https://github.com/BoxiLi/qutip-qip/commit/d24b7b6c60a680644ec0f10dc775373bde1f2788) but have quite some difficulties updating the tests. It seems that the whole test file needs to be restructured because of the new interface?