Skip to content

Commit

Permalink
Fixing inconsist usage of DirMPS when describing canonical form
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloAndresCQ committed Nov 29, 2024
1 parent 1e12786 commit 5716d28
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion pytket/extensions/cutensornet/structured_state/mps.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@


class DirMPS(Enum):
"""An enum to refer to relative directions within the MPS."""
"""An enum to refer to relative directions within the MPS.
When used to refer to the canonical form of a tensor, LEFT means that its conjugate
transpose is its inverse when connected to its left bond and physical bond.
Similarly for RIGHT.
"""

LEFT = 0
RIGHT = 1
Expand Down
8 changes: 4 additions & 4 deletions pytket/extensions/cutensornet/structured_state/mps_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ def _apply_2q_unitary_nonadjacent(
optimize={"path": [(0, 1)]},
)

# The site tensor is now in canonical form (since S is contracted to the right)
self.canonical_form[l_pos] = DirMPS.RIGHT # type: ignore
# The site tensor is now in canonical form
self.canonical_form[l_pos] = DirMPS.LEFT # type: ignore

# Next, "push" the `msg_tensor` through all site tensors between `l_pos`
# and `r_pos`. Once again, this is just contract_decompose on each.
Expand All @@ -306,7 +306,7 @@ def _apply_2q_unitary_nonadjacent(
)

# The site tensor is now in canonical form
self.canonical_form[pos] = DirMPS.RIGHT # type: ignore
self.canonical_form[pos] = DirMPS.LEFT # type: ignore

# Finally, contract the `msg_tensor` with the site tensor in `r_pos` and the
# `r_gate_tensor` from the decomposition of `gate_tensor`
Expand Down Expand Up @@ -402,7 +402,7 @@ def _apply_2q_unitary_nonadjacent(
# Since we are contracting S to the "left" in `svd_method`, the site tensor
# at `pos+1` is canonicalised, whereas the site tensor at `pos` is the one
# where S has been contracted to and, hence, is not in canonical form
self.canonical_form[pos + 1] = DirMPS.LEFT # type: ignore
self.canonical_form[pos + 1] = DirMPS.RIGHT # type: ignore
self.canonical_form[pos] = None
# Update fidelity lower bound
this_fidelity = 1.0 - info.svd_info.discarded_weight
Expand Down

0 comments on commit 5716d28

Please sign in to comment.