Skip to content

Commit

Permalink
CircuitMPS add better errors for unsupported ops (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmgray committed Apr 25, 2024
1 parent 75a8569 commit 605868f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions quimb/tensor/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,9 @@ def build_controlled_gate_htn(
tags_all=None,
bond_ind=None,
):
"""Build a low rank hyper tensor network (CP-decomp like) representation of
a multi controlled gate.
"""
ngate = len(gate.qubits)
gate_shape = (2,) * (2 * ngate)
array = gate.array.reshape(gate_shape)
Expand Down Expand Up @@ -3615,6 +3618,17 @@ def __init__(
def _init_state(self, N, dtype="complex128"):
return MPS_computational_state("0" * N, dtype=dtype)

def _apply_gate(self, gate, tags=None, **gate_opts):
if gate.controls:
raise ValueError("`CircuitMPS` does not yet support `controls`.")

if len(gate.qubits) > 2:
raise ValueError(
"`CircuitMPS` does not yet support 3+ qubit gates."
)

super()._apply_gate(gate, tags=tags, **gate_opts)

@property
def psi(self):
# no squeeze so that bond dims of 1 preserved
Expand Down

0 comments on commit 605868f

Please sign in to comment.