Skip to content

Commit

Permalink
Add AerProvider function for optimizing backend options
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseclectic committed Sep 26, 2020
1 parent 2fba5de commit ec53496
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions qiskit/providers/aer/aerprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,10 @@ def backends(self, name=None, filters=None, **kwargs):

def __str__(self):
return 'AerProvider'

@staticmethod
def optimize_backend_options(min_qubits=10, max_qubits=20, ntrials=10):
"""Set optimal OpenMP and fusion options for backend."""
from .profile import optimize_backend_options
return optimize_backend_options(
min_qubits=min_qubits, max_qubits=max_qubits, ntrials=ntrials)
16 changes: 16 additions & 0 deletions qiskit/providers/aer/backends/aerbackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,25 @@ def _format_qobj(self, qobj, backend_options, noise_model):
output = qobj.to_dict()
# Add new parameters to config from backend options
config = output["config"]

if backend_options is not None:
for key, val in backend_options.items():
config[key] = val if not hasattr(val, 'to_dict') else val.to_dict()

# Add default OpenMP options
if 'statevector_parallel_threshold' not in config and hasattr(
self, '_statevector_parallel_threshold'):
config['statevector_parallel_threshold'] = self._statevector_parallel_threshold

# Add default fusion options
if 'fusion_threshold' not in config:
if 'gpu' in config.get('method', '') and hasattr(self, '_fusion_threshold_gpu'):
# Set GPU fusion threshold
config['fusion_threshold'] = self._fusion_threshold_gpu
elif hasattr(self, '_fusion_threshold'):
# Set CPU fusion threshold
config['fusion_threshold'] = self._fusion_threshold

# Add noise model to config
if noise_model is not None:
config["noise_model"] = noise_model
Expand Down

0 comments on commit ec53496

Please sign in to comment.