Skip to content

Commit

Permalink
fix cu qiskit translation
Browse files Browse the repository at this point in the history
  • Loading branch information
refraction-ray committed Dec 15, 2023
1 parent 9bd8721 commit fc2fb06
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

- Support degenerate eigenvalue for jax backend `eigh` method when using AD

- Fixed `cu` gate translation from qiskit to avoid qiskit bug

## 0.11.0

### Added
Expand Down
3 changes: 2 additions & 1 deletion tensorcircuit/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,8 @@ def qiskit2tc(
tc_circuit.multicontrol(
*idx, ctrl=ctrl_state, unitary=gates._x_matrix, name="x"
)
elif gate_name[0] == "c" and gate_name[:7] != "circuit":
elif gate_name[0] == "c" and gate_name[:7] != "circuit" and gate_name != "cu":
# qiskit cu bug, see https://github.com/tencent-quantum-lab/tensorcircuit/issues/199
for i in range(1, len(gate_name)):
if (gate_name[-i] == "o") & (gate_name[-i - 1] == "_"):
break
Expand Down
3 changes: 3 additions & 0 deletions tests/test_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,9 @@ def test_qiskit2tc():
qisc.x(3)
qisc.y(3)
qisc.z(3)
qisc.cu(
5.868768495722669, 2.24809352294186, 3.59102783505607, 2.0223650288392, 1, 3
)
qisc.cnot(0, 1)
qisc.cy(0, 1)
qisc.cz(0, 1, ctrl_state=0)
Expand Down

0 comments on commit fc2fb06

Please sign in to comment.