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
For a fixed QuantumCircuit with custom unitary gate matrix, QiskitAer is producing different statevector simulation results for qiskit v.1.2.4 and v.1.3.0
Steps to reproduce the problem
Using qiskit-aer=0.15.1, run the following script with qiskit==1.2.4 and qiskit==1.3.0 will reproduce different statevector results
importqiskitfromqiskit_aerimportAerSimulatorfromqiskit.circuit.libraryimportUnitaryGatefromqiskit.quantum_infoimportrandom_unitaryimportnumpyasnpdefget_qiskit_unitary_gate(rng, control=None):
rand_unitary=random_unitary(4, seed=rng)
gate=UnitaryGate(rand_unitary)
print(f"unitary gate matrix:")
print(gate)
ifcontrolisNone:
returngateelse:
returngate.control(control)
defget_qiskit_multi_control_circuit():
qubits=qiskit.QuantumRegister(5)
circuit=qiskit.QuantumCircuit(qubits)
forqinqubits:
circuit.h(q)
qs=list(qubits)
rng=np.random.default_rng(1234)
foriinrange(2):
rng.shuffle(qs)
ccu_gate=get_qiskit_unitary_gate(rng, control=2)
print(f"{i}th gate on {qs}")
circuit.append(ccu_gate, qs[:4])
circuit.p(0.1, qubits[0])
returncircuitprint(f"{qiskit.__version__=}")
circuit=get_qiskit_multi_control_circuit()
print(circuit)
circuit.save_statevector()
# Transpile for simulatorsimulator=AerSimulator(method='statevector')
circ=qiskit.transpile(circuit, simulator)
# Run and get statevectorresult=simulator.run(circ).result()
sv=np.asarray(result.get_statevector(circ))
print("Sum of state vector:", sv.sum())
What is the expected behavior?
The gate matrices defining the custom unitary gates are identical between qiskit==1.2.4 and qiskit==1.3.0 and therefore the returned statevector should be the same. On my end I have the following results:
Informations
What is the current behavior?
For a fixed QuantumCircuit with custom unitary gate matrix, QiskitAer is producing different statevector simulation results for qiskit v.1.2.4 and v.1.3.0
Steps to reproduce the problem
Using
qiskit-aer=0.15.1
, run the following script withqiskit==1.2.4
andqiskit==1.3.0
will reproduce different statevector resultsWhat is the expected behavior?
The gate matrices defining the custom unitary gates are identical between
qiskit==1.2.4
andqiskit==1.3.0
and therefore the returned statevector should be the same. On my end I have the following results:qiskit==1.2.4
qiskit==1.3.0
From our experiment, I believe the results from
qiskit=1.2.4
are correct. There might be some parsing issue betweenqiskit-aer
andqiskit==1.3.0
Suggested solutions
The text was updated successfully, but these errors were encountered: