-
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
[RFC] Unrolling #3146
Comments
In terms of synthesis you may also want to choose between different algorithms or input a custom one. Simple example for single qubit unitaries is you could synthesis to u3, u1+x90, rx+ry or rx+rz gates. |
from @chriseclectic in #3146 (comment) :
May I add it as optional? Or do you think is a "must to have"? |
Proposal: multiple prioritized decompositionsSupporting multiple possible decomposition per gate might allow to signal the unroller on how to unroll each gate until the basis gate set is reached. The decompositions are sorted by preference. ie, in Consider the coming examples using the following decomposition rules:
cuasi-implementation: def decompose(gate, basis, visited=None):
if gate in basis:
return [gate]
if visited is None:
visited = set()
if gate in visited:
return [None] # No decomposition was found on this branch
visited.add(gate) #avoids inf loops
decompositions = decompositions_db[gate]
for decomposition in decompositions:
candidate = []
for subgate in decomposition:
candidate.append(decompose(subgate, basis, visited))
if None not in candidate: # is it a valid decomposition?
return candidate # once a valid decomposition is found, return it.
return None # no decomposition was found
for gate in circuit:
circuit.replace(gate, decompose(gate, basis)) #replaces gate with its decomposition
To implement this proposal:
Problems:
Footnotes: |
I think that moving away from Opinions:
Questions:
|
@mtreinish raised a good question in #1435: If we build to a library of equivalent DAGs, how can we make sure that users or passes don't inadvertently modify them and alter their behavior in subsequent circuits? |
Would be fair to say that they should be ordered at unrolling-time? I think would be easier to have a "default" order that can be modified. But I'm also okey with having them without any priority and set that priority immediately before unrolling (I'm not sure how the API would look like)
you mean transpile different circuits with different unrolling strategies? Like unrolling differently
Sure.. it could be. In general, unrolling should be "lazy" ie no call until that unroll is necessary.
I think this is also solvable by having callables as decompositions, which is consistent with the synthesis situation. What do you think? I can modify the proposal to "decompositions is a list of callables that return a DAG". |
IMHO, gate mapping is an arbitrary directed graph: one may specify multiple decompositions per gate, and loops are allowed. The backend defines the set of physically implemented gates (or in case of a simulator, all of them), which then allows the graph to be transformed into a DAG via Breadth-first search (BFS) from the physical gates. This way we separate gate mappings from the physical basis set. |
The problem
There is a need to support unrolling to a broader set of gate basis (see #3086). Additionally, supporting multiple decompositions are growing (see #3067).
Use cases
Our unrolling mechanism should support the following situations:
CX -> Rxx -> CX
.unitary
: If the basis supportsunitary
and there is no further possible decomposition for a gate that is not in the basis, the gate should be transformed to unitary.unitary -> U
transformation is particularly expensive. While it should be possible, unrolling should consider that cost.Optional features
It would be nice to also support the following situations:
unitary
, even when they are in the basis. Currently, this is solved withlabels
.The text was updated successfully, but these errors were encountered: