Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accelerated implementation of objective function class for approximate quantum compiling #7697

Merged
merged 23 commits into from
Oct 28, 2022

Conversation

A-tA-v
Copy link
Contributor

@A-tA-v A-tA-v commented Feb 22, 2022

Summary

Accelerated implementation of objective function class for approximate quantum compiling

Details and comments

The objective function itself remains the same as in the current version (Frobenius norm of the difference between the target matrix and approximating circuit). However, the new implementation is significantly faster. It can be optionally selected along with the current version.

@A-tA-v A-tA-v requested a review from a team as a code owner February 22, 2022 13:02
@ajavadia
Copy link
Member

Thanks for the contribution. Is this a drop-in replacement or there are some trade-offs? If it's simply faster then I don't think we need to keep the old objective function. Also do you have some numbers about how much faster it is on an example input?

@A-tA-v
Copy link
Contributor Author

A-tA-v commented Apr 27, 2022

Hi Ali, thank you for your reponse. The default implementation might be interesting because it is easy to understand, if someone would like to see some technical details how the method does work. The accelerated code is harder to comprehend as it uses a lot of caching and transformations. Also, it uses more memory. Otherwise, you are right.
We are working on simplification of the accelerated implemenetation, but it will take quite a time to complete.
As for comparison, we can provide a speed-up vs number of qubits plot.

@ajavadia
Copy link
Member

Ok sounds good. Yes I think we can keep the old one around then for now. I had a look through the PR and it all looks pretty good. Once you put some benchmarking numbers here then I think we can merge.

@A-tA-v
Copy link
Contributor Author

A-tA-v commented Apr 29, 2022

This is the benchmarking result: accelerated implementation vs default (straightforward) one. The actual speedup may depend on Numpy version, number of CPU cores and hardware generation, whether the code is executed with multi-threading enabled or not, and so on. However, the performance of accelerated version is always consistently higher. On the chart you can see the speedup (averaged over various circuit depths) as a function of the number of qubits. We also show the dispersion of speedup measurements (plus/minus standard deviation around the mean).

speedup

@coveralls
Copy link

coveralls commented Apr 29, 2022

Pull Request Test Coverage Report for Build 3341797110

  • 420 of 435 (96.55%) changed or added relevant lines in 8 files are covered.
  • 43 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.02%) to 84.427%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/transpiler/synthesis/aqc/fast_gradient/layer.py 128 130 98.46%
qiskit/transpiler/synthesis/aqc/fast_gradient/fast_gradient.py 111 115 96.52%
qiskit/transpiler/synthesis/aqc/fast_gradient/pmatrix.py 99 103 96.12%
qiskit/transpiler/synthesis/aqc/fast_gradient/fast_grad_utils.py 74 79 93.67%
Files with Coverage Reduction New Missed Lines %
src/optimize_1q_gates.rs 1 95.16%
src/sampled_exp_val.rs 14 63.93%
src/results/marginalization.rs 28 72.41%
Totals Coverage Status
Change from base Build 3339680957: 0.02%
Covered Lines: 62113
Relevant Lines: 73570

💛 - Coveralls

@1ucian0 1ucian0 linked an issue May 25, 2022 that may be closed by this pull request
@HuangJunye HuangJunye added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Jun 21, 2022
@A-tA-v
Copy link
Contributor Author

A-tA-v commented Jul 29, 2022

Dear reviewers, could have a look at this pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community PR PRs from contributors that are not 'members' of the Qiskit repo
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants