-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingmod: qasm3Related to OpenQASM 3 import or exportRelated to OpenQASM 3 import or export
Description
Environment
- Qiskit version: 1.0.2
- Python version: Python 3.10.12
- Operating system: Ubuntu 22.04
What is happening?
Applying the sx
gate seems to give a different result if I copy and paste the x
and sx
gate definitions out from stdgates.inc
, versus if I use include stdgates.inc
.
How can we reproduce the issue?
from qiskit import transpile
from qiskit.qasm3 import loads
from qiskit.quantum_info import Statevector
from qiskit_aer import Aer
qc = loads('''
OPENQASM 3.0;
gate x a { U(pi, 0, pi) a; }
gate sx a { pow(1/2) @ x a; }
qubit[1] r1;
sx r1[0];
''')
qc = transpile(qc, Aer.get_backend('qasm_simulator'))
state_vec = Statevector.from_instruction(qc)
print(state_vec)
print(state_vec.probabilities())
Output:
Statevector([1.+0.j, 0.+0.j],
dims=(2,))
[1. 0.]
What should happen?
Using the include instead:
from qiskit import transpile
from qiskit.qasm3 import loads
from qiskit.quantum_info import Statevector
from qiskit_aer import Aer
qc = loads('''
OPENQASM 3.0;
include "stdgates.inc";
qubit[1] r1;
sx r1[0];
''')
qc = transpile(qc, Aer.get_backend('qasm_simulator'))
state_vec = Statevector.from_instruction(qc)
print(state_vec)
print(state_vec.probabilities())
Gets the correct probabilities:
Statevector([0.5+0.5j, 0.5-0.5j],
dims=(2,))
[0.5 0.5]
Any suggestions?
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingmod: qasm3Related to OpenQASM 3 import or exportRelated to OpenQASM 3 import or export