:py:mod:`qsearch.post_processing` ================================= .. py:module:: qsearch.post_processing .. autoapi-nested-parse:: This module defines PostProcessor, a class used to modify circuits after they have been synthesized. Several implementations are provided. .. attribute:: BasicSingleQubitReduction_PostProcessor Attempts to remove single-qubit gates without sacrificing the quality of the solution in terms of eval_func .. attribute:: ParameterTuning_PostProcessor Attempts to reduce eval_func simply by re-running the solver with stronger parameters. .. attribute:: LEAPReoptimizing_PostProcessor Reduces the length of circuits produced using LEAP by re-running segments of the circuit. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: qsearch.post_processing.PostProcessor qsearch.post_processing.BasicSingleQubitReduction_PostProcessor qsearch.post_processing.ParameterTuning_PostProcessor qsearch.post_processing.LEAPReoptimizing_PostProcessor .. py:class:: PostProcessor(options=opt.Options()) This class is used to modify circuits that have already been synthesized. .. py:method:: post_process_circuit(self, result, options=None) Processes the circuit dictionary and returns a new one. :param result: A dictionary containing a synthesized circuit. Expect it to contain "structure" and "parameters", but it may contain more, depending on what previous PostProcessors were run and on the compiler. :returns: A dictionary containing any updates that should be made to the circuit dictionary, such as new values for "structure" or "parameters" or arbitrary other data. :rtype: dict .. py:class:: BasicSingleQubitReduction_PostProcessor(options=opt.Options()) Bases: :py:obj:`PostProcessor` Attempts to reduce the number of single-qubit gates in a circuit by sequentially removing a gate, attempting to use a Solver on it, and keeping that gate removed if successful. .. py:method:: post_process_circuit(self, result, options=None) Processes the circuit dictionary and returns a new one. :param result: A dictionary containing a synthesized circuit. Expect it to contain "structure" and "parameters", but it may contain more, depending on what previous PostProcessors were run and on the compiler. :returns: A dictionary containing any updates that should be made to the circuit dictionary, such as new values for "structure" or "parameters" or arbitrary other data. :rtype: dict .. py:class:: ParameterTuning_PostProcessor(options=opt.Options()) Bases: :py:obj:`PostProcessor` Attempts to reduce the eval_func value of the circuit simply by tuning the parameters better using stronger Solver parameters. .. py:method:: post_process_circuit(self, result, options=None) Processes the circuit dictionary and returns a new one. :param result: A dictionary containing a synthesized circuit. Expect it to contain "structure" and "parameters", but it may contain more, depending on what previous PostProcessors were run and on the compiler. :returns: A dictionary containing any updates that should be made to the circuit dictionary, such as new values for "structure" or "parameters" or arbitrary other data. :rtype: dict .. py:class:: LEAPReoptimizing_PostProcessor(options=Options()) Bases: :py:obj:`qsearch.compiler.Compiler`, :py:obj:`PostProcessor` A PostProcessor that re-optimizes LeapCompiler-compiled circuits via search. This PostProcessor puts "holes" in the circuit where LEAP fixed prefixes and runs qsearch on those holes to reduce the total number of gates. .. py:method:: post_process_circuit(self, result, options=None) Re-optimize a LEAP circuit. Pass "depth" to indicate the size to re-synthesize. It is recommended to call like: `project.post_process(post_processing.LEAPReoptimizing_PostProcessor(), solver=multistart_solvers.MultiStart_Solver(8), parallelizer=parallelizers.ProcessPoolParallelizer, depth=7)` .. py:method:: compile(self, options=Options()) Backwards compatible interface since this is technically a Compiler. You should use LEAPReoptimizing_PostProcessor.post_process_circuit with the Project post_processing API.