Skip to content

Commit f54012d

Browse files
is_near_clifford_tableau_writer
1 parent 23c4664 commit f54012d

4 files changed

Lines changed: 40 additions & 32 deletions

File tree

pyqrack/qrack_ace_backend.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ def __init__(
222222
is_binary_decision_tree=False,
223223
is_opencl=True,
224224
is_host_pointer=(True if os.environ.get("PYQRACK_HOST_POINTER_DEFAULT_ON") else False),
225+
is_near_clifford_tableau_writer=False,
225226
noise=0,
226227
to_clone=None,
227228
):
@@ -320,6 +321,7 @@ def __init__(
320321
is_binary_decision_tree=is_binary_decision_tree,
321322
is_opencl=is_opencl,
322323
is_host_pointer=is_host_pointer,
324+
is_near_clifford_tableau_writer=is_near_clifford_tableau_writer,
323325
noise=noise,
324326
)
325327
)

pyqrack/qrack_near_clifford_qec_backend.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ def __init__(
3333
code_len=5,
3434
layers_per_qec_round = 0,
3535
is_eager = True,
36-
toClone=None,
36+
to_clone=None,
3737
):
3838
if (code_len < 3) or ((code_len & 1) == 0):
3939
raise ValueError("QrackNearCliffordQecBackend code_len must be odd and >= 3!")
4040

41-
if toClone:
42-
qubit_count = toClone.num_qubits()
43-
code_len = toClone.code_len
44-
layers_per_qec_round = toClone.layers
45-
is_eager = toClone.is_eager
41+
if to_clone:
42+
qubit_count = to_clone.num_qubits()
43+
code_len = to_clone.code_len
44+
layers_per_qec_round = to_clone.layers
45+
is_eager = to_clone.is_eager
4646
if qubit_count < 0:
4747
qubit_count = 0
4848

@@ -66,8 +66,8 @@ def __init__(
6666
total_qubits = self.code_len * self.n_qubits + (self.code_len - 1)
6767

6868
self.sim = (
69-
toClone.sim.clone()
70-
if toClone
69+
to_clone.sim.clone()
70+
if to_clone
7171
else QrackStabilizer(total_qubits)
7272
)
7373

@@ -162,7 +162,7 @@ def _prop_nc(self, lq1, lq2):
162162
self.c[lq1] = True
163163

164164
def clone(self):
165-
return QrackNearCliffordQecBackend(toClone=self)
165+
return QrackNearCliffordQecBackend(to_clone=self)
166166

167167
def num_qubits(self):
168168
return self.n_qubits
@@ -641,7 +641,7 @@ def run_qiskit_circuit(self, experiment, shots=1):
641641
_data.append(self._add_sample_measure(self._sample_qubits, self._sample_clbits))
642642
else:
643643
for shot in range(shots):
644-
self._sim = QrackNearCliffordQecBackend(toClone=self)
644+
self._sim = QrackNearCliffordQecBackend(to_clone=self)
645645
self._classical_memory = 0
646646
self._classical_register = 0
647647

pyqrack/qrack_simulator.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,23 @@ def __init__(
5656
is_opencl=True,
5757
is_host_pointer=(True if os.environ.get("PYQRACK_HOST_POINTER_DEFAULT_ON") else False),
5858
is_sparse=False,
59+
is_near_clifford_tableau_writer=False,
5960
noise=0,
6061
pyzx_circuit=None,
6162
qiskit_circuit=None,
6263
):
6364
self.sid = None
6465

65-
is_tensor_network=True
66-
is_paged=True
67-
is_cpu_gpu_hybrid=True
68-
if is_sparse:
69-
is_opencl = False
66+
if is_near_clifford_tableau_writer:
67+
is_tensor_network=False
68+
is_schmidt_decompose=False
69+
is_stabilizer_hybrid=True
70+
else:
71+
is_tensor_network=True
72+
is_paged=True
73+
is_cpu_gpu_hybrid=True
74+
if is_sparse:
75+
is_opencl = False
7076

7177
if pyzx_circuit is not None:
7278
qubit_count = pyzx_circuit.qubits

pyqrack/qrack_stabilizer.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,42 +20,42 @@ class QrackStabilizer(QrackSimulator):
2020

2121
def __init__(
2222
self,
23-
qubitCount=-1,
24-
cloneSid=-1,
25-
pyzxCircuit=None,
26-
qiskitCircuit=None,
23+
qubit_count=-1,
24+
clone_sid=-1,
25+
pyzx_circuit=None,
26+
qiskit_circuit=None,
2727
):
2828
self.sid = None
2929

30-
if pyzxCircuit is not None:
31-
qubitCount = pyzxCircuit.qubits
32-
elif qiskitCircuit is not None and qubitCount < 0:
30+
if pyzx_circuit is not None:
31+
qubit_count = pyzx_circuit.qubits
32+
elif qiskit_circuit is not None and qubitCount < 0:
3333
raise RuntimeError(
3434
"Must specify qubitCount with qiskitCircuit parameter in QrackSimulator constructor!"
3535
)
3636

37-
if qubitCount > -1 and cloneSid > -1:
37+
if qubit_count > -1 and clone_sid > -1:
3838
raise RuntimeError(
3939
"Cannot clone a QrackStabilizer and specify its qubit length at the same time, in QrackStabilizer constructor!"
4040
)
4141

4242
self.is_tensor_network = False
4343
self.is_pure_stabilizer = True
4444

45-
if cloneSid > -1:
46-
self.sid = Qrack.qrack_lib.init_clone(cloneSid)
45+
if clone_sid > -1:
46+
self.sid = Qrack.qrack_lib.init_clone(clone_sid)
4747
else:
48-
if qubitCount < 0:
49-
qubitCount = 0
48+
if qubit_count < 0:
49+
qubit_count = 0
5050

51-
self.sid = Qrack.qrack_lib.init_count_stabilizer(qubitCount)
51+
self.sid = Qrack.qrack_lib.init_count_stabilizer(qubit_count)
5252

5353
self._throw_if_error()
5454

55-
if pyzxCircuit is not None:
56-
self.run_pyzx_gates(pyzxCircuit.gates)
57-
elif qiskitCircuit is not None:
58-
self.run_qiskit_circuit(qiskitCircuit)
55+
if pyzx_circuit is not None:
56+
self.run_pyzx_gates(pyzx_circuit.gates)
57+
elif qiskit_circuit is not None:
58+
self.run_qiskit_circuit(qiskit_circuit)
5959

6060
def set_stochastic(self, s):
6161
Qrack.qrack_lib.SetStochastic(self.sid, s)

0 commit comments

Comments
 (0)