qiboteam / qibo

A framework for quantum computing
https://qibo.science
Apache License 2.0
287 stars 58 forks source link

Speed up `circuit.unitary()` using sparse matrices #1344

Closed andrea-pasquale closed 3 months ago

andrea-pasquale commented 3 months ago

This PR proposes to speed up circuit.unitary() which returns the unitary corresponding to the circuit by performing the multiplication of all matrices gates using sparse matrices instead. I think that it makes sense given that most of times we are dealing with single and two qubit gates, which could be seen as sparse operators for large number of qubits.

Checklist:

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.82%. Comparing base (fc3a043) to head (9891ae2).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## sgd_callback #1344 +/- ## ============================================= Coverage 99.82% 99.82% ============================================= Files 72 72 Lines 10562 10572 +10 ============================================= + Hits 10543 10553 +10 Misses 19 19 ``` | [Flag](https://app.codecov.io/gh/qiboteam/qibo/pull/1344/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/qiboteam/qibo/pull/1344/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam) | `99.82% <100.00%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.