-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
Qiskit Quantum Fourier Transform (QFT) circuits error out during conversion #2354
Comments
Hi @cosenal, I recently learned about Mitiq and Qiskit, and this issue related appears to be an opportunity for me. Can I contribute to this issue? |
Hi @DotandLog – You're welcome to start looking at the issue now, but just so you are aware, this issue will most likely make it into the selection of Mitiq Unitary Hack bounties. If you wait a week, you can be eligible for that. |
…ns.py to decompose a qiskit circuit to native gates if an error occured. A test with zne was added to test for this with the QFT gate.
Hello! I submitted a pull request and passed all the tests regarding this issue. This is my first open source contribution so I'm a bit new to how this works. Regarding documentation for this, I wasn't sure if anything needed to be updated since no new features were added |
@NnguyenHTommy No documentation is needed, since this is more like a bug fix. |
* Fixed issue #2354 where a fallback was addded to conversions.py to decompose a qiskit circuit to native gates if an error occured. A test with zne was added to test for this with the QFT gate. * added myself to the bottom of the authors file * Adjusted code to follow the comments that cosenal placed with previous pull request. Moved the exception catch from the from_qiskit() to the from_qasm() function as that function is more general and is called by from_qiskit(). Used a QasmException catch instead of Exception to make it more clear that Qasm has trouble converting Adjusted code to follow the comments that cosenal placed with previous pull request. Moved the exception catch from the from_qiskit() to the from_qasm() function as that function is more general and is called by from_qiskit(). Used a QasmException catch instead of Exception to make it more clear that Qasm has trouble converting different gates. Removed choosing a basis for the transpile and let qiskit decide what gates to use. Added an additional test case to test the from_qasm() function. * resolving second round of changes reviewed by cosenal! moved the exception catch to the from_qiskit() function from the from_qasm() function as from_qasm() can handle non-qiskit circuits. Switched the test case to test the from_qiskit() function in doing so. Also only decomposed rather than transpiling and decomposing as transpiling doesn't do anything. * renaming and added updated docstrings according to cosenal suggestions
* Fixed issue #2354 where a fallback was addded to conversions.py to decompose a qiskit circuit to native gates if an error occured. A test with zne was added to test for this with the QFT gate. * added myself to the bottom of the authors file * Adjusted code to follow the comments that cosenal placed with previous pull request. Moved the exception catch from the from_qiskit() to the from_qasm() function as that function is more general and is called by from_qiskit(). Used a QasmException catch instead of Exception to make it more clear that Qasm has trouble converting Adjusted code to follow the comments that cosenal placed with previous pull request. Moved the exception catch from the from_qiskit() to the from_qasm() function as that function is more general and is called by from_qiskit(). Used a QasmException catch instead of Exception to make it more clear that Qasm has trouble converting different gates. Removed choosing a basis for the transpile and let qiskit decide what gates to use. Added an additional test case to test the from_qasm() function. * resolving second round of changes reviewed by cosenal! moved the exception catch to the from_qiskit() function from the from_qasm() function as from_qasm() can handle non-qiskit circuits. Switched the test case to test the from_qiskit() function in doing so. Also only decomposed rather than transpiling and decomposing as transpiling doesn't do anything. * renaming and added updated docstrings according to cosenal suggestions
If a Qiskit input circuit is composed of a QFT subcircuit, it errors out once it's executed with error mitigation techniques.
Minimum non-working snippet (adapted from #558 to comply with Qiskit 1.0):
Error:
Traceback:
This is somehow different from #558 and #1073, which were raised on versions of Qiskit pre-1.0, and where the error was about unsupported gates.
One workaround is to either decompose or transpile the circuit before it's passed as an argument to quantum error mitigation routines (see commented lines in the snippet above)1. At the moment, this workaround is not explicit to the user, so we could implement a fallback mechanism in Mitiq interface, where a circuit gets decomposed or transpiled whenever the conversion to the internal representation fails.
This issue is only about Qiskit circuits, but in the future the mechanism implemented could be generalized to other frontends.
Footnotes
note that decomposing the circuit is necessary also inside the executor for running the circuit on the simulator. However, that's not sufficient, because in error-mitigation routines (e.g.
execute_with_zne
) the conversion to Mitiq circuits happens before the body of the executor is run. ↩The text was updated successfully, but these errors were encountered: