pygsti.algorithms.compilers.compile_stabilizer_measurement#
- compile_stabilizer_measurement(s, p, pspec, absolute_compilation, paulieq_compilation, qubit_labels=None, iterations=20, paulirandomize=False, algorithm='COCAGE', aargs=None, costfunction='2QGC:10:depth:1', rand_state=None)#
Generates a circuit to map the stabilizer state to the standard state |0,0,0,…>.
The stabilizer state is specified by s and p. The circuit returned is over the gates in the processor spec pspec. See :function”compile_stabilizer_state() for the inverse of this. So, this circuit followed by a Z-basis measurement can be used to simulate a projection onto the stabilizer state C`|0,0,0,…>` where C is the Clifford represented by s and p.
- Parameters:
s (array over [0,1]) – An (2n X 2n) symplectic matrix of 0s and 1s integers. This is a symplectic matrix representing any Clifford gate that, when acting on |0,0,0,…>, generates the stabilizer state that we need to map to |0,0,0,…>. So s is not unique.
p (array over [0,1]) – A length-2n vector over [0,1,2,3] that, together with s, defines a valid n-qubit Clifford gate. This phase vector matrix should, together with s, represent any Clifford gate that, when acting on |0,0,0,…>, generates the stabilizer state that we need to map to |0,0,0,…>. So p is not unique.
pspec (QubitProcessorSpec, optional) –
An nbar-qubit QubitProcessorSpec object that encodes the device that the stabilizer is being compiled for, where nbar >= n. If this is specified, the output circuit is over the gates available in this device. If this is None, the output circuit is over the “canonical” processor of CNOT gates between all qubits, consisting of “H”, “HP”, “PH”, “HPH”, “I”, “X”, “Y” and “Z”, which is the set used internally for the compilation. In most circumstances, the output will be more useful if a QubitProcessorSpec is provided.
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.
absolute_compilation (CompilationRules) – Rules for exactly (absolutely) compiling the “native” gates of pspec into clifford gates.
paulieq_compilation (CompilationRules) – Rules for compiling, up to single-qubit Pauli gates, the “native” gates of pspec into clifford gates.
qubit_labels (List, optional) – Required if the stabilizer state 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.
iterations (int) – This algorithm is randomized. This is the number of iterations used in the algorithm. the time taken by this function increases linearly with iterations. Increasing iterations will often improve the obtained compilation (the “cost” of the obtained circuit, as specified by costfunction may decrease towards some asymptotic value).
paulirandomize (bool, optional) – If True then independent, uniformly random Pauli layers (a Pauli on each qubit) are inserted in between every layer in the circuit. These Paulis are then compiled into the gates in pspec, if pspec is provided. That is, this Pauli-frame-randomizes / Pauli-twirls the internal layers of this circuit. This can be useful for preventing coherent addition of errors in the circuit.
algorithm (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. algorithm specifies the CNOT-compilation algorithm to use. The allowed values are all those algorithms that 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.
aargs (list, optional) – If the CNOT compilation algorithm can take optional arguments, these are specified here. This is passed to compile_cnot_circuit() as aarg.
costfunction (function or string, optional) –
If a function, it is a function that takes a circuit and pspec as the first and second inputs and returns a ‘cost’ (a float) for the circuit. The circuit input to this function will be over the gates in pspec, if a pspec has been provided, and as described above if not. This costfunction is used to decide between different compilations when randomized algorithms are used: the lowest cost circuit is chosen. If a string it must be one of:
’2QGC’ : the cost of the circuit is the number of 2-qubit gates it contains.
’depth’ : the cost of the circuit is the depth of the circuit.
- ’2QGC:x:depth:y’the cost of the circuit is x * the number of 2-qubit gates in the circuit +
y * the depth of the circuit, where x and y are integers.
rand_state (RandomState, optional) – A np.random.RandomState object for seeding RNG
- Returns:
A circuit that maps the specified stabilizer state to |0,0,0,…>
- Return type: