From 605868fcac56f5d0ec5959dfd1ddf7644c72967f Mon Sep 17 00:00:00 2001 From: Johnnie Gray Date: Thu, 25 Apr 2024 16:35:13 -0700 Subject: [PATCH] CircuitMPS add better errors for unsupported ops (#230) --- quimb/tensor/circuit.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/quimb/tensor/circuit.py b/quimb/tensor/circuit.py index 27e21740..46755841 100644 --- a/quimb/tensor/circuit.py +++ b/quimb/tensor/circuit.py @@ -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) @@ -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