encode¶
- guppyft.encode.encode(hugr: Package | GuppyFunctionDefinition[(), None], spec: EncodeSpec, *, passes: list[ComposablePass] | None = None) Package[source]¶
Encodes the given package (or Guppy function, directly compiled to a package for convenience) by applying four stages:
running the given computational passes;
lowering the operations in the package to logical operations and potentially performing static optimizations (e.g. resolving some qubit address assignments statically);
running additional logical passes (e.g. inserting additional QEC cycles); and
implementing the logical operations with physical gates.
The returned runnable package is guaranteed to be semantically equivalent to the given one.
- Parameters:
hugr – The package to encode (or Guppy function for convenience).
spec – See
EncoderSpec.passes – Computational passes to run on the given package. Defaults to one run of
Normalize.
- Returns:
The encoded runnable package.