Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Oxidize the internals of Optimize1qGatesDecomposition (Qiskit#9578)
* Oxidize the internals of Optimize1qGatesDecomposition This commit rewrites the internals of the Optimize1qGatesDecomposition transpiler pass to leverage more Rust. As the size of circuits are growing the amount of time the transpiler typically spends in Optimize1qGatesDecomposition grows linearly with the number of circuits. Since Qiskit#9185 (which converted the angle calculation in the synthesis routine to Rust) the time spent constructing intermediate DAGCircuit objects for each possible decomposition has been dominating the total runtime of the pass. To attempt to alleviate this bottleneck this commit mvoes as much of the circuit construction to rust as possible. The one qubit euler decomposition is now done in Rust and a sequence of gate names along with their corresponding angles are returned to the pass with the lowest error rate is returned. The pass will then convert that sequence into a DAGCircuit object if the decomposition will be substituted into the output dag. This has the advantage of both speeding up the computation of the output circuit and also deferring the creation of DAGCircuit and Gate objects until they're actually needed. * Move all error calculation to rust This commit makes 2 changes to the split between python and rust in the transpiler pass code. First the error mapping is converted to a rust native pyclass that increases the efficiency of getting the error rates for gates into the rust side. The second is any intermediate error scoring is done in rust. This is primarily to simplify the code as we're already doing the calculation with the new class in Rust. * Remove parallel iteration over multiple target basis This commit removes the usage of rayon for parallel iteration over the multiple target basis. In local benchmarking the overhead of using rayon to spawn a threadpool and divide the work over multiple threads hurts performance. The execution of the decomposition is sufficiently fast that iterating serially will be faster than spawning the threadpool for basis from current backends. So it's better to just remove the overhead. We can revisit parallelism in the future if it makes sense * Fix small oversights in internal pass usage This commit fixes the majority (if not all) the test failures that occured in earlier test failures. The primary cause of the failures were places that were calling private functions of the Optimize1qGatesDecomposition pass internally and not accounting for the new return types from some of those methods. This has been updated to handle these edge cases correctly now. Additionally, there was a small oversight in the porting of the numerics for the psx basis circuit generator function which was causing incorrect decompositions in some cases that has been fixed (the missing abs() call was added). * Add release note * Simplify logic to construct error map Co-authored-by: John Lapeyre <[email protected]> * Update comments, docstrings, and variable names in optimize_1q_decomposition * Make constant list of valid bases more local * Remove clippy unwrap suppression and use match syntax * Update releasenotes/notes/speedup-one-qubit-optimize-pass-483429af948a415e.yaml Co-authored-by: Jake Lishman <[email protected]> * Use to_object() instead of clone().into_py() * Remove out of date comment * Use FnOnce for X type in circuit_psx_gen * Add rem_euclid comment * Fix u3/u321 condition in _possible_decomposers --------- Co-authored-by: John Lapeyre <[email protected]> Co-authored-by: Jake Lishman <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information