iqm.cpc.compiler.compilation_stage.compiler_pass#
- iqm.cpc.compiler.compilation_stage.compiler_pass(function)#
Wrap a compiler pass function to give it a uniform signature.
The first parameter of
functionis the data (e.g. circuits) the pass should process and then return. Stateful side effects can be achieved via manipulation the compiler context. Any other parameterfunctionmust be either asweepable pass option, or
default member of the compiler context, or
the literal
context: dict[str, Any].
The compiler context will always contain the default items in
DEFAULT_CONTEXT_KEYS. If a pass function needs a non-default item from the context (or wants to insert one), it must havecontextas one of its arguments. This way, the compiler context can be used to pass information from an earlier pass (or the user) to a later one.The wrapped pass function has the standard signature
wrapped_pass(data_: Any, context: dict[str, Any], options: dict[str, Any]) -> Any. The first parameter is the data (e.g. circuits) the pass should process. The second is the compiler context, and the third one contains any pass-specific options (which can be swept over).