Skip to content

Commit

Permalink
Solved issue by recalculating new_dim after canonicalisation. (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloAndresCQ authored Jul 28, 2023
1 parent 7eefaa1 commit 6c00ac9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pytket/extensions/cutensornet/mps/mps_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ def _apply_2q_gate(self, positions: tuple[int, int], gate: Op) -> MPSxGate:
# to the larger tensor resulting from the contraction.
self.canonicalise(l_pos, r_pos)

# Since canonicalisation may change the dimension of the bonds,
# we need to recalculate the value of `new_dim`
if l_pos == 0 or r_pos == len(self) - 1:
new_dim = 2
else:
new_dim = 2 * min(
self.get_virtual_dimensions(l_pos)[0],
self.get_virtual_dimensions(r_pos)[1],
)

# Load the gate's unitary to the GPU memory
gate_unitary = gate.get_unitary().astype(dtype=self._complex_t, copy=False)
gate_tensor = cp.asarray(gate_unitary, dtype=self._complex_t)
Expand Down

0 comments on commit 6c00ac9

Please sign in to comment.