ngnrsaa / qflex

Flexible Quantum Circuit Simulator (qFlex) implements an efficient tensor network, CPU-based simulator of large quantum circuits.
Apache License 2.0
97 stars 25 forks source link

Reduce memory requirements #252

Closed benjaminvillalonga closed 4 years ago

benjaminvillalonga commented 4 years ago

Actual tensor sizes are taken into account for allocating space for the contraction, as opposed to ranks and the max bond dimension of the network. This reduces the memory requirements for contracting tensor networks with heterogeneous bond dimensions.

benjaminvillalonga commented 4 years ago

I have also added some new circuits that I should have committed separately. They are some of the circuits that would have allocated more memory than needed.

Meaningful changes happened in contraction_utils.*

s-mandra commented 4 years ago

It looks good to me. After fixing all the nits, I'm ok with merging this PR.

benjaminvillalonga commented 4 years ago

Some examples on memory usage and runtimes on a single core of my laptop: sycamore depth 6: 904 KB and 25 s rochester depth 20: 2.4 GB and 70 s bristlecone-48 depth 24: 52.8 MB and 7.5 s (with the current fidelity settings on the ordering file) bristlecone-70 depth 20: 7.3 MB and 191 s (with the current fidelity settings)

95-martin-orion commented 4 years ago

Some examples on memory usage and runtimes on a single core of my laptop: {...} bristlecone-70 depth 20: 7.3 MB and 191 s (with the current fidelity settings)

Was this run 7.3MB or 7.3GB? Either way, all of these numbers look good to me.

benjaminvillalonga commented 4 years ago

Was this run 7.3MB or 7.3GB? Either way, all of these numbers look good to me.

It was 7.26 MB. Great, merging!