pygsti.algorithms.compilers.compile_conditional_symplectic

pygsti.algorithms.compilers.compile_conditional_symplectic#

compile_conditional_symplectic(s, pspec, qubit_labels=None, calg='COiCAGE', cargs=None, check=True, rand_state=None)#

Finds circuits that partially (conditional on the input) implement the Clifford given by s.

The core of the compile_stabilizer_state() and compile_stabilizer_measurement() functions. Finds circuits C1 and C2 so that:

  1. C1 is a CNOT circuit

  2. C2 is a circuit with the form 1-qubit-gates – CNOT circuit – 1-qubit gates.

  3. The symplectic rep of the circuit consisting of C1 followed by C2 has the form ((.,B)(.,D)) when s has the form ((A,B),(C,D)).

Therefore, the circuit C2 acting on |0,0,0,…> generates the same stabilizer state (up to Paulis) as a circuit that has the symplectic rep (s,p) for any valid p. The circuit is only “conditionally” equivalent to another circuit with the rep (s,p) – conditional on the input state – which is the meaning of the name compile_conditional_symplectic.

Parameters:
  • s (array over [0,1]) – An (2n X 2n) symplectic matrix of 0s and 1s integers.

  • pspec (QubitProcessorSpec, optional) – An nbar-qubit QubitProcessorSpec object that encodes the device that s is being “conditionally” compiled for, where nbar >= n. If nbar > n it is necessary to provide qubit_labels, that specifies which of the qubits in pspec the stabilizer is over. (All other qubits will not be part of the returned circuit, regardless of whether that means an over-head is required to avoid using gates that act on those qubits. If these additional qubits should be used, then the input (s,p) needs to be “padded” to be the identity on those qubits). The ordering of the indices in (s,`p`) is w.r.t to ordering of the qubit labels in pspec.qubit_labels, unless qubit_labels is specified. Then, the ordering is taken w.r.t the ordering of the list qubit_labels.

  • qubit_labels (List, optional) – Required if the s is over less qubits than pspec. In this case this is a list of the qubits to compile the Clifford for; it should be a subset of the elements of pspec.qubit_labels. The ordering of the qubits in (s,`p`) is taken w.r.t the ordering of this list.

  • calg (str, optional) – Our algorithm finds a circuit consisting of 1Q-gates - a CNOT circuit - 1Q-gates. The CNOT circuit is found using Gaussian elimination, and it can then be recompiled using a CNOT-circuit compiler. calg specifies the CNOT-compilation algorithm to use. The allowed values are all those algorithms that are permisable in the compile_cnot_circuit() function. See the docstring of that function for more information. The default is likely to be the best out of the in-built CNOT compilers under most circumstances. Note that this is only used to recompile the CNOT circuit in C2, because the main use for this function only needs C1 for reference, rather than as a part of a final output.

  • cargs (list, optional) – If the CNOT compilation algorithm can take optional arguments, these are specified here. This is passed to compile_cnot_circuit() as aarg.

  • check (bool, optional) – Whether to check that the output is correct.

  • rand_state (RandomState, optional) – A np.random.RandomState object for seeding RNG

Returns:

  • Circuit – The circuit C2 described above.

  • Circuit – The circuit C1 described above.