mirror of https://github.com/Qiskit/qiskit.git
5f3c9969db
* Add base code * Add tests * Add more tests * move files to results and move imports * fix test * add more tests * change from dict to counts * Run black * Convert sampled exp val function to rust This commit rewrites the python implementation of the expectation value calculation to rust. The rust implementation should be significantly faster to compute the expectation value. * Fix lint * ignore cyclic import warning since inside func * black * Add some checks on inputs * Add release note * Speed up bitstring access in rust code This commit fixes the primary bottleneck in the rust expectation value calculation. The bit string access of the nth position previously used in the code was O(n) and for large numbers of qubits this access could add up in aggregate while computing the expectation value (even with profiling overhead for 127 qubit this was still roughly .3 seconds for calling the rust function). This commit adjusts how we access the nth character of the bit string to be O(1) and removing that bottlneck and for 127 qubit bit string provides a ~3x speedup. The tradeoff is that this isn't safe (in that there is potential incorrect behavior) if someone injects random unicode characters in the bitstring. However as this is unlikely making the change is worth it considering the speed up. After this commit the largest bottleneck is conversion overhead from python->rust and memory management of the temp rust object, at ~59% of the time to run the sampled_expval_complex() function, which is hard to workaround. Although, there might be further tuning to reduce the time required for the remaining 41%. * Update qiskit/result/sampled_expval.py If this works then yes indeed. Each operator appears to be coded differently so happy there is some overlap here Co-authored-by: Julien Gacon <gaconju@gmail.com> * explain raw dict inputs * Update test/python/result/test_sampled_expval.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Apply suggestions from code review Co-authored-by: John Lapeyre <jlapeyre@users.noreply.github.com> * Make oper_table_size a const variable instead of a magic number Co-authored-by: John Lapeyre <jlapeyre@users.noreply.github.com> Co-authored-by: Matthew Treinish <mtreinish@kortar.org> Co-authored-by: John Lapeyre <jlapeyre@users.noreply.github.com> Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> |
||
---|---|---|
.. | ||
results | ||
sabre_swap | ||
dense_layout.rs | ||
edge_collections.rs | ||
lib.rs | ||
nlayout.rs | ||
optimize_1q_gates.rs | ||
pauli_exp_val.rs | ||
sampled_exp_val.rs | ||
sparse_pauli_op.rs | ||
stochastic_swap.rs |