-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add support for "flat_sample": sampling without keys for performance #3808
Copy link
Copy link
Open
Labels
area/measurementsarea/performancearea/resultkind/feature-requestDescribes new functionalityDescribes new functionalitystatus/needs-agreed-designWe want to do this, but it needs an agreed upon design before implementationWe want to do this, but it needs an agreed upon design before implementationstatus/rfc-neededThis needs an RFC document.This needs an RFC document.triage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked onA consensus emerged that this bug report, feature request, or other action should be worked on
Metadata
Metadata
Assignees
Labels
area/measurementsarea/performancearea/resultkind/feature-requestDescribes new functionalityDescribes new functionalitystatus/needs-agreed-designWe want to do this, but it needs an agreed upon design before implementationWe want to do this, but it needs an agreed upon design before implementationstatus/rfc-neededThis needs an RFC document.This needs an RFC document.triage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked onA consensus emerged that this bug report, feature request, or other action should be worked on
Type
Fields
Give feedbackNo fields configured for issues without a type.
Currently Cirq has a bit of a performance problem. One of the contributing factors to this is that there are very few "escape hatches" that you can use to opt out of features that slow things down. This suggestion is to add one such escape hatch.
A "flat sample" is a 2d numpy uint8 array where the major index is "repetition index" and the minor axis lists off the output bits ordered by moment, then by within-moment order, then by qubit order within each measurement operation. If we want to go even more extreme, the array could be bit packed to reduce space usage by 8x although then it's much harder for people to use.
To be explicit:
Flat measurements can be more performant than non-flat measurements because they don't require scattering values across memory as they are collected. They also implicitly avoid key collision issues to do with measurements being repeated in a loop. This makes them much more amenable to e.g. error correction circuits.
I propose that we modify
Samplerto have aflat_sample(circuit)method that by default delegates toSampler.run, but which we then write more efficient implementations for in cirq.Simulator.