Skip to content

Commit

Permalink
Merge branch 'main' into cpu-only
Browse files Browse the repository at this point in the history
  • Loading branch information
WrathfulSpatula committed Dec 4, 2024
2 parents 6891aca + dce17c4 commit 8c9221c
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 18 deletions.
24 changes: 24 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
pyqrack (1.34.3) bionic; urgency=medium

* Qiskit v1.3 update (Bionic 4/4)

-- Daniel Strano <[email protected]> Wed, 04 Dec 2024 14:21:10 -0500

pyqrack (1.34.2) focal; urgency=medium

* Qiskit v1.3 update (Focal 3/4)

-- Daniel Strano <[email protected]> Wed, 04 Dec 2024 14:19:44 -0500

pyqrack (1.34.1) jammy; urgency=medium

* Qiskit v1.3 update (Jammy 2/4)

-- Daniel Strano <[email protected]> Wed, 04 Dec 2024 14:17:22 -0500

pyqrack (1.34.0) noble; urgency=medium

* Qiskit v1.3 update (Noble 1/4)

-- Daniel Strano <[email protected]> Wed, 04 Dec 2024 14:13:59 -0500

pyqrack (1.33.4) bionic; urgency=medium

* Bounds checking and QrackCircuit to string (Bionic 4/4)
Expand Down
2 changes: 1 addition & 1 deletion debian/files
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pyqrack_1.33.4_source.buildinfo libs optional
pyqrack_1.34.3_source.buildinfo libs optional
41 changes: 25 additions & 16 deletions pyqrack/qrack_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,18 @@ def string_to_qiskit_circuit(circ_string):

return circ

def _u3_to_mtrx(params):
th = float(params[0])
ph = float(params[1])
lm = float(params[2])

c = math.cos(th / 2)
s = math.sin(th / 2)
el = np.exp(1j * lm)
ep = np.exp(1j * ph)

return [ c + 0j, -el * s, ep * s, el * ep * c]

def in_from_qiskit_circuit(circ):
"""Read a Qiskit circuit into a QrackCircuit
Expand All @@ -404,29 +416,26 @@ def in_from_qiskit_circuit(circ):

out = QrackCircuit()

basis_gates = ["u", "cx"]
circ = transpile(circ, basis_gates=basis_gates, optimization_level=3)
basis_gates = ["x", "y", "z", "u", "cx", "cy", "cz", "cu"]
circ = transpile(circ, basis_gates=basis_gates, optimization_level=0)
for gate in circ.data:
o = gate.operation
if o.name == "u":
th = float(o.params[0])
ph = float(o.params[1])
lm = float(o.params[2])

c = math.cos(th / 2)
s = math.sin(th / 2)

op = [
c + 0j,
-np.exp(1j * lm) * s,
np.exp(1j * ph) * s,
np.exp(1j * (ph + lm)) * c
]
op = []
if o.name in ["x", "cx"]:
op = [0, 1, 1, 0]
elif o.name in ["y", "cy"]:
op = [0, -1j, 1j, 0]
elif o.name in ["z", "cz"]:
op = [1, 0, 0, -1]
else:
op = QrackCircuit._u3_to_mtrx(o.params)
if o.name in ["x", "y", "z", "u"]:
out.mtrx(op, circ.find_bit(gate.qubits[0])[0])
else:
ctrls = []
for c in gate.qubits[0:1]:
ctrls.append(circ.find_bit(c)[0])

out.ucmtrx(ctrls, [0, 1, 1, 0], circ.find_bit(gate.qubits[1])[0], 1)

return out
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from setuptools import setup


VERSION = "1.34.0"
VERSION = "1.34.4"

# Read long description from README.
README_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'README.md')
Expand Down

0 comments on commit 8c9221c

Please sign in to comment.