Skip to content

Commit

Permalink
Fix PR
Browse files Browse the repository at this point in the history
Signed-off-by: David Winderl <winderl13@gmail.com>

Removes append_pauli gadegt

must me -> must be

Change type to float constructor

Signed-off-by: David Winderl <winderl13@gmail.com>

Clifford clifford -> Clifford Tableau

Signed-off-by: David Winderl <winderl13@gmail.com>

Removes redundant if condition

Signed-off-by: David Winderl <winderl13@gmail.com>

Fix unit tests and pipeline

Signed-off-by: David Winderl <winderl13@gmail.com>

Fix tests

Signed-off-by: David Winderl <winderl13@gmail.com>
  • Loading branch information
daehiff committed Aug 11, 2024
1 parent bdf8627 commit 68d092b
Show file tree
Hide file tree
Showing 11 changed files with 313 additions and 241 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ on:
jobs:
lint:
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
matrix:
python-version: [ "3.9", "3.10" ]
outputs:
Expand Down
4 changes: 2 additions & 2 deletions pauliopt/clifford/tableau.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def mult_paulis(p1, p2, sign1, sign2, n_qubits):

class CliffordTableau:
"""
Class for storing and manipulating Clifford clifford.
A Clifford clifford is a representation of a Clifford circuit as a
Class for storing and manipulating Clifford tableau.
A Clifford tableau is a representation of a Clifford circuit as a
2n x 2n binary matrix, where n is the number of qubits. The first n rows
represent the stabilizers, and the last n rows represent the destabilizers.
The first n columns represent the X operators, and the last n columns
Expand Down
4 changes: 2 additions & 2 deletions pauliopt/clifford/tableau_synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,10 @@ def get_non_cutting_vertex(G, pivot_col, swappable_nodes):

def synthesize_tableau(tableau: CliffordTableau, topo: Topology, include_swaps=True):
"""
Architecture aware synthesis of a Clifford clifford.
Architecture aware synthesis of a Clifford tableau.
This is the implementation of the algorithm described in Winderl et. al. [1]
:param tableau: The Clifford clifford
:param tableau: The Clifford tableau
:param topo: The topology
:param include_swaps: Whether to allow initial and final measurement permutations
Expand Down
9 changes: 3 additions & 6 deletions pauliopt/gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def __repr__(self) -> str:
return f"{self.name}({self.phase}, {', '.join(args)})"

def get_phase_as_float(self):
return self.phase if not isinstance(self.phase, Angle) else self.phase.to_qiskit
return self.phase if not isinstance(self.phase, Angle) else float(self.phase)

def get_phase_as_angle(self):
return self.phase if isinstance(self.phase, Angle) else Angle(self.phase)
Expand Down Expand Up @@ -193,7 +193,7 @@ def __init__(self, *qubits):
@abstractmethod
def get_h_s_cx_decomposition(self) -> List[Union["H", "S", "CX"]]:
"""
Every clifford must me decomposable into a list of H, S and CX gates.
Every clifford must be decomposable into a list of H, S and CX gates.
Returns:
"""
Expand Down Expand Up @@ -695,10 +695,7 @@ class Rx(PhaseGate):
@property
def decomp(self):
(q,) = self.qubits
if isinstance(self.phase, Angle):
return [XHead(self.get_phase_as_angle()) @ {q}]
else:
return [XHead(Angle(self.get_phase_as_angle())) @ {q}]
return [XHead(self.get_phase_as_angle()) @ {q}]

def to_qiskit(self):
try:
Expand Down
7 changes: 4 additions & 3 deletions pauliopt/pauli/pauli_gadget.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pauliopt.gates import H, V, Rz, CX, Vdg
from pauliopt.pauli_strings import Pauli, X, Y, Z, I
from pauliopt.topologies import Topology
from pauliopt.utils import AngleExpr


def decompose_cnot_ladder_z(ctrl: int, trg: int, arch: Topology):
Expand Down Expand Up @@ -59,9 +60,9 @@ def find_minimal_cx_assignment(column: np.array, arch: Topology, q0=None):


class PPhase:
_angle: float
_angle: AngleExpr

def __init__(self, angle: float):
def __init__(self, angle: AngleExpr):
self._angle = angle

def __matmul__(self, paulis: List[Pauli]):
Expand All @@ -72,7 +73,7 @@ def __str__(self):


class PauliGadget:
def __init__(self, angle: float, paulis: List[Pauli]):
def __init__(self, angle: AngleExpr, paulis: List[Pauli]):
self.angle = angle
self.paulis = paulis

Expand Down
10 changes: 3 additions & 7 deletions pauliopt/pauli/pauli_polynomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ def __irshift__(self, gadget: PauliGadget):
f"Pauli Polynomial has {self.num_qubits} qubits, but Pauli gadget has: "
f"{len(gadget)} qubits"
)
self.append_pauli_gadget(gadget)
self.pauli_gadgets.append(gadget)
return self

def __rshift__(self, pauli_polynomial: "PauliPolynomial"):
for gadget in pauli_polynomial.pauli_gadgets:
self.append_pauli_gadget(gadget)
self.pauli_gadgets.append(gadget)
return self

def __repr__(self):
Expand Down Expand Up @@ -134,8 +134,6 @@ def num_legs(self):
legs += gadget.num_legs()
return legs

def append_pauli_gadget(self, pauli_gadget: PauliGadget):
self.pauli_gadgets.append(pauli_gadget)

def assign_time(self, time: float):
for gadet in self.pauli_gadgets:
Expand Down Expand Up @@ -239,7 +237,7 @@ def to_svg(
# width of the text of the phases # TODO round floats (!!)
text_width = int(math.ceil(50 * vscale))

bend_degree = int(math.ceil(10))
bend_degree = 10

# margins between the angle and the legs
margin_angle_x = int(math.ceil(20 * hscale))
Expand All @@ -249,8 +247,6 @@ def to_svg(
margin_x = int(math.ceil(10 * hscale))
margin_y = int(math.ceil(10 * hscale))

font_size = int(10)

width = (
num_gadgets * (square_width + margin_x + margin_angle_x + text_width)
+ margin_x
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ pytket-qiskit==0.34.0
qiskit==0.39.0
galois==0.3.7
parameterized==0.9.0
notebook==7.0.7
notebook~=7.0.7
black==24.3.0
Loading

0 comments on commit 68d092b

Please sign in to comment.