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

Entropy-based stopping criterion #151

Merged
merged 21 commits into from
Jan 12, 2024
Merged

Conversation

gevtushenko
Copy link
Collaborator

Closes #150 and #147.

This PR adds new command line option --stopping-criterion <criterion> with two predefined criteria stdrel and entropy along with API for customization of the stopping criterion. The nvbench/examples/custom_criterion.cu illustrates how custom criteria can be added on per-run basis. This opens possibilities for performance CI improvements. One can now develop criteria that, for instance, collects large sample, store the sample size and then on each re-run of performance CI loads this number, leading to better stability.

Apart from new API, entropy criterion is introduced. To enable it, it's sufficient to write --stopping-criterion entropy. The criterion computes cumulative entropy of the sample and stores it in an entropy window. Then, linear regression on the cumulative entropy window is computed. If the angle of the linear regression is small enough and coefficient of determination (R^2) is large enough, criterion believes that new samples will not introduce any new information and the sample is representative. Entropy criterion addresses concerns from #150 and #147 as well as significantly reduces variation of sample size, which is important for performance CI. Below is a plot of sample size distribution for stdrel and entropy criteria collected on nvbench/examples/throughput.cu that illustrates this point:

stdrel_vs_entropy

Below is an example where stdrel noticed small variance and decided to stop, but entropy noticed that entropy grows and kept sampling, discovering new modes:

large

large_4

Other times, entropy notices that new measurements do not introduce anything new to the sample and stops earlier:

small_2
small_3
small_5

Each criterion has its own set of parameters. Parameters like --max-noise and --min-time only affect stdrel criterion, whereas --max-angle and --min-r2 are parameters of entropy.

For now, stdrel stays as default criterion. Decision on switching the default criterion will be made after some field experience.

examples/CMakeLists.txt Outdated Show resolved Hide resolved
examples/custom_criterion.cu Outdated Show resolved Hide resolved
examples/custom_criterion.cu Outdated Show resolved Hide resolved
examples/custom_criterion.cu Outdated Show resolved Hide resolved
nvbench/CMakeLists.txt Outdated Show resolved Hide resolved
nvbench/criterion_registry.cuh Outdated Show resolved Hide resolved
nvbench/criterion_registry.cuh Outdated Show resolved Hide resolved
nvbench/detail/entropy_criterion.cxx Show resolved Hide resolved
nvbench/stopping_criterion.cuh Show resolved Hide resolved
nvbench/stopping_criterion.cuh Outdated Show resolved Hide resolved
@gevtushenko gevtushenko requested a review from alliepiper January 8, 2024 22:22
nvbench/detail/statistics.cuh Outdated Show resolved Hide resolved
nvbench/detail/entropy_criterion.cxx Show resolved Hide resolved
nvbench/detail/entropy_criterion.cxx Show resolved Hide resolved
nvbench/detail/entropy_criterion.cuh Show resolved Hide resolved
examples/custom_criterion.cu Outdated Show resolved Hide resolved
examples/custom_criterion.cu Outdated Show resolved Hide resolved
nvbench/criterion_manager.cuh Outdated Show resolved Hide resolved
nvbench/criterion_manager.cuh Outdated Show resolved Hide resolved
nvbench/criterion_manager.cxx Outdated Show resolved Hide resolved
nvbench/criterion_manager.cxx Outdated Show resolved Hide resolved
nvbench/criterion_manager.cxx Outdated Show resolved Hide resolved
nvbench/detail/entropy_criterion.cuh Outdated Show resolved Hide resolved
nvbench/stopping_criterion.cuh Outdated Show resolved Hide resolved
nvbench/stopping_criterion.cuh Outdated Show resolved Hide resolved
nvbench/state.cuh Show resolved Hide resolved
nvbench/stopping_criterion.cuh Outdated Show resolved Hide resolved
nvbench/option_parser.cu Outdated Show resolved Hide resolved
nvbench/stopping_criterion.cuh Outdated Show resolved Hide resolved
Copy link
Collaborator

@alliepiper alliepiper left a comment

Choose a reason for hiding this comment

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

LGTM -- Thanks for this, it should be a huge improvement!

@gevtushenko gevtushenko merged commit d8dced8 into NVIDIA:main Jan 12, 2024
rapids-bot bot pushed a commit to rapidsai/rapids-cmake that referenced this pull request Mar 4, 2024
This PR bumps the nvbench version to fetch the latest feature added in NVIDIA/nvbench#151 which should largely reduce nvbench runtime.

Authors:
  - Yunsong Wang (https://github.com/PointKernel)

Approvers:
  - Robert Maynard (https://github.com/robertmaynard)

URL: #549
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.

Investigate refined benchmark sample stopping criterion
3 participants