:py:mod:`qsearch.backends` ========================== .. py:module:: qsearch.backends .. autoapi-nested-parse:: 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: .. attribute:: PythonBackend This simply returns the Python circuit, such that Python and Numpy are used for computation. .. attribute:: NativeBackend This returns the converted circuit from native_from_object, which uses the Rust implementation of Qsearch circuits provided in the qsrs module. .. attribute:: 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 ~~~~~~~ .. autoapisummary:: qsearch.backends.Backend qsearch.backends.SmartDefaultBackend qsearch.backends.PythonBackend qsearch.backends.NativeBackend Attributes ~~~~~~~~~~ .. autoapisummary:: qsearch.backends.RUST_ENABLED .. py:data:: RUST_ENABLED :annotation: = True .. py:class:: Backend(options=Options()) This class prepares a circuit for solving, replacing a Python circuit with another implementation. .. py:method:: prepare_circuit(self, circ, options=None) :abstractmethod: 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. .. py:class:: SmartDefaultBackend(options=Options()) Bases: :py:obj:`Backend` This Backend tries to use the native Rust code, but will gracefully fallback to Python if there is an issue. .. py:method:: 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. .. py:class:: PythonBackend(options=Options()) Bases: :py:obj:`Backend` This Backend will simply return the Python Qsearch circuit passed in, therefore using Python and Numpy for matrix computation. .. py:method:: 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. .. py:class:: NativeBackend(options=Options()) Bases: :py:obj:`Backend` This Backend will use the native Rust implementation of Qsearch circuits for faster matrix computation. .. py:method:: 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.