autoqasm.api module
This module implements the decorator API for generating programs using AutoQASM.
- autoqasm.api.main(func: Callable | None = None, *, num_qubits: int | None = None) Program | Callable[[...], Program][source]
Decorator that converts a function into a Program object containing the quantum program.
The decorator re-converts the target function whenever the decorated function is called, and a new Program object is returned each time.
- Parameters:
func (Callable | None) – Decorated function. May be
Nonein the case where decorator is used with parentheses.num_qubits (int | None) – Configuration to set the total number of qubits to declare in the program.
- Returns:
Program | Callable[…, Program] – The Program object containing the converted quantum program, or a partial function of the
maindecorator.
- autoqasm.api.subroutine(func: Callable | None = None, annotations: str | Iterable[str] | None = None) Callable[[...], Program][source]
Decorator that converts a function into a callable that will insert a subroutine into the quantum program.
- Parameters:
func (Callable | None) – Decorated function. May be
Nonein the case where decorator is used with parentheses.annotations (str | Iterable[str] | None) – Annotations to be added to the subroutine.
- Returns:
Callable[…, Program] – A callable which returns the converted quantum program when called.
- autoqasm.api.gate(func: Callable | None = None) Callable[[...], None][source]
Decorator that converts a function into a callable gate definition.
- Parameters:
func (Callable | None) – Decorated function. May be
Nonein the case where decorator is used with parentheses.- Returns:
Callable[…, None] – A callable which can be used as a custom gate inside an aq.function or inside another aq.gate.
- autoqasm.api.gate_calibration(*, implements: Callable, **kwargs) Callable[[], GateCalibration][source]
A decorator that register the decorated function as a gate calibration definition. The decorated function is added to a main program using
with_calibrationsmethod of the main program. The fixed values of qubits or angles that the calibration is implemented against are supplied as kwargs. The name of the kwargs must match the args of the gate function it implements.- Parameters:
implements (Callable) – Gate function.
- Returns:
Callable[[], GateCalibration] – A callable to be added to a main program using
with_calibrationsmethod of the main program.