-
Notifications
You must be signed in to change notification settings - Fork 365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shot branching optimization for multi-shots simulations #1596
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just left reasons of some compilation errors.
break; | ||
case Gates::rzx: | ||
BaseState::qregs_[iChunk].apply_rotation(op.qubits, QV::Rotation::zx, std::real(op.params[0])); | ||
qreg.apply_rotation(op.qubits, QV::Rotation::zx, std::real(op.params[0])); | ||
break; | ||
case Gates::ecr: | ||
BaseState::qregs_[iChunk].apply_matrix(op.qubits, Linalg::VMatrix::ECR); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iChunk
is not defined.
break; | ||
case Gates::rzx: | ||
apply_matrix(op.qubits, Linalg::VMatrix::rzx(op.params[0])); | ||
apply_matrix(state, op.qubits, Linalg::VMatrix::rzx(op.params[0])); | ||
break; | ||
case Gates::ecr: | ||
apply_matrix(op.qubits, Linalg::VMatrix::ECR); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no matching member function for call to 'apply_matrix'
@@ -632,26 +509,27 @@ bool StateChunk<state_t>::allocate_qregs(uint_t num_chunks) | |||
//allocate qregs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qregs_
is not defined.
Current interface of
Though For 0.12, I think we do not need such refactoring, but for 0.13, we need refactoring. |
@doichanj will create a new shot-branch implementation with some refactoring work in State classes. |
Summary
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)