You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, it may happen that after the synthesis one gets a circuit with more CX gates than before the synthesis.
Here is an example:
from qiskit import QuantumCircuit
from qiskit.circuit.library import *
from qiskit.transpiler import PassManager
from qiskit.transpiler.passes.optimization import CollectLinearFunctions
from qiskit.transpiler.passes.synthesis import (
LinearFunctionsSynthesis,
LinearFunctionsToPermutations,
)
# linear
n=5
qc = QuantumCircuit(n)
for i in range(n-1):
qc.cx(i,i+1)
# print (LinearFunction(qc).linear)
print ("Before LinearFunction:", qc.count_ops())
qc2 = PassManager(CollectLinearFunctions()).run(qc)
qc3 = PassManager(LinearFunctionsSynthesis()).run(qc2)
# print (qc3)
print ("After LinearFunction: ", qc3.count_ops())
outputs:
Before LinearFunction: OrderedDict([('cx', 4)])
After LinearFunction: OrderedDict([('cx', 6)])
Here are the suggestions to handle this problem and improve LinearFunction synthesis:
The transpiler pass of LinearFunctionsSynthesis should not return a circuit if it has more CX gates and/or worse depth than the original circuit.
Let A=LinearFunction(qc).linear.
Try to decompose the following 4 options and choose the best one (with optimal CX count and/or depth):
A, inverse(A), transpose(A) and inverse(transpose(A)).
(take the reverse circuit and/or reverse the ctrl and trgt of the CX gate accordingly).
Transfer qiskit.transpiler.synthesis.graysynth to qiskit.synthesis.graysynth and add further synthesis algorithms of reversible linear circuits.
The text was updated successfully, but these errors were encountered:
@ShellyGarion , @mtreinish, how would LinearFunctionsSynthesis know if it's supposed to improve gate-count or depth? I might be wrong, but I don't recall seeing the optimization criteria as part of the options to transpile.
What should we add?
Improving LinearFunction synthesis.
Currently, it may happen that after the synthesis one gets a circuit with more CX gates than before the synthesis.
Here is an example:
outputs:
Here are the suggestions to handle this problem and improve LinearFunction synthesis:
The transpiler pass of LinearFunctionsSynthesis should not return a circuit if it has more CX gates and/or worse depth than the original circuit.
Let
A=LinearFunction(qc).linear
.Try to decompose the following 4 options and choose the best one (with optimal CX count and/or depth):
A, inverse(A), transpose(A) and inverse(transpose(A)).
(take the reverse circuit and/or reverse the ctrl and trgt of the CX gate accordingly).
Transfer
qiskit.transpiler.synthesis.graysynth
toqiskit.synthesis.graysynth
and add further synthesis algorithms of reversible linear circuits.The text was updated successfully, but these errors were encountered: