Skip to content

Commit

Permalink
Fixing wrong qubit id in id gate (#46)
Browse files Browse the repository at this point in the history
* Fixing wrong qubit id in id gate

* Updating id usage to avoid non-default id
  • Loading branch information
idavis authored Nov 27, 2023
1 parent b972ed9 commit 054b7ad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/qiskit_qir/visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,9 @@ def __branch():
qis.z(self._builder, *qubits)
elif "id" == instruction.name:
# See: https://github.com/qir-alliance/pyqir/issues/74
qis.x(self._builder, pyqir.qubit(self._module.context, 0))
qis.x(self._builder, pyqir.qubit(self._module.context, 0))
qubit = pyqir.qubit(self._module.context, qubit_id(*qubits))
qis.x(self._builder, qubit)
qis.x(self._builder, qubit)
elif instruction.definition:
_log.debug(
f"About to process composite instruction {instruction.name} with qubits {qargs}"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_circuits/basic_circuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def unroll():
circ = QuantumCircuit(3)
circ.ccx(0, 1, 2)
circ.crz(theta=0.1, control_qubit=0, target_qubit=1)
circ.id(0)
circ.id(2)

return circ.decompose()

Expand Down

0 comments on commit 054b7ad

Please sign in to comment.