That's pretty much it! There obviously is loads of optimizations that can be done, but it obscures the pretty standard linear algebra that is used to represent and calculate the states of the quantum computer!
A well-written version using OpenCL and written in rust is also available: http://github.com/qcgpu/qcgpu-rust if you are interested! Always looking for feedback
I've wondered - is it a common memory optimization tactic to store the individual qbit values until they become entangled and the product state cannot be factored? Or is entanglement common enough that it wouldn't be worth the overhead?
It depends! If you use a lot of scratch qubits, it can be useful to use sparse vectors, but if you are going to be doing a lot of superpositions / entangling many qubits, this isn't as effective, and performance suffers a lot. Libraries such as libquantum (written in C) use sparse state vectors, whereas the QCGPU library uses dense state vectors (as it is being stored on the GPU, it doesn't really impact the performance of the computer it's being simulated on). I benchmarked it, and the rust one was way faster for everything, apart from the initialization of registers and the application of some controlled gates
Comments
That's pretty much it! There obviously is loads of optimizations that can be done, but it obscures the pretty standard linear algebra that is used to represent and calculate the states of the quantum computer!
A well-written version using OpenCL and written in rust is also available: http://github.com/qcgpu/qcgpu-rust if you are interested! Always looking for feedback
I've wondered - is it a common memory optimization tactic to store the individual qbit values until they become entangled and the product state cannot be factored? Or is entanglement common enough that it wouldn't be worth the overhead?
It depends! If you use a lot of scratch qubits, it can be useful to use sparse vectors, but if you are going to be doing a lot of superpositions / entangling many qubits, this isn't as effective, and performance suffers a lot. Libraries such as libquantum (written in C) use sparse state vectors, whereas the QCGPU library uses dense state vectors (as it is being stored on the GPU, it doesn't really impact the performance of the computer it's being simulated on). I benchmarked it, and the rust one was way faster for everything, apart from the initialization of registers and the application of some controlled gates