-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Circuits with control flow now raise a proper error when circuit_to_instruction
is called
#13921
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
Conversation
…nstruction is called
One or more of the following people are relevant to this code:
|
Pull Request Test Coverage Report for Build 13564994279Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just one minor typo
Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This method was added to fix a performance regression introduced by Qiskit#13921. This check should be quicker than the multiple calls to `isinstance`.
In Qiskit#13921 a check was added to circuit_to_instruction() for determining if the circuit has a control flow op. This check was adding significant overhead to the function, nightly asv benchmarks are showing up to a ~9x slowdown. Qiskit#13921 attempted to fix this regression but did so by adding a new API which isn't applicable at this point for 2.0. That PR could/should still be used in 2.1. In the meantime this commit seeks to solve the performance regression by adjusting how the check is performed to mitigate the runtime regression for 2.0.
In #13921 a check was added to circuit_to_instruction() for determining if the circuit has a control flow op. This check was adding significant overhead to the function, nightly asv benchmarks are showing up to a ~9x slowdown. #13921 attempted to fix this regression but did so by adding a new API which isn't applicable at this point for 2.0. That PR could/should still be used in 2.1. In the meantime this commit seeks to solve the performance regression by adjusting how the check is performed to mitigate the runtime regression for 2.0.
* Add: Add method has_control_flow_op(), to `QuantumCircuit` This method was added to fix a performance regression introduced by #13921. This check should be quicker than the multiple calls to `isinstance`. * Lint: Fix formatting * Lint: Removed unused import and f-string * Docs: Add release note - Add `has_control_flow_op` to autogenerate docs. * Fix: Addressing review comments Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * Docs: Fix formatting issue in `QuantumCircuit` docstring. * Lint: Fix formatting bug in `QuantumCircuit`. * Test: Add testcases - One test case with a regular control flow operation and another with a custom one. * Test: Remove unsupported test and extend original test. - Implement a combinatorics based test for control flow operations. * Fix: Import order in `test_circuit_operations` * Update test/python/circuit/test_circuit_operations.py --------- Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
* Add: Add method has_control_flow_op(), to `QuantumCircuit` This method was added to fix a performance regression introduced by Qiskit#13921. This check should be quicker than the multiple calls to `isinstance`. * Lint: Fix formatting * Lint: Removed unused import and f-string * Docs: Add release note - Add `has_control_flow_op` to autogenerate docs. * Fix: Addressing review comments Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * Docs: Fix formatting issue in `QuantumCircuit` docstring. * Lint: Fix formatting bug in `QuantumCircuit`. * Test: Add testcases - One test case with a regular control flow operation and another with a custom one. * Test: Remove unsupported test and extend original test. - Implement a combinatorics based test for control flow operations. * Fix: Import order in `test_circuit_operations` * Update test/python/circuit/test_circuit_operations.py --------- Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Summary
Fixes #11379
Details and comments
Converting a quantum circuit to a gate with
circuit_to_instruction
now fails properly when given circuit contains control flow instructions.