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

add auto-configuration of threads for qasm simulator #61

Merged
merged 29 commits into from
Apr 7, 2019
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e082608
add auto-configuration of threads for qasm simulator
hhorii Feb 19, 2019
7b0d936
reduce test overheads of qasm_thread_management
hhorii Feb 19, 2019
58c660b
work around set_parallelization in stabilizer.
hhorii Feb 20, 2019
9b22976
Merge remote-tracking branch 'upstream/master' into refactor_thread
hhorii Feb 20, 2019
00de273
handle automatic simulation types in set_parallelization
hhorii Feb 21, 2019
3c34cd6
Merge remote-tracking branch 'upstream/master' into refactor_thread
hhorii Feb 21, 2019
120b231
use Statevector::State instead of QubitVector::State
hhorii Feb 21, 2019
dd5fd52
enable shot parallelization in qasm simulator. enable nested parallel…
hhorii Feb 22, 2019
a4d2014
Merge remote-tracking branch 'upstream/master' into refactor_thread
hhorii Mar 5, 2019
92f4482
add comment on parallelization in qasm controller
hhorii Mar 6, 2019
a5d0c52
support multiple calls of set_config
hhorii Mar 8, 2019
3a9bdda
refactor set_parallelization
hhorii Mar 23, 2019
3c0d068
Merge remote-tracking branch 'upstream/master' into refactor_thread
hhorii Mar 23, 2019
e5a9916
use qiskit.util instead of qiskit._util
hhorii Mar 26, 2019
474f7c8
change thread management
hhorii Mar 25, 2019
99e0d0b
relaxed test criteria for ch
hhorii Mar 26, 2019
8704fcb
Merge commit '99e0d0b' into refactor_thread
hhorii Mar 26, 2019
76d2a59
Merge remote-tracking branch 'upstream/master' into refactor_thread
hhorii Mar 26, 2019
11b44b6
use max_memory_mb instead of available_memory
hhorii Mar 27, 2019
0806235
Merge remote-tracking branch 'upstream/master' into refactor_thread
hhorii Mar 27, 2019
4fe7eff
Merge remote-tracking branch 'upstream/master' into refactor_thread
hhorii Apr 2, 2019
ebcfc36
modify thread tests
hhorii Apr 2, 2019
c52f8c5
QuantumChannel integration with noise (#107)
hhorii Apr 3, 2019
17b08d7
use max_memory_mb in aerbackend
hhorii Apr 3, 2019
ba2af7b
resolve conflict in aerbackend
hhorii Apr 3, 2019
182aeb5
Merge remote-tracking branch 'upstream/master' into refactor_thread
hhorii Apr 3, 2019
cb8fbd4
add change log for this change of thread management
hhorii Apr 3, 2019
e06e245
* Merge branch 'master' into refactor_thread
atilag Apr 5, 2019
0b51d29
* Changing loop variables from unsigned to signed because of OpenMP 2
atilag Apr 7, 2019
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
36 changes: 30 additions & 6 deletions contrib/standalone/qasm_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@

enum class CmdArguments {
SHOW_VERSION,
INPUT_CONFIG,
INPUT_DATA
};

inline CmdArguments parse_cmd_options(const std::string& argv){
if(argv == "-v" || argv == "--version"){
return CmdArguments::SHOW_VERSION;
return CmdArguments::SHOW_VERSION;
} else if (argv == "-c" || argv == "--config"){
return CmdArguments::INPUT_CONFIG;
}
return CmdArguments::INPUT_DATA;
}
Expand All @@ -54,16 +57,18 @@ inline void usage(const std::string& command, std::ostream &out){
show_version();
std::cerr << "\n";
std::cerr << "Usage: \n";
std::cerr << command << " [-v] <file>\n";
std::cerr << " -v Show version\n";
std::cerr << " file : qobj file\n";
std::cerr << command << " [-v] [-c <config>] <file>\n";
std::cerr << " -v : Show version\n";
std::cerr << " -c <config> : Configuration file\n";;
std::cerr << " file : qobj file\n";
}

int main(int argc, char **argv) {

std::ostream &out = std::cout; // output stream
int indent = 4;
json_t qobj;
json_t config;

if(argc == 1){
usage(std::string(argv[0]), out);
Expand All @@ -76,9 +81,22 @@ int main(int argc, char **argv) {
case CmdArguments::SHOW_VERSION:
show_version();
return 0;
case CmdArguments::INPUT_CONFIG:
if (++pos == static_cast<unsigned int>(argc)) {
failed("Invalid config (no file is specified.)", out, indent);
return 1;
}
try {
config = JSON::load(std::string(argv[pos]));
}catch(std::exception &e){
std::string msg = "Invalid config (" + std::string(e.what()) + ")";
failed(msg, out, indent);
return 1;
}
break;
case CmdArguments::INPUT_DATA:
try {
qobj = JSON::load(std::string(argv[1]));
qobj = JSON::load(std::string(argv[pos]));
pos = argc; //Exit from the loop
}catch(std::exception &e){
std::string msg = "Invalid input (" + std::string(e.what()) + ")";
Expand All @@ -94,8 +112,14 @@ int main(int argc, char **argv) {

// Initialize simulator
AER::Simulator::QasmController sim;

// Check for config
sim.set_config(qobj["config"]);
json_t config_all = qobj["config"];
if (!config.empty())
config_all.update(config.begin(), config.end());

sim.set_config(config_all);

out << sim.execute(qobj).dump(4) << std::endl;

return 0;
Expand Down
6 changes: 3 additions & 3 deletions qiskit/providers/aer/backends/aerbackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ def _format_qobj_str(self, qobj, backend_options, noise_model):
if backend_options is not None:
for key, val in backend_options.items():
config[key] = val
if "available_memory" not in config:
available_mb = int(local_hardware_info()['memory'] * 1024)
config['available_memory'] = available_mb
if "max_memory_mb" not in config:
max_memory_mb = int(local_hardware_info()['memory'] * 1024 / 2)
config['max_memory_mb'] = max_memory_mb
# Add noise model
if noise_model is not None:
config["noise_model"] = noise_model
Expand Down
8 changes: 7 additions & 1 deletion qiskit/providers/aer/backends/qasm_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class QasmSimulator(AerBackend):
available memory, uses the statevector method. Otherwise, uses
the ch method (Default: "automatic").

* "available_memory" (int): Set the amount of memory (in MB)
* "max_memory_mb" (int): Set the amount of memory (in MB)
the simulator has access to (Default: Maximum available)

* "initial_statevector" (vector_like): Sets a custom initial
Expand Down Expand Up @@ -71,6 +71,12 @@ class QasmSimulator(AerBackend):
Note that this cannot be enabled at the same time as parallel
experiment execution (Default: 1).

* "max_statevector_memory_mb" (int): Sets the maximum size of memory
to store a state vector. If a state vector needs more, an error
is thrown. In general, a state vector of n-qubits uses 2^n complex
values (16 Bytes). If set to 0, the maximum will be automatically
set to the system memory size (Default: 0).

* "statevector_parallel_threshold" (int): Sets the threshold that
"n_qubits" must be greater than to enable OpenMP
parallelization for matrix multiplication during execution of
Expand Down
Loading