QuantumComputer.compile(program, to_native_gates=True, optimize=True, protoquil_positional=None, *, protoquil=None)[source]

A high-level interface to program compilation.

Compilation currently consists of two stages. Please see the AbstractCompiler docs for more information. This function does all stages of compilation.

Right now both to_native_gates and optimize must be either both set or both unset. More modular compilation passes may be available in the future.

Additionally, a call to compile also calls the reset method if one is running on the QPU. This is a bit of a sneaky hack to guard against stale compiler connections, but shouldn’t result in any material hit to performance (especially when taking advantage of parametric compilation for hybrid applications).

  • program (Program) – A Program
  • to_native_gates (bool) – Whether to compile non-native gates to native gates.
  • optimize (bool) – Whether to optimize the program to reduce the number of operations.
  • protoquil (Optional[bool]) – Whether to restrict the input program to and the compiled program to protoquil (executable on QPU). A value of None means defer to server.
Return type:

Union[BinaryExecutableResponse, PyQuilExecutableResponse]


An executable binary suitable for passing to QuantumComputer.run().