qbraid.transpiler.transpile

transpile(program, target, conversion_graph=None, max_path_attempts=3, max_path_depth=None, **kwargs)[source]

Transpile a quantum program to a target language using a conversion graph. This function attempts to find a conversion path from the program’s current format to the target format. It can limit the search to a certain number of attempts and path depths.

Parameters:
  • program (qbraid.programs.QPROGRAM) – The quantum program to transpile.

  • target (str) – The target language to transpile to.

  • conversion_graph (Optional[ConversionGraph]) – The graph representing available conversions. If None, a default graph is used. Defaults to None.

  • max_path_attempts (int) – The maximum number of conversion paths to attempt before raising an exception. This is useful to avoid excessive computations when multiple paths are available. Defaults to 3.

  • max_path_depth (Optional[int]) – The maximum depth of conversions within a given path to allow. For example, a path with a depth of 2 would be [‘cirq’ -> ‘qasm2’ -> ‘qiskit’], whereas a depth of 1 would be a direct conversion [‘cirq’ -> ‘braket’]. Defaults to None, i.e. no limit set on the path depth.

Returns:

The transpiled quantum program.

Return type:

qbraid.programs.QPROGRAM

Raises: