From 9308bfe2a17d93b8cfa57252e82f602b1919f291 Mon Sep 17 00:00:00 2001 From: PabloAndresCQ Date: Tue, 14 Nov 2023 10:54:11 +0000 Subject: [PATCH] Changes suggested by Iakov --- pytket/extensions/cutensornet/tnstate/mps_mpo.py | 4 ++-- pytket/extensions/cutensornet/tnstate/ttn.py | 8 ++++---- pytket/extensions/cutensornet/tnstate/ttn_gate.py | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pytket/extensions/cutensornet/tnstate/mps_mpo.py b/pytket/extensions/cutensornet/tnstate/mps_mpo.py index c6253974..915db486 100644 --- a/pytket/extensions/cutensornet/tnstate/mps_mpo.py +++ b/pytket/extensions/cutensornet/tnstate/mps_mpo.py @@ -388,7 +388,7 @@ def update_sweep_cache(pos: int, direction: DirMPS) -> None: T = cq.contract( *interleaved_rep, options={"handle": self._lib.handle, "device_id": self._lib.device_id}, - optimize={"samples": 1}, + optimize={"samples": 0}, ) if direction == DirMPS.LEFT: r_cached_tensors.append(T) @@ -450,7 +450,7 @@ def update_variational_tensor( F = cq.contract( *interleaved_rep, options={"handle": self._lib.handle, "device_id": self._lib.device_id}, - optimize={"samples": 1}, + optimize={"samples": 0}, ) # Get the fidelity diff --git a/pytket/extensions/cutensornet/tnstate/ttn.py b/pytket/extensions/cutensornet/tnstate/ttn.py index d56dd4d5..efc142ce 100644 --- a/pytket/extensions/cutensornet/tnstate/ttn.py +++ b/pytket/extensions/cutensornet/tnstate/ttn.py @@ -569,7 +569,7 @@ def vdot(self, other: TTN) -> complex: # type: ignore result = cq.contract( *interleaved_rep, options={"handle": self._lib.handle, "device_id": self._lib.device_id}, - optimize={"samples": 1}, # There is little to no optimisation to be done + optimize={"samples": 0}, # There is little to no optimisation to be done ) self._logger.debug(f"Result from vdot={result}") @@ -672,7 +672,7 @@ def get_statevector(self) -> np.ndarray: result_tensor = cq.contract( *interleaved_rep, options={"handle": self._lib.handle, "device_id": self._lib.device_id}, - optimize={"samples": 1}, # There is little to no optimisation to be done + optimize={"samples": 0}, # There is little to no optimisation to be done ) # Convert to numpy vector and flatten @@ -712,7 +712,7 @@ def get_amplitude(self, state: int) -> complex: result = cq.contract( *interleaved_rep, options={"handle": self._lib.handle, "device_id": self._lib.device_id}, - optimize={"samples": 1}, # There is little to no optimisation to be done + optimize={"samples": 0}, # There is little to no optimisation to be done ) self._logger.debug(f"Amplitude of state {state} is {result}.") @@ -773,7 +773,7 @@ def get_dimension(self, path: RootPath, direction: DirTTN) -> int: direction: The direction of the bond. Returns: - The dimension of the bond between the node and its parent. + The dimension of the specified bond. Raises: ValueError: If ``path`` is not in the TTN. diff --git a/pytket/extensions/cutensornet/tnstate/ttn_gate.py b/pytket/extensions/cutensornet/tnstate/ttn_gate.py index c16a3bb6..cd226c06 100644 --- a/pytket/extensions/cutensornet/tnstate/ttn_gate.py +++ b/pytket/extensions/cutensornet/tnstate/ttn_gate.py @@ -87,7 +87,7 @@ def _apply_1q_gate(self, qubit: Qubit, gate: Op) -> TTNxGate: def _apply_2q_gate(self, q0: Qubit, q1: Qubit, gate: Op) -> TTNxGate: """Applies the 2-qubit gate to the TTN. - Truncation is automatically applied according to the paremeters + Truncation is automatically applied according to the parameters in the ``Config`` object passed to this ``TTN``. The TTN is converted to canonical form before truncating. @@ -130,7 +130,7 @@ def _apply_2q_gate(self, q0: Qubit, q1: Qubit, gate: Op) -> TTNxGate: node_bonds = aux_bonds.copy() node_bonds[bond_q0] = "i0" node_bonds[bond_q1] = "i1" - result_bonds = aux_bonds.copy() + result_bonds = aux_bonds result_bonds[bond_q0] = "o0" result_bonds[bond_q1] = "o1" @@ -237,7 +237,7 @@ def _apply_2q_gate(self, q0: Qubit, q1: Qubit, gate: Op) -> TTNxGate: aux_bonds = [f"q{x}" for x in range(n_qbonds)] + ["p"] node_bonds = aux_bonds.copy() node_bonds[bond] = "a" - result_bonds = aux_bonds.copy() + result_bonds = aux_bonds result_bonds[bond] = "b" result_bonds[-1] = "f"