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

Conversation

hhorii
Copy link
Collaborator

@hhorii hhorii commented Mar 17, 2021

Summary

Adds basic profiling code to find suitable threshold values for OpenMP and gate fusion for backend options.
This is a revised version of #956.

Details and comments

This PR will add following into to #956.

  • Save optimized parameters into settings.conf
  • Optimize fusion_cost.N

@hhorii hhorii force-pushed the profile-thresholds branch 5 times, most recently from 682504b to d2057f8 Compare March 18, 2021 03:39
@hhorii hhorii changed the title [WIP] Automatically set and save optimal OpenMP and fusion thresholds Automatically set and save optimal OpenMP and fusion thresholds Mar 22, 2021
@hhorii
Copy link
Collaborator Author

hhorii commented Mar 22, 2021

Once Qiskit/qiskit#5943 is merged, optimized parameters will be able to be store in user config around here:

def _set_optimized_option(option_name, value):
setattr(AerBackend, f'_{option_name}', value)

def _clear_optimized_option(option_name):
if hasattr(AerBackend, f'_{option_name}'):
delattr(AerBackend, f'_{option_name}')

@hhorii hhorii force-pushed the profile-thresholds branch 2 times, most recently from a0730fa to cc00860 Compare March 23, 2021 01:35
Copy link
Member

@chriseclectic chriseclectic left a comment

Choose a reason for hiding this comment

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

Some changers needed here. I think it might be better to wait until after #1194 is merged and just use profiling for AerSimulator which provides a common interface to all simulation methods and makes it easier to check if using GPU or not since it has a separate device option.

@@ -49,3 +50,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

@@ -159,9 +160,17 @@ def run(self,
DeprecationWarning,
stacklevel=3)

# Add default OpenMP options
gpu = backend_options is not None and 'gpu' in backend_options.get('method', '')
Copy link
Member

Choose a reason for hiding this comment

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

Backend options is a deprecated argument. Typically the method will already be in the qobj config

@@ -159,9 +160,17 @@ def run(self,
DeprecationWarning,
stacklevel=3)

# Add default OpenMP options
gpu = backend_options is not None and 'gpu' in backend_options.get('method', '')
profiled_options = get_performance_options(gpu)
Copy link
Member

Choose a reason for hiding this comment

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

This should be handled as pat of the format qobj, and only add the profile option to the qobj config if they aren't present in options or run options

from .aererror import AerError


def profile_performance_options(min_qubits=10, max_qubits=25, ntrials=5,
Copy link
Member

Choose a reason for hiding this comment

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

This profile.py file should probably be moved into aer/utils/ and the user facing functions added to aer/utils/__init__.py

@hhorii
Copy link
Collaborator Author

hhorii commented Apr 9, 2021

Here are performance graphs (time_taken includes only transpilation + simulation and excludes interface overheads) with default and tuned configurations.

Configurations:

  • Left: MacBook (2.6 GHz 6-Core Intel Core i7)
    • statevector_parallel_threshold=11
    • fusion_threshold=19
  • Right: Xeon (Intel Xeon Gold 6140 CPU )
    • statevector_parallel_threshold=16
    • fusion_threshold=11

QuantumVolume:
image image

IntegerComparator:
image image

WeightedAdder:
image image

QuadraticForm:
image image

QFT:
image image

RealAmplitudes with full entanglements
image image

RealAmplitudes with linear entanglements
image image

Red lines are expected the lowest. Because this profiling function uses QuantumVolume, tuned options do not work for others. However, I believe, these side-effects are acceptables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants