-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Two-step transpilation for variational algorithms #7217
Conversation
Pull Request Test Coverage Report for Build 1522789478
💛 - Coveralls |
qiskit/utils/quantum_instance.py
Outdated
bound_pass_manager (Optional['PassManager']): Pass manager to apply on bound circuits | ||
only. |
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.
Do people generally know what a 'bound circuit' means? Should we state here that this is a circuit whose parameters have been set via the bind/assign so that no symbolic parameters remain (assuming I have it right!). Did it have to be a parameterized circuit in the first place - e.g. is it valid to pass in a circuit with fixed parameters to the transpile the first time around and still use this?
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.
I've added more docs in 718bfc3, hopefully it's clearer now 🙂
Two-step transpile is the right thing to do for parameterized circuits. 👍 |
test/python/algorithms/test_vqe.py
Outdated
from qiskit.utils import QuantumInstance, algorithm_globals, has_aer | ||
|
||
if has_aer(): | ||
from qiskit import Aer | ||
|
||
|
||
class _Counter(TransformationPass): |
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.
Should this be an AnalysisPass ? It seems to me that this kind of information should be added to the property pass, since they passes should not hold state among runs.
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.
Overall this LGTM, the code change is straightforward enough. I just have some documentation issues inline. Mainly I think we should have a separate release note for the circuit sampler change and also be a bit more explicit about which transpile()
we're talking about in the docstring for the new kwargs.
Co-authored-by: Matthew Treinish <[email protected]>
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, thanks for making the updates to the docs.
Allow two transpiler stages in the :class:`~qiskit.utils.QuantumInstance`, one for | ||
parameterized circuits and a second one for bound circuits (i.e. no free parameters) only. | ||
If a quantum instance with passes for unbound and bound circuits is passed into a | ||
:class:`~qiskit.opflow.CircuitSampler`, the sampler will attempt to apply the unbound pass |
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.
I'd probably have split this into a separate note, but it's fine integrated into this too.
* Fix performance regression of VQE * Update qiskit/opflow/converters/circuit_sampler.py Co-authored-by: Julien Gacon <[email protected]> Co-authored-by: Julien Gacon <[email protected]>
* first working version * use additional kwarg, not dict * add test * add reno * black & type hint in tests * add more docs * log based testing * avoid enum and pass pass managers in transpile * docs * Apply suggestions from code review Co-authored-by: Matthew Treinish <[email protected]> * update docs Co-authored-by: Luciano Bello <[email protected]> Co-authored-by: Matthew Treinish <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* first working version * use additional kwarg, not dict * add test * add reno * black & type hint in tests * add more docs * log based testing * avoid enum and pass pass managers in transpile * docs * Apply suggestions from code review Co-authored-by: Matthew Treinish <[email protected]> * update docs Co-authored-by: Luciano Bello <[email protected]> Co-authored-by: Matthew Treinish <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* first working version * use additional kwarg, not dict * add test * add reno * black & type hint in tests * add more docs * log based testing * avoid enum and pass pass managers in transpile * docs * Apply suggestions from code review Co-authored-by: Matthew Treinish <[email protected]> * update docs Co-authored-by: Luciano Bello <[email protected]> Co-authored-by: Matthew Treinish <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Summary
Allow two transpiler passes in variational algorithms, one for parameterized circuits (executed once) and one for bound circuits (executed in each iteration). This is a requirement for the QAOA runtime program.
Details and comments
Allow two transpiler stages in the
QuantumInstance
, one forparameterized circuits and a second one for bound circuits only. This enables variational
algorithms like the VQE to run a pass manager for parameterized
circuits once and, additionally, another transpiler pass on the bound circuits in each
iteration. This is an important feature since not all passes support parameterized circuits.
For example, this feature allows using the pulse-efficient CX decomposition in the VQE.