-
Notifications
You must be signed in to change notification settings - Fork 34
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
✨ Support for Qiskit's final_layout
#439
Labels
Core
Anything related to the Core library and IR
feature
New feature or request
good first issue
Good for newcomers
python
Anything related to Python code
Milestone
Comments
burgholzer
added
good first issue
Good for newcomers
feature
New feature or request
Core
Anything related to the Core library and IR
python
Anything related to Python code
labels
Oct 14, 2023
Since this issue's creation, Qiskit 1.0 has been released and we moved to depend on it. |
TeWas
added a commit
to TeWas/mqt-core
that referenced
this issue
Apr 18, 2024
burgholzer
pushed a commit
to TeWas/mqt-core
that referenced
this issue
Apr 20, 2024
burgholzer
pushed a commit
to TeWas/mqt-core
that referenced
this issue
Apr 20, 2024
burgholzer
added a commit
that referenced
this issue
Apr 20, 2024
## Description This PR adds support for Qiskit's `final_layout` attribute when importing circuits from Qiskit. It interprets the `output_permutation` of an MQT `QuantumComputation` object based on Qiskit's `final_index_layout()`, which maps the original input circuit's qubit indices to the final physical qubit indices after routing. This mapping is the result of applying `routing_permutation()` to the `initial_layout`. Additionally, it fixes the interpretation of the output_permutation in `initializeIOMapping()` to align with Qiskit's final_layout. Fixes #439 ## Checklist: <!--- This checklist serves as a reminder of a couple of things that ensure your pull request will be merged swiftly. --> - [x] The pull request only contains commits that are related to it. - [x] I have added appropriate tests and documentation. - [x] I have made sure that all CI jobs on GitHub pass. - [x] The pull request introduces no new warnings and follows the project's style guidelines. --------- Signed-off-by: burgholzer <burgholzer@me.com> Co-authored-by: burgholzer <burgholzer@me.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Core
Anything related to the Core library and IR
feature
New feature or request
good first issue
Good for newcomers
python
Anything related to Python code
What's the problem this feature will solve?
When reasoning about quantum circuits there are two degrees of freedom that can always lead to problems/confusion:
An arbitrary permutation of a circuit's qubits might be applied at the very beginning of the circuit (referred to as an "initial layout") or at the end of the circuit (referred to as an "output permutation").
In almost any case, a circuit containing such permutations would still be considered equivalent to a circuit without such permutations.
This is especially relevant for verifying the equivalence of quantum circuits and the results of compilation flows in particular.
For a long time, Qiskit has supported a
_layout
property for itsQuantumCircuit
objects that captured the initial layout applied during compilation. Within the MQT we use this property to infer theinitialLayout
for ourQuantumComputation
objects.In
0.22.0
(which is now our minimum supported version), Qiskit changed the_layout
property to a properTranspileLayout
class.0.23.0
introduced an additionalfinal_layout
component that (in some confusing fashion) captures the output permutation.This should allow to also infer the output permutation from Qiskit.
Right now, we use the measurements in a circuit for that purpose, which is rathe prone to errors (e.g., someone not adding measurements to their circuit before compilation).
Describe the solution you'd like
Starting with
0.45.0.
(which should be the next minor release), the ergonomics of theTranspileLayout
class have been considerably improved (see Qiskit/qiskit#10835).That should yield a blueprint for how to interpret the
final_layout
and to infer theoutputPermutation
from Qiskit circuits.A potential solution would first look if the
final_layout
attribute is present.If so, it would check whether the new convenient syntax (>=0.45.0) is available.
If not, it replicates the logic to parse the output permutation.
If no final layout is present, the solution should check for measurements in the circuit and infer the output permutation from there (as it currently does).
The text was updated successfully, but these errors were encountered: