"""Python bindings for the C4-Helix HUGR types and operations extensions."""importfunctoolsfromhugr.extimportExtension,ExtensionRegistry,OpDef,TypeDeffromhugr.opsimportExtOpfromhugr.std.intimportINT_TYPES_EXTENSIONfromhugr.tysimportExtTypefrom._utilimportload_extension,load_extension_json
[docs]classHelixTypesExtension:"""Extension providing linear Helix blocks and T-state resources."""
[docs]def__call__(self)->Extension:"""Return the Helix types extension."""returnload_extension("guppyft.helix.types")
@functools.cached_propertydefhelix_block_def(self)->TypeDef:"""A Helix block containing two logical qubits, labelled 0 and 1. For the instantiated type, see `helix_block`. """returnself().get_type("block")
[docs]defhelix_block(self)->ExtType:"""A Helix block containing two logical qubits, labelled 0 and 1."""returnself.helix_block_def.instantiate([])
@functools.cached_propertydefhelix_t_state_def(self)->TypeDef:"""An opaque, consumable T-state resource. For the instantiated type, see `helix_t_state`. """returnself().get_type("t_state")
[docs]classHelixOpsExtension:"""Extension providing Helix logical operations. Each block comprises two logical qubits, labelled 0 and 1. These indices are runtime HUGR inputs. """
[docs]def__call__(self)->Extension:"""Return the Helix ops extension with its type dependencies resolved."""registry=ExtensionRegistry.from_extensions([_HELIX_TYPES(),load_extension("guppyft.std.types"),INT_TYPES_EXTENSION,])returnExtension.from_json(load_extension_json("guppyft.helix.ops"),registry)
@functools.cached_propertydefprep_plus_def(self)->OpDef:"""Definition of the `prep_plus` operation. For the instantiated operation, see `prep_plus`. """returnself().get_op("prep_plus")
[docs]defprep_plus(self)->ExtOp:"""Prepare the ``|++>`` state on a block."""returnself.prep_plus_def.instantiate([])
@functools.cached_propertydefprep_zero_def(self)->OpDef:"""Definition of the `prep_zero` operation. For the instantiated operation, see `prep_zero`. """returnself().get_op("prep_zero")
[docs]defprep_zero(self)->ExtOp:"""Prepare the all-zero state on a block."""returnself.prep_zero_def.instantiate([])
@functools.cached_propertydefcx_between_blocks_def(self)->OpDef:"""Definition of the `cx_between_blocks` operation. For the instantiated operation, see `cx_between_blocks`. """returnself().get_op("cx_between_blocks")
[docs]defcx_between_blocks(self)->ExtOp:"""Targeted CX from the first block to the second. Runtime indices select the control and target. """returnself.cx_between_blocks_def.instantiate([])
@functools.cached_propertydefcx_def(self)->OpDef:"""Definition of the `cx` operation. For the instantiated operation, see `cx`. """returnself().get_op("cx")
[docs]defcx(self)->ExtOp:"""CX from logical qubit 0 to 1."""returnself.cx_def.instantiate([])
@functools.cached_propertydefcx_transversal_def(self)->OpDef:"""Definition of the `cx_transversal` operation. For the instantiated operation, see `cx_transversal`. """returnself().get_op("cx_transversal")
[docs]defcx_transversal(self)->ExtOp:"""Apply CX from each logical qubit in the first block to the corresponding logical qubit in the second block. """returnself.cx_transversal_def.instantiate([])
@functools.cached_propertydefcz_def(self)->OpDef:"""Definition of the `cz` operation. For the instantiated operation, see `cz`. """returnself().get_op("cz")
@functools.cached_propertydeffree_def(self)->OpDef:"""Definition of the `free` operation. For the instantiated operation, see `free`. """returnself().get_op("free")
[docs]deffree(self)->ExtOp:"""Discard a block."""returnself.free_def.instantiate([])
@functools.cached_propertydeffree_t_state_def(self)->OpDef:"""Definition of the `free_t_state` operation. For the instantiated operation, see `free_t_state`. """returnself().get_op("free_t_state")
[docs]deffree_t_state(self)->ExtOp:"""Discard an unused T-state resource."""returnself.free_t_state_def.instantiate([])
@functools.cached_propertydefh_all_def(self)->OpDef:"""Definition of the `h_all` operation. For the instantiated operation, see `h_all`. """returnself().get_op("h_all")
[docs]defh_all(self)->ExtOp:"""Hadamard on each logical qubit."""returnself.h_all_def.instantiate([])
@functools.cached_propertydefinject_t_def(self)->OpDef:"""Definition of the `inject_t` operation. For the instantiated operation, see `inject_t`. """returnself().get_op("inject_t")
[docs]definject_t(self)->ExtOp:"""Instantiate the `inject_t` operation. Consume a T-state resource and apply T to the logical qubit selected by a runtime index. """returnself.inject_t_def.instantiate([])
@functools.cached_propertydefinject_tdg_def(self)->OpDef:"""Definition of the `inject_tdg` operation. For the instantiated operation, see `inject_tdg`. """returnself().get_op("inject_tdg")
[docs]definject_tdg(self)->ExtOp:"""Instantiate the `inject_tdg` operation. Consume a T-state resource and apply Tdg to the logical qubit selected by a runtime index. """returnself.inject_tdg_def.instantiate([])
@functools.cached_propertydefmeasure_x_all_def(self)->OpDef:"""Definition of the `measure_x_all` operation. For the instantiated operation, see `measure_x_all`. """returnself().get_op("measure_x_all")
[docs]defmeasure_x_all(self)->ExtOp:"""Destructively measure both logical qubits in the X basis."""returnself.measure_x_all_def.instantiate([])
@functools.cached_propertydefmeasure_z_all_def(self)->OpDef:"""Definition of the `measure_z_all` operation. For the instantiated operation, see `measure_z_all`. """returnself().get_op("measure_z_all")
[docs]defmeasure_z_all(self)->ExtOp:"""Destructively measure both logical qubits in the Z basis."""returnself.measure_z_all_def.instantiate([])
@functools.cached_propertydefprep_t_state_def(self)->OpDef:"""Definition of the `prep_t_state` operation. For the instantiated operation, see `prep_t_state`. """returnself().get_op("prep_t_state")
[docs]defprep_t_state(self)->ExtOp:"""Instantiate the `prep_t_state` operation. Supply a resource which can be consumed to apply a T or Tdg gate to a logical qubit. """returnself.prep_t_state_def.instantiate([])
@functools.cached_propertydefqec_cycle_def(self)->OpDef:"""Definition of the `qec_cycle` operation. For the instantiated operation, see `qec_cycle`. """returnself().get_op("qec_cycle")
[docs]defqec_cycle(self)->ExtOp:"""Perform syndrome extraction and recovery (or a Pauli-frame update). Ideally preserves the logical state, including external entanglement. """returnself.qec_cycle_def.instantiate([])
@functools.cached_propertydefss_def(self)->OpDef:"""Definition of the `ss` operation. For the instantiated operation, see `ss`. """returnself().get_op("ss")
[docs]defss(self)->ExtOp:"""Logical S on both qubits."""returnself.ss_def.instantiate([])
@functools.cached_propertydefswap_def(self)->OpDef:"""Definition of the `swap` operation. For the instantiated operation, see `swap`. """returnself().get_op("swap")
[docs]defswap(self)->ExtOp:"""Swap the two qubits in the block."""returnself.swap_def.instantiate([])
@functools.cached_propertydefx_def(self)->OpDef:"""Definition of the `x` operation. For the instantiated operation, see `x`. """returnself().get_op("x")
[docs]defx(self)->ExtOp:"""Apply X to the logical qubit selected by a runtime index."""returnself.x_def.instantiate([])
@functools.cached_propertydefy_def(self)->OpDef:"""Definition of the `y` operation. For the instantiated operation, see `y`. """returnself().get_op("y")
[docs]defy(self)->ExtOp:"""Apply Y to the logical qubit selected by a runtime index."""returnself.y_def.instantiate([])
@functools.cached_propertydefz_def(self)->OpDef:"""Definition of the `z` operation. For the instantiated operation, see `z`. """returnself().get_op("z")
[docs]defz(self)->ExtOp:"""Apply Z to the logical qubit selected by a runtime index."""returnself.z_def.instantiate([])