Improve TwoLocal and RealAmplitudes synthesis when entanglement='full'
See original GitHub issueWhat should we add?
When choosing a TwoLocal
or RealAmplitude
or EfficientSU2
gate with entanglement=full
on n-qubits (for VQE ansatz),
then we get a circuit with a CX sub-circuit that contains n*(n-1)/2
CX gates.
However, we can re-write this circuit with only n-1
CX gates with a linear connectivity (see a code example below).
from qiskit.circuit.library import *
from qiskit.quantum_info import Operator
n = 5
# print (RealAmplitudes(n, reps=1, insert_barriers=True).decompose())
# now note that the CX-subcircuit is in fact the same as this qc below
qc = QuantumCircuit(n)
for i in range(n):
for j in range(i+1, n):
qc.cx(i,j)
# print ("qc", qc)
mat = LinearFunction(qc).linear
op = Operator(qc)
qc1 = QuantumCircuit(n)
for i in range(n-1):
qc1.cx(n-i-2, n-i-1)
# print ("qc1", qc1)
mat1 = LinearFunction(qc).linear
op1 = Operator(qc1)
print((mat == mat1).all())
print (op == op1)
outputs:
True
True
It will be good to update either NLocal
or TwoLocal
to consider this specific enhancement,
as it seems that this is used in many applications.
Issue Analytics
- State:
- Created a year ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
qiskit.circuit.library.RealAmplitudes
The entanglement can be set using the entanglement keyword as string or a list of index-pairs. See the documentation of TwoLocal and NLocal...
Read more >qiskit-terra - bytemeta
Improve TwoLocal and RealAmplitudes synthesis when entanglement='full ' · QPY serialization does not preserve Delay time unit.
Read more >Karma: Null Error from Percy Snapshots - GoogleForCreators/Web ...
Improve TwoLocal and RealAmplitudes synthesis when entanglement='full ', 12, 2022-07-05, 2022-10-01. Tar, drench, and heavy compressors, 8, 2021-12-26 ...
Read more >Updating a node with an anchor removes the anchor - Mikefarah/Yq
Improve TwoLocal and RealAmplitudes synthesis when entanglement='full ', 12, 2022-07-05, 2022-11-04. Updating causes game crash after restart, 1, 2022-05-18 ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We have agreed upon the following API:
the new method will be called
reverse_linear
the previous method will be called
full
(as it originally was)the documentation will say that for a
TwoLocal
circuit, ifentanglement_blocks='cx'
thenfull
andreverse_linear
actually provide the same circuitfor
RealAmplitudes
andEfficientSU2
circuits, where alwaysentanglement_blocks='cx'
, the default value forentanglement
will be changed fromfull
toreverse_linear
Yeah it seems these names were chosen by how they visually look like on the circuit, not by their effect. But at the moment I think these names are mostly just an identifier, without any rigour behind them. If you other suggestions I think we can change them 🙂