OptimizerInstance¶
- class guppylang.optimizer.OptimizerInstance(definition: GuppyFunctionDefinition[P, Out], passes: list[ComposablePass] = <factory>, target_platform: Platform | None = None)[source]¶
Builder used to configure optimizations for compiling a Guppy program.
Obtained by calling
GuppyFunctionDefinition.with_opt_level()orGuppyFunctionDefinition.with_minimal_opt().See
guppylang.optimizerfor usage examples.- __delattr__(name)¶
Implement delattr(self, name).
- __eq__(other)¶
Return self==value.
- __init__(definition: GuppyFunctionDefinition[P, Out], passes: list[ComposablePass] = <factory>, target_platform: Platform | None = None) None¶
- __repr__()¶
Return repr(self).
- __setattr__(name, value)¶
Implement setattr(self, name, value).
- __type_params__ = (P, Out)¶
- compile_entrypoint(debug_mode: bool = False) Package[source]¶
Compile an entrypoint with the configured optimizations.
- compile_function(debug_mode: bool = False) Package[source]¶
Compile a function with the configured optimizations.
- definition: GuppyFunctionDefinition[P, Out]¶
- emulator(n_qubits: int | None = None, builder: EmulatorBuilder | None = None, libs: list[Package] | None = None, platform: Platform | None = None, debug_mode: bool = False) EmulatorInstance[source]¶
Compile this function for emulation with the configured optimizations.
Emulation in debug mode (enabling panic traces) requires minimal optimization.
- target_platform: Platform | None = None¶
- with_minimal_opt() OptimizerInstance[P, Out][source]¶
Configure the function to use minimal optimization when compiling.
Equivalent to with_opt_level(OptimizationLevel.Minimal), thus it overrides any previously configured optimization level or custom passes.
- with_opt_level(level: OptimizationLevel) OptimizerInstance[P, Out][source]¶
Configure the optimization level used when compiling this function.
This overrides any previously configured optimization level or custom passes.
- with_optimization(optimization: ComposablePass) OptimizerInstance[P, Out][source]¶
Add an additional optimization pass to run while compiling the program.
- with_target_platform(platform: Platform) OptimizerInstance[P, Out][source]¶
Set the default platform used by the emulator.