This repository has been archived by the owner on Jun 12, 2023. It is now read-only.
faster SLSQP in measurement mitigation (code included) #520
Labels
enhancement
New feature or request
What is the expected behavior?
CompleteMeasFitter.filter.apply
was a bottleneck for my qiskit project, so I tried optimizing it.apply
calls Scipy'sminimize
using SLSQP to infer what the counts "should have been" given the known measurement error statistics. The cost function provided to minimize does some matrix multiplication. This is pretty fast, but given the large number of parameters (one for each state label, which I think will be ~2^N or thereabouts), I suspect (?) the gradient must be expensive (~2^N evaluations). Minimize gives an option to provide the gradient (jacobian) directly, so if the preceding logic is valid then it should speed up the fit routine by ~2^N. This is roughly consistent with a small test I ran for 5 qubits where it decreased the runtime for correcting some hundreds of circuits from ~5-10 seconds to <1 second. More testing would be a good idea (and maybe double-checking my pen-and-paper derivative is right...).Also added the jacobian for the constraint, not sure what effect this has but seemed easy enough.
I also changed the initial guess, formerly it was a list of small random values, now it's set to the measured (uncorrected) counts, since hopefully the errors will usually be small-ish so that should be a pretty good guess for the corrected values.
Code is below. Sorry it's annoying that this is an issue and not a PR, but as a qiskit user as opposed to a qiskit dev, I wanted to contribute this optimization but don't have the bandwidth right now to learn how to submit a PR, how to install the master branch, etc. Open to suggestions for low-barrier ways for users to give feedback.
New code:
qiskit/ignis/mitigation/measurement/filters.py
Old code:
The text was updated successfully, but these errors were encountered: