quantumlib/Stim

`stim.CompiledDemSampler.sample(return_errors=True)` too slow when the error matrix is sparse

Opened this issue · 1 comments

I think in many cases it can be useful to get a "ground truth" when sampling errors. From my understanding the intended way to do so with Stim is stim.CompiledDemSampler.sample(return_errors=True). However this can be much slower than return_errors=False when the error matrix is sparse:

image

Would it be possible to return a sparse representation of the errors without so much time overhead?

I was expecting adding bit_packed=True to the sample call to save 8x on the overhead here, but it doesn't. This suggests there's something wrong other than the size of the output. I'll look into it. My best guess is that it has to do with transposing the data when moving from the internal representation to the external result.