qsearch.backends

This module describes Backend, a class which is called before the Solver is run in order to replace a Python Qsearch circuit with a Qsearch circuit based on another implementation, such as Rust or GPU.

There are three provided Backend implementations:

qsearch.backends.PythonBackend

This simply returns the Python circuit, such that Python and Numpy are used for computation.

qsearch.backends.NativeBackend

This returns the converted circuit from native_from_object, which uses the Rust implementation of Qsearch circuits provided in the qsrs module.

qsearch.backends.SmartDefaultBackend

This backend tries to use the native Rust backend, but if it fails to convert the circuit (such as if there are unsupported gates), it will fallback to Python rather than throwing an error.

Module Contents

Classes

Backend

This class prepares a circuit for solving, replacing a Python circuit with another implementation.

SmartDefaultBackend

This Backend tries to use the native Rust code, but will gracefully fallback to Python if there is an issue.

PythonBackend

This Backend will simply return the Python Qsearch circuit passed in, therefore using Python and Numpy for matrix computation.

NativeBackend

This Backend will use the native Rust implementation of Qsearch circuits for faster matrix computation.

Attributes

RUST_ENABLED

qsearch.backends.RUST_ENABLED = True
class qsearch.backends.Backend(options=Options())

This class prepares a circuit for solving, replacing a Python circuit with another implementation.

abstract prepare_circuit(self, circ, options=None)

This function accepts a Python Qsearch circuit and returns a Qsearch circuit with a different implementation. :param circ: The Python Qsearch circuit to be converted.

class qsearch.backends.SmartDefaultBackend(options=Options())

Bases: Backend

This Backend tries to use the native Rust code, but will gracefully fallback to Python if there is an issue.

prepare_circuit(self, circuit, options=None)

This function accepts a Python Qsearch circuit and returns a Qsearch circuit with a different implementation. :param circ: The Python Qsearch circuit to be converted.

class qsearch.backends.PythonBackend(options=Options())

Bases: Backend

This Backend will simply return the Python Qsearch circuit passed in, therefore using Python and Numpy for matrix computation.

prepare_circuit(self, circuit, options=None)

This function accepts a Python Qsearch circuit and returns a Qsearch circuit with a different implementation. :param circ: The Python Qsearch circuit to be converted.

class qsearch.backends.NativeBackend(options=Options())

Bases: Backend

This Backend will use the native Rust implementation of Qsearch circuits for faster matrix computation.

prepare_circuit(self, circuit, options=None)

This function accepts a Python Qsearch circuit and returns a Qsearch circuit with a different implementation. :param circ: The Python Qsearch circuit to be converted.