qbraid.transpiler.Conversion

class Conversion(source, target, conversion_func, weight=None, bias=None)[source]

Class for defining and handling custom conversions between different quantum program packages.

Initialize a Conversion instance with source and target packages and a conversion function.

Parameters:
  • source (str) – The source package from which conversion starts.

  • target (str) – The target package to which conversion is done.

  • conversion_func (Callable) – The function that performs the actual conversion.

  • weight (Optional[float]) – Optional weighting factor for the conversion, ranging [0,1]. If not specified, defaults to 1 or a custom value derived from the conversion_func.

  • bias (Optional[float]) – Optional factor used to fine-tune the weight calculation and modify the decision thresholds for pathfinding. Defaults to 0. Higher values prioritize shorter paths. For example, a bias of 0.25 slightly favors a single conversion at weight 0.8 over two conversions at weight 1.0, whereas a bias of 0.1 requires a single conversion of weight > 0.9 to be preferred over two at weight 1.0.

__init__(source, target, conversion_func, weight=None, bias=None)[source]

Initialize a Conversion instance with source and target packages and a conversion function.

Parameters:
  • source (str) – The source package from which conversion starts.

  • target (str) – The target package to which conversion is done.

  • conversion_func (Callable) – The function that performs the actual conversion.

  • weight (Optional[float]) – Optional weighting factor for the conversion, ranging [0,1]. If not specified, defaults to 1 or a custom value derived from the conversion_func.

  • bias (Optional[float]) – Optional factor used to fine-tune the weight calculation and modify the decision thresholds for pathfinding. Defaults to 0. Higher values prioritize shorter paths. For example, a bias of 0.25 slightly favors a single conversion at weight 0.8 over two conversions at weight 1.0, whereas a bias of 0.1 requires a single conversion of weight > 0.9 to be preferred over two at weight 1.0.

Methods

__init__(source, target, conversion_func[, ...])

Initialize a Conversion instance with source and target packages and a conversion function.

convert(program)

Convert a quantum program from the source package to the target package.

Attributes

native

True if the conversion function is native to qbraid package, False otherwise.

source

The source package of the conversion.

supported

True if all packages required to perform the conversion are installed.

target

The target package of the conversion.

weight

The weight of the conversion function used to prioritize conversion paths.