You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace std::vector<bool> with std::vector<char> for faster computations (#25)
While profiling tesseract, I noticed bottlenecks in the `to_node`
function and `VectorBoolHash` function class when testing **Surface Code
Transversal CX Protocols** for larger values of r, d and p
(specifically, **r=11,d=11** and **r=13,d=13** and **p=0.002**). A
significant percentage of decoding time was spent in code regions
operating with `std::vector<bool>` data structures. Using these data
structures to store boolean elements can be inefficient (see
https://www.geeksforgeeks.org/problem-with-std-vector-bool-in-cpp/ for
more detail).
In this PR, I replaced `std::vector<bool>` data structures inside the
`TesseractDecoder` class with `std::vector<char>` and retained
statements that were assigning true/false literal values to specific
elements, as they can be implicitly converted to a char (1 or 0). I also
slightly modified the logic for hashing the array of boolean elements in
the `VectorBoolHash` function class.
I tested and evaluated the performance impact of this optimization on a
**single shot/simulation of a quantum circuit for larger search problems
of Surface Code Transversal CX Protocols**. I performed 10 runs with a
fixed seed for generating a shot/simulation and detectors ordering and
computed the average decoding time across those runs.
Note that when performing runs of multiple shots, the optimization will
be propagated on each shot and the final result will contain performance
improvement aggregated (summed up) across each shot.

<b> Performance Impact on
Surface Code Transversal CX Protocols (r=13, d=13, p=0.0005, p=0.001,
Short Beam)</b>

<b> Performance
Impact on Surface Code Transversal CX Protocols (r=13, d=13, p=0.0005,
p=0.001, Long Beam)</b>

<b> Performance
Impact on Surface Code Transversal CX Protocols (r=13, d=13, p=0.002,
Short Beam)</b>

<b> Time Reduction in Key Functions
for Surface Code Transversal CX Protocols (r=13, d=13, p=0.002, Short
Beam)</b>
---------
Signed-off-by: Dragana Grbic <[email protected]>
0 commit comments