Shot branching optimization for multi-shots simulations #1606
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
I recreate this PR from PR #1596 because something is wrong to build Docs.
This PR is implementation of optimization for multi-shots simulations with operations with randomness (measure, reset, initialize, kraus or noise sampling)
Details and comments
Starting from 1 state, the simulation branches state into some states caused by randomness of the operation. Simulation time will be decreased when the number of the final branched states is smaller than number of shots.
To implement this optimization, I moved
qreg
andcreg
intoRegister
class and most of the functions ofState
class takes reference to theRegister
so that each function can handleRegister
class independently to manage multiple branched states.I implemented
run_shots
function inState
class that simulates multiple shots with or without shot branching optimization and also batched execution for GPU.Here is performance measurements of shot branching using QFT circuits with 1% of Kraus noise (1000 shots)
Since there are so many branches in noise simulation, the effect of this implementation is limited. Smaller noise ratio, larger qubits and larger number of shots will improve performance for this test case.
I think shot branching has more advantage in simulating circuits with intermediate measurements. (smaller number of branches)