Error when adding gate after circuit.initialize method
See original GitHub issueEnvironment
- Qiskit Terra version: 0.19.2
- Python version: 3.9.6
- Operating system: Windows 11
What is happening?
Failure to run quantum circuit after circuit.initialize() method and any gate, using either statevector or qasm simulator.
The circuit runs when only having an initialize method. But it fails when more gates are appended after the initialization.
How can we reproduce the issue?
beta = 0.3
alpha = np.sqrt(1 - abs(beta)**2)
qc = QuantumCircuit(1)
qc.initialize([alpha, beta], 0)
qc.h(0)
qc.measure_all()
qc.draw()
sv_sim = Aer.get_backend('statevector_simulator')
qasm_sim = Aer.get_backend('qasm_simulator')
execute(qc, qasm_sim).result().get_counts()
…
What should happen?
I would imagine we can initialize a state and apply any gate we want to it. Here, this code block should get a Python dictionary of measurement counts.
Any suggestions?
The second param of initialize() method can also be a bit misleading, causing ambiguity when reading the doc, since one may natively think “qubits” as the number of qubits. But I think I get the intention now.
Issue Analytics
- State:
- Created a year ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Figure of large circuit with initialize gives an error on rendering ...
I am trying to initialize a quantum circuit and draw the circuit using the Matplotlib backend: size = 4 q = QuantumRegister(size, name='q')...
Read more >Error when attempting to visualize controlled hadamard gate ...
The error refers to a "Unitary" method. This could be the unitary_simulator / UnitarySimulator the tutorial used versus the one I imported.
Read more >qiskit.extensions.Initialize — Qiskit 0.24.1 documentation
Call to create a circuit with gates that take the desired vector to zero. inverse (). Invert this instruction. is_parameterized ().
Read more >Build, edit, and inspect quantum circuits
You can also double-click a gate to access the Edit operation panel, and set the conditional parameters that way. Add a control modifier¶....
Read more >Models — Qibo 0.1.9 documentation
Creates a copy of the circuit with noise gates after each gate. ... Initialize the Grover algorithm with the superposition and Grover ancilla....
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
Thanks a million, I will do so right away!
Could you try upgrading your version of Terra, and seeing if the bug persists? You’ve got a pretty old version (0.19.2) compared to the current 0.22.0.
(For what it’s worth, I ran this:
with Terra 0.22.0 and Aer 0.11.0 and got
which looks about right to me.)