Skip to content
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

Adding circuit executor classes and shot-branching #1766

Merged
merged 63 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
5684f13
adding executor classes for parallel simulations
doichanj Mar 17, 2023
a03bbb1
merge main
doichanj Mar 17, 2023
430ed9f
fix merge conflicts
doichanj Mar 23, 2023
4a0b8ec
Fix tensor_network method enablenment
doichanj Mar 24, 2023
e0ba7e6
simplify sub-classes
doichanj Mar 29, 2023
1cd3c73
fix unformatted code
doichanj Mar 30, 2023
0499009
Merge remote-tracking branch 'upstream/main' into add_executor
doichanj Mar 30, 2023
9fcd4e9
fix unformatted code again
doichanj Mar 30, 2023
f4fe17f
Fix MPI code
doichanj Mar 30, 2023
c6c2e6e
Fix shot-branching was not enabled with noise sampling
doichanj Apr 5, 2023
72faca7
Fix clang format
doichanj Apr 5, 2023
8945629
set_num_qubits to virtual function to set correct num qubits on matrix
doichanj Apr 6, 2023
cb0579c
reflecting review comments
doichanj Apr 7, 2023
b0c79a3
reuse of random number generator
doichanj Apr 7, 2023
6a56514
Merge remote-tracking branch 'upstream/main' into add_executor
doichanj Apr 7, 2023
6abd5ab
recover save_data_per_shot
doichanj Apr 17, 2023
9a9e3e7
Merge remote-tracking branch 'upstream/main' into add_executor
doichanj Apr 17, 2023
a7276f3
add missed omp threads setting in statevector, change class hieralchy
doichanj Apr 19, 2023
d02c782
Fix performance issue of GPU shot-branching
doichanj Apr 21, 2023
7fa4240
move fusion outside of loop for non noise dynamic circuits
doichanj May 19, 2023
846f645
Merge branch 'main' into add_executor
doichanj May 22, 2023
371dd62
fix shot-branching options in aer_compiler.py
doichanj May 22, 2023
16aa8a8
save codes before merge
doichanj Jun 13, 2023
a2ff17c
merge 0.12.1
doichanj Jun 13, 2023
d87af94
Fix format
doichanj Jun 13, 2023
c814b89
Merge remote-tracking branch 'upstream/main' into add_executor
doichanj Jun 14, 2023
907ab1b
Fix multi-chunk with cuStateVec
doichanj Jul 4, 2023
2acffce
format
doichanj Jul 4, 2023
2dbe800
format
doichanj Jul 4, 2023
009870a
Merge remote-tracking branch 'upstream/main' into add_executor
doichanj Jul 5, 2023
891f110
Merge remote-tracking branch 'upstream/main' into add_executor
doichanj Jul 7, 2023
fa9e1fc
add better multi-GPU distribution for shot-branching
doichanj Jul 10, 2023
7f0efee
Merge remote-tracking branch 'upstream/main' into add_executor
doichanj Jul 10, 2023
5fb9fbc
fix format
doichanj Jul 10, 2023
b682d9b
Changed option shot_branching_enable=False by default, add shot_branc…
doichanj Jul 11, 2023
2216225
format
doichanj Jul 11, 2023
ffd21d1
format test_shot_branching.py
doichanj Jul 11, 2023
138a1a0
Changed OpenMP threading for shot-branching
doichanj Jul 14, 2023
abbb719
Merge remote-tracking branch 'upstream/main' into add_executor
doichanj Jul 14, 2023
61bb0cb
mutable to matrix and param buffer
doichanj Jul 14, 2023
3353d11
format
doichanj Jul 14, 2023
07bffc2
add target_gpus option
doichanj Jul 28, 2023
c76ed74
Remove Python 3.7 from Github actions (#1819)
tungbq Jul 27, 2023
99c9e26
Fix missing dynamic link path for CUDA runtime and cuQuantum librarie…
doichanj Jul 27, 2023
67e6e8d
Fix OpenMP nested parallel (#1880)
doichanj Jul 27, 2023
8885eae
Support u3 gate application in Aer runtime API (#1876)
ibm-wakizaka Jul 27, 2023
0d553b0
Fix required_memory_mb (#1881)
doichanj Jul 27, 2023
daf3c19
format
doichanj Jul 31, 2023
2235462
format
doichanj Jul 31, 2023
dbe2300
format
doichanj Jul 31, 2023
fabfa63
comment out target_gpu setting for non-GPU
doichanj Jul 31, 2023
e66ab86
comment out target_gpu setting for non-GPU
doichanj Jul 31, 2023
c9c6150
Remove `PulseSimulator` (#1884)
hhorii Aug 2, 2023
e39e458
Fix an issue in `aer_state_initialize()` of C API (#1885)
hhorii Aug 3, 2023
a59e319
fix MPI shot-branching sampling
doichanj Aug 4, 2023
6fe5f04
fix unmerged file
doichanj Aug 7, 2023
8f07e97
remove conflict
doichanj Aug 9, 2023
e63e1e0
rerun tests
doichanj Aug 9, 2023
2170189
remove conflict
doichanj Aug 9, 2023
f566872
recover files
doichanj Aug 9, 2023
12b7d7b
remove conflict
doichanj Aug 9, 2023
36f0ea8
fix non-gpu
doichanj Aug 9, 2023
f1ee98d
update release note
doichanj Aug 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions qiskit_aer/backends/aer_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,8 @@ def compile_circuit(circuits, basis_gates=None, optypes=None):
"chunk_swap_buffer_qubits": (int, np.integer),
"batched_shots_gpu": (bool, np.bool_),
"batched_shots_gpu_max_qubits": (int, np.integer),
"shot_branching_enable": (bool, np.bool_),
"shot_branching_sampling_enable": (bool, np.bool_),
"num_threads_per_device": (int, np.integer),
"statevector_parallel_threshold": (int, np.integer),
"statevector_sample_measure_opt": (int, np.integer),
Expand All @@ -488,6 +490,7 @@ def compile_circuit(circuits, basis_gates=None, optypes=None):
"use_cuTensorNet_autotuning": (bool, np.bool_),
"parameterizations": (list),
"fusion_parallelization_threshold": (int, np.integer),
"target_gpus": (list),
}


Expand Down
31 changes: 31 additions & 0 deletions qiskit_aer/backends/aer_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ class AerSimulator(AerBackend):
If AerSimulator is built with cuStateVec support, cuStateVec APIs are enabled
by setting ``cuStateVec_enable=True``.

* ``target_gpus`` (list): List of GPU's IDs starting from 0 sets
the target GPUs used for the simulation.
If this option is not specified, all the available GPUs are used for
chunks/shots distribution.

**Additional Backend Options**

Expand Down Expand Up @@ -287,6 +291,30 @@ class AerSimulator(AerBackend):
threads per GPU. This parameter is used to optimize Pauli noise
simulation with multiple-GPUs (Default: 1).

* ``shot_branching_enable`` (bool): This option enables/disables
applying shot-branching technique to speed up multi-shots of dynamic
circutis simulations or circuits simulations with noise models.
(Default: False).
Starting from single state shared with multiple shots and
state will be branched dynamically at runtime.
This option can decrease runs of shots if there will be less branches
than number of total shots.
This option is available for ``"statevector"``, ``"density_matrix"``
and ``"tensor_network"``.

* ``shot_branching_sampling_enable`` (bool): This option enables/disables
applying sampling measure if the input circuit has all the measure
operations at the end of the circuit. (Default: False).
Because measure operation branches state into 2 states, it is not
efficient to apply branching for measure.
Sampling measure improves speed to get counts for multiple-shots
sharing the same state.
Note that the counts obtained by sampling measure may not be as same as
the counts calculated by multiple measure operations,
becuase sampling measure takes only one randome number per shot.
This option is available for ``"statevector"``, ``"density_matrix"``
and ``"tensor_network"``.

* ``accept_distributed_results`` (bool): This option enables storing
results independently in each process (Default: None).

Expand Down Expand Up @@ -709,6 +737,9 @@ def _default_options(cls):
batched_shots_gpu=False,
batched_shots_gpu_max_qubits=16,
num_threads_per_device=1,
# multi-shot branching
shot_branching_enable=False,
shot_branching_sampling_enable=False,
# statevector options
statevector_parallel_threshold=14,
statevector_sample_measure_opt=10,
Expand Down
20 changes: 17 additions & 3 deletions qiskit_aer/backends/wrappers/aer_controller_binding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ void bind_aer_controller(MODULE m) {
[](Config &config, uint_t val) {
config.num_threads_per_device.value(val);
});
// # multi-shot branching
aer_config.def_readwrite("shot_branching_enable",
&Config::shot_branching_enable);
aer_config.def_readwrite("shot_branching_sampling_enable",
&Config::shot_branching_sampling_enable);
// # statevector options
aer_config.def_readwrite("statevector_parallel_threshold",
&Config::statevector_parallel_threshold);
Expand Down Expand Up @@ -403,6 +408,10 @@ void bind_aer_controller(MODULE m) {
[](Config &config, uint_t val) {
config.extended_stabilizer_norm_estimation_default_samples.value(val);
});
aer_config.def_property(
"target_gpus",
[](const Config &config) { return config.target_gpus.val; },
[](Config &config, reg_t val) { config.target_gpus.value(val); });

aer_config.def(py::pickle(
[](const AER::Config &config) {
Expand Down Expand Up @@ -488,12 +497,14 @@ void bind_aer_controller(MODULE m) {
write_value(77, config.unitary_parallel_threshold),
write_value(78, config.memory_blocking_bits),
write_value(
79,
config.extended_stabilizer_norm_estimation_default_samples));
79, config.extended_stabilizer_norm_estimation_default_samples),
write_value(80, config.shot_branching_enable),
write_value(81, config.shot_branching_sampling_enable),
write_value(82, config.target_gpus));
},
[](py::tuple t) {
AER::Config config;
if (t.size() != 79)
if (t.size() != 82)
throw std::runtime_error("Invalid serialization format.");

read_value(t, 0, config.shots);
Expand Down Expand Up @@ -580,6 +591,9 @@ void bind_aer_controller(MODULE m) {
read_value(t, 78, config.memory_blocking_bits);
read_value(t, 79,
config.extended_stabilizer_norm_estimation_default_samples);
read_value(t, 80, config.shot_branching_enable);
read_value(t, 81, config.shot_branching_sampling_enable);
read_value(t, 82, config.target_gpus);
return config;
}));
}
Expand Down
30 changes: 30 additions & 0 deletions releasenotes/notes/add_executor-a03f2d23cf6f4ca9.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
features:
- |
This release restructures ``State`` classes.
Adding circuit executor classes that runs a circuit and manages multiple
states for multi-shots simulations or multi-chunk simulations for large
number of qubits.
Previously ``StateChunk`` class manages multiple chunks for multi-shots or
multi-chunk simulations but now ``State`` class only has one state
and all the parallelization codes are moved to ``Executor`` classes.
Now all ``State`` classes are independent from parallelization.
Also some of the functions in ``Aer::Controller`` class are moved to
``CircuitExecutor::Executor`` class.
- |
Shot-branching technique that accelerates dynamic circuits simulations
is implemented with restructured ``Executor`` classes.
Shot-branching is currently applicable to statevector density_matrix
and tensor_network methods.
Shot-branching provides dynamic distribution of multi-shots
by branching states when applying dynamic operations
(measure, reset, initialize, noises)
By default ``shot_branching_enable`` is disabled.
And by setting ``shot_branching_sampling_enable``, final measures will be
done by sampling measure that will speed up to get counts for multiple shots
sharing the same state.
- |
A new option ``target_gpus`` is added to select GPUs used for the
simulation. A list of target GPU's ID is passed for example
``target_gpus=[0, 2]`` select 2 GPUs to be used.
Without this option, all the available GPUs are used.
Loading