Definitions¶
- class guppylang.defs.GuppyFunctionDefinition(wrapped: Definition)[source]¶
Bases:
GuppyDefinition,GuppyCompilableProgram,Generic[P,Out]A Guppy function definition.
- compile() Package[source]¶
Compiles an execution entrypoint function definition to a HUGR package
Equivalent to
GuppyDefinition.compile_entrypoint().- Returns:
The compiled package object.
- Return type:
Package
- Raises:
GuppyError – If the entrypoint has arguments.
- compile_function() Package[source]¶
Compile a Guppy function definition to HUGR.
- Returns:
The compiled package object.
- Return type:
Package
- compile_entrypoint() Package[source]¶
Compiles an execution entrypoint function definition to a HUGR package
- Returns:
The compiled package object.
- Return type:
Package
- Raises:
GuppyError – If the entrypoint has arguments.
- check() None¶
Type-check a Guppy definition.
- with_minimal_opt() OptimizerInstance[P, Out][source]¶
Configure the function to use minimal optimization when compiling.
Equivalent to with_opt_level(OptimizationLevel.Minimal).
- with_opt_level(level: OptimizationLevel) OptimizerInstance[P, Out][source]¶
Configure the optimization level used when compiling this function.
- emulator(n_qubits: int | None = None, builder: EmulatorBuilder | None = None, libs: list[Package] | None = None, platform: Literal['helios', 'sol'] = 'helios') EmulatorInstance[source]¶
Compile this function for emulation with the selene-sim emulator.
Compiles the function to a HUGR package and builds it using the provided EmulatorBuilder configuration or a default one.
See
guppylang.emulatorfor more details on the emulator.- Parameters:
n_qubits – The number of qubits to allocate for the function. If it is not
provided (use
builder.with_platform()in that case)needs (the function has to declare the expected number of qubits it)
@expected_qubits. (with the decorator)
builder – An optional EmulatorBuilder to use for building the emulator
provided
used. (the default EmulatorBuilder will be)
libs – An optional list of additional HUGR packages to link with the compiled
the (function. This can be used to provide additional library functions that)
on. (function being compiled depends)
platform – The quantum platform to target. Defaults to
"helios". Set tois ("sol" to target the Sol QIS. Ignored if an explicit builder)
provided
- Returns:
An EmulatorInstance that can be used to run the function in an emulator.
- class guppylang.defs.GuppyTypeVarDefinition(wrapped: Definition, _ty_var: TypeVar)[source]¶
Bases:
GuppyDefinitionDefinition of a Guppy type variable.
- compile() Package¶
Compile a Guppy definition to HUGR.
- check() None¶
Type-check a Guppy definition.
- class guppylang.defs.GuppyEnumDefinition(wrapped: Definition)[source]¶
Bases:
GuppyDefinitionA Guppy enum definition.
- class guppylang.defs.GuppyCompilableProgram(*args, **kwargs)[source]¶
Bases:
ProtocolA guppy definition for a program that can be compiled or emulated.
- compile() Package[source]¶
Compile an execution entrypoint to a HUGR package.
Alias for
compile_entrypoint().- Returns:
The compiled package object.
- Return type:
Package
- Raises:
GuppyError – If the entrypoint has arguments.
- compile_entrypoint() Package[source]¶
Compile an execution entrypoint to a HUGR package.
- Returns:
The compiled package object.
- Return type:
Package
- Raises:
GuppyError – If the entrypoint has arguments.
- compile_function() Package[source]¶
Compile the function definition to a HUGR package.
- Returns:
The compiled package object.
- Return type:
Package
- Raises:
GuppyError – If the function has arguments.
- emulator(n_qubits: int | None = None, builder: EmulatorBuilder | None = None, libs: list[Package] | None = None, platform: Literal['helios', 'sol'] = 'helios') EmulatorInstance[source]¶
Compile this function for emulation with the selene-sim emulator.
Compiles the function to a HUGR package and builds it using the provided EmulatorBuilder configuration or a default one.
See
guppylang.emulatorfor more details on the emulator.- Parameters:
n_qubits – The number of qubits to allocate for the function. If it is not
provided (use
builder.with_platform()in that case)needs (the function has to declare the expected number of qubits it)
@expected_qubits. (with the decorator)
builder – An optional EmulatorBuilder to use for building the emulator
provided
used. (the default EmulatorBuilder will be)
libs – An optional list of additional HUGR packages to link with the compiled
the (function. This can be used to provide additional library functions that)
on. (function being compiled depends)
platform – The quantum platform to target. Defaults to
"helios". Set tois ("sol" to target the Sol QIS. Ignored if an explicit builder)
provided
- Returns:
An EmulatorInstance that can be used to run the function in an emulator.