Skip to content

Commit

Permalink
add fusion cost tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
hhorii committed Mar 18, 2021
1 parent c27a8ab commit 682504b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
11 changes: 9 additions & 2 deletions qiskit/providers/aer/backends/aerbackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,21 @@ def _run_job(self, job_id, qobj, backend_options, noise_model, validate):
# Add default OpenMP options
if 'statevector_parallel_threshold' not in backend_options and hasattr(
self, '_statevector_parallel_threshold'):
backend_options['statevector_parallel_threshold'] = self._statevector_parallel_threshold
backend_options['statevector_parallel_threshold'] = \
getattr(self, '_statevector_parallel_threshold')

# Add default fusion options
attr_postfix = '_gpu' if 'gpu' in backend_options.get('method', '') else ''
if 'fusion_threshold' not in backend_options and hasattr(
self, f'_fusion_threshold{attr_postfix}'):
self, f'_fusion_threshold{attr_postfix}'):
# Set fusion threshold
backend_options['fusion_threshold'] = getattr(self, f'_fusion_threshold{attr_postfix}')
for i in range(1, 6):
if f'fusion_cost.{i}' not in backend_options and \
hasattr(self, f'_fusion_cost{attr_postfix}.{i}'):
# Set cost for each
backend_options[f'fusion_cost.{i}'] = getattr(self,
f'_fusion_cost{attr_postfix}.{i}')

# The new function swaps positional args qobj and job id so we do a
# type check to swap them back
Expand Down
12 changes: 3 additions & 9 deletions qiskit/providers/aer/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
Profile backend options for optimal performance
"""
from qiskit import transpile, assemble, execute
from qiskit.circuit.library import QuantumVolume
from .aererror import AerError

from .backends.aerbackend import AerBackend
from .backends.qasm_simulator import QasmSimulator

def optimize_backend_options(min_qubits=10, max_qubits=20, ntrials=10):
"""Set optimal OpenMP and fusion options for backend."""
Expand Down Expand Up @@ -49,8 +51,6 @@ def optimize_backend_options(min_qubits=10, max_qubits=20, ntrials=10):
# TODO: Write profile to a local qiskitaerrc file so this doesn't
# need to be re-run on a system and the following can be loaded
# in the AerBackend class from the rc file if it is found
from qiskit.providers.aer.backends.aerbackend import AerBackend

if 'statevector_parallel_threshold' in profile:
AerBackend._statevector_parallel_threshold = profile[
'statevector_parallel_threshold']
Expand All @@ -66,9 +66,6 @@ def profile_parallel_threshold(min_qubits=10, max_qubits=20, ntrials=10,
backend_options=None,
return_ratios=False):
"""Evaluate optimal OMP parallel threshold for current system."""
from qiskit.circuit.library import QuantumVolume
from qiskit.providers.aer.backends.qasm_simulator import QasmSimulator

simulator = QasmSimulator()
opts = {'method': 'statevector',
'max_parallel_experiments': 1,
Expand Down Expand Up @@ -123,9 +120,6 @@ def profile_fusion_threshold(min_qubits=10, max_qubits=20, ntrials=10,
backend_options=None, gpu=False,
return_ratios=False):
"""Evaluate optimal OMP parallel threshold for current system."""
from qiskit.circuit.library import QuantumVolume
from qiskit.providers.aer.backends.qasm_simulator import QasmSimulator

simulator = QasmSimulator()
opts = {'method': 'statevector',
'max_parallel_experiments': 1,
Expand Down

0 comments on commit 682504b

Please sign in to comment.