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

Automatically set and save optimal OpenMP and fusion thresholds #1183

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions qiskit/providers/aer/aerprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from .backends.statevector_simulator import StatevectorSimulator
from .backends.unitary_simulator import UnitarySimulator
from .backends.pulse_simulator import PulseSimulator
from .profile import profile_performance_options


class AerProvider(Provider):
Expand Down Expand Up @@ -78,3 +79,9 @@ 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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets remove this method from the provider for now and make it have to be run by importing the profiling functions

"""Set optimal OpenMP and fusion options for backend."""
return profile_performance_options(
min_qubits=min_qubits, max_qubits=max_qubits, ntrials=ntrials)
19 changes: 17 additions & 2 deletions qiskit/providers/aer/backends/aerbackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

from ..aerjob import AerJob
from ..aererror import AerError
from ..profile import get_performance_options

# Logger
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -155,9 +156,23 @@ def run(self,
else:
qobj = assemble(circuits, self)

# Add backend options to the Job qobj
profile_num_qubits = None
if isinstance(circuits, QasmQobj):
profile_num_qubits = qobj.config.n_qubits
if isinstance(circuits, list) and len(circuits) > 0 and hasattr(circuits[0], 'num_qubits'):
profile_num_qubits = circuits[0].num_qubits

profiled_options = {}
if profile_num_qubits is not None:
# Get profiled options for performance
gpu = backend_options is not None and 'gpu' in backend_options.get('method', '')
profiled_options = get_performance_options(profile_num_qubits, gpu)
for run_option in run_options:
if run_option in profiled_options:
del profiled_options[run_option]

self._add_options_to_qobj(
qobj, backend_options=backend_options, **run_options)
qobj, backend_options=backend_options, **profiled_options, **run_options)

# Optional validation
if validate:
Expand Down
Loading