Git Product home page Git Product logo

Comments (4)

Renmusxd avatar Renmusxd commented on September 14, 2024

Thanks for the interest. I actually don't use raw matrix multiplication for the bulk of the backend calculations. That's because most linalg libraries don't know how to exploit the tensor product structure of quantum circuits. By knowing how the matrices are constructed, as a tensor product of smaller matrices, we never need to construct the full matrix and can skip entries we know will be 0. This is faster even than sparse representations.

I should set up some benchmarks to explicitly compare this though.

from rustqip.

mert-kurttutan avatar mert-kurttutan commented on September 14, 2024

Yeah, I have not checked the codebase in super detail. Just tossing around this idea in case some of the ops can be formulated in a way that is relevant to faer rs

from rustqip.

Renmusxd avatar Renmusxd commented on September 14, 2024

Added some benchmarks across a few backends.
Here I'm just testing a single 2x2 matrix applied to qubit 0 and identity applied elsewhere -- most benchmarks are on 12 qubits, the "large" ones are on 15 qubits.
I test 4 backends: qip (this library), ndarray, sprs (sparse matrices), and faer.

test tests::bench_ones_faer_reuse_arena      ... bench:   6,446,267 ns/iter (+/- 47,841)
test tests::bench_ones_ndarray_build_each    ... bench: 142,738,247 ns/iter (+/- 980,752)
test tests::bench_ones_ndarray_reuse         ... bench:   4,600,275 ns/iter (+/- 404,325)
test tests::bench_ones_ndarray_reuse_arena   ... bench:   4,604,027 ns/iter (+/- 562,828)
test tests::bench_ones_qip                   ... bench:      58,430 ns/iter (+/- 1,756)
test tests::bench_ones_qip_large             ... bench:   1,289,297 ns/iter (+/- 23,239)
test tests::bench_ones_sprs_build_each       ... bench:     103,473 ns/iter (+/- 637)
test tests::bench_ones_sprs_build_each_large ... bench:  38,890,543 ns/iter (+/- 616,850)
test tests::bench_ones_sprs_reuse            ... bench:      17,702 ns/iter (+/- 205)
test tests::bench_ones_sprs_reuse_large      ... bench:   5,318,135 ns/iter (+/- 47,856)

It looks like faer isn't performing very well compared to the others so I'm worried I didn't write the benchmark properly, if you're familiar with the library I'm open to changes.

from rustqip.

Renmusxd avatar Renmusxd commented on September 14, 2024

Followup: After talking with the faer devs on their discord it seems it isn't really the best choice for backend. Their matrix on vector support is not prioritized and performs no better than using blas with 1 thread. I'll close this for now but keep the bench around.

from rustqip.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.