I'm encoding data into a QuantumCircuit via the Initialize method for QFTs. In doing this and transpiling for IonQ backends, I'm getting rather complex circuits. Is there a way to encode this data more efficiently for IonQ backends or a method to approximate this circuit? Thanks in advance!
2 Answers
I think that the QuantumCircuit.initialize()
method isn't always providing the most efficient state preparations.
I have tried to initialize some very simple states, like $|11⟩$ for 2-qubits system:
- In the first case I just used simple 2 NOT gates (which are also native gates in all the quantum computers that I know), so the the transpiled version is pretty much the same:
- In the second case I have used
qc.initialize([0,0,0,1])
to initialize the same $|11⟩$ state and the results are very ugly:
Along with this talking I can infer that QuantumCircuit.initialize()
isn't providing always the most efficient method for setting a desired state. And that's probably the reason that so many gates are used in order to set the 8-qubits state above.
Try to set up the desired state manually (I don't understand exactly which state you are trying to initialize here so I can't tell you exactly how to do it for now).
Try using isometry
instead of initialize
:
qc.isometry(y/np.linalg.norm(y), [*range(n_qubits)], [])
Also, try setting optimization_level
to 3 for transpile
method. Most of the time this will reduce number of gates.
qc1 = transpile(circuits=qc, backend=backend, optimization_level=3)