valid_stabilizer_state_preparation¶
- guppyft.verify.valid_stabilizer_state_preparation(semantic_function: SemanticStabilizerState | SemanticStabilizerStateDouble, impl_function: ImplementationStabilizerState | ImplementationStabilizerStateDouble, code_definition: StabilizerCode, n_impl_ancillas: int | None = None) bool[source]¶
Checks whether impl_function is a valid implementation of semantic_function.
Validates the implementation of a logical state preparation function. The program must contain only Clifford gates and measurements. The resulting state may be on a single code block or entangle two code blocks.
- Parameters:
semantic_function – A Guppy function for semantic action of Pauli eigenstate preparation over one or two code blocks.
impl_function – A Guppy function for preparing the logical eigenstate over one or two code blocks.
code_definition – A stabilizer code with well-defined \([[n, k, d]]\) parameters, stabilizer generators, and logical operators.
n_impl_ancillas – The number of ancilla qubits used in the implementation. Defaults to None meaning that no ancilla qubits are used by default.
- Returns:
A Boolean indicating whether the state preparation is valid.
from guppylang import guppy from guppylang.std.builtins import array from guppylang.std.quantum import cx, h, qubit from guppyft.code_def import StabilizerCode from guppyft.verify import valid_stabilizer_state_preparation CSS_4Q_DEF = StabilizerCode.from_python_strings( n_physical_qubits=4, n_logical_qubits=2, distance=2, generators=["XXXX", "ZZZZ"], x_logicals=["XXII", "XIXI"], z_logicals=["IZIZ", "IIZZ"], ) @guppy def specify_zero_state() -> array[qubit, 2]: return array(qubit() for _ in range(2)) @guppy def implement_non_ft_zero_state() -> array[qubit, 4]: block = array(qubit() for _ in range(4)) h(block[0]) cx(block[0], block[1]) cx(block[0], block[2]) cx(block[0], block[3]) return block assert valid_stabilizer_state_preparation( specify_zero_state, implement_non_ft_zero_state, CSS_4Q_DEF, )