-
Notifications
You must be signed in to change notification settings - Fork 76
Don't use implicitly elapsed_time in autotuner
#3036
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
Closed
Closed
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c4a40f4
Don't use implicitly 'elapsed_time' in autotuner
anmyachev 022d974
pass a function for autotuner via 'do_bench' param
anmyachev de18b7a
revert warmup/rep changes
anmyachev e82f873
Apply suggestions from code review
anmyachev 5710fd1
remove 'kernel_name'
anmyachev b67dc9a
Merge branch 'main' into amyachev/autotuner
whitneywhtsang 330e328
Merge branch 'main' into amyachev/autotuner
whitneywhtsang 3221a3e
Merge branch 'main' of https://github.com/intel/intel-xpu-backend-for…
anmyachev 25ec4a6
calculate the number of iterations based on time
anmyachev 51505c5
Merge branch 'main' of https://github.com/intel/intel-xpu-backend-for…
anmyachev eb10a92
TRITON_PRINT_AUTOTUNING
anmyachev f044ec3
more runs for 'estimate_ms' calculation
anmyachev 61370a0
Merge branch 'main' of https://github.com/intel/intel-xpu-backend-for…
anmyachev ddc6595
align the procedure for getting estimate_ms with the procedure in do_…
anmyachev f6a05b7
one extra call before
anmyachev 44f3d02
align
anmyachev da4d163
Update .github/workflows/triton-benchmarks.yml
anmyachev 06d9469
Merge branch 'main' into amyachev/autotuner
anmyachev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import argparse | ||
| import itertools | ||
| import os | ||
| import time | ||
|
|
||
| from triton.testing import assert_close as triton_assert_close, Benchmark | ||
|
|
||
|
|
@@ -162,6 +163,39 @@ def extract_kernels(funcs): | |
| raise NotImplementedError(f"BENCHMARKING_METHOD: {BENCHMARKING_METHOD} isn't implemented") | ||
|
|
||
|
|
||
| def make_do_bench_for_autotune(): | ||
| import triton | ||
|
|
||
| def autotuner_do_bench(fn, *args, **kwargs): | ||
| di = triton.runtime.driver.active.get_device_interface() | ||
|
|
||
| fn() | ||
| di.synchronize() | ||
|
|
||
| cache = triton.runtime.driver.active.get_empty_cache_for_benchmark() | ||
|
|
||
| count = 5 | ||
| start = time.time_ns() / 1_000_000 | ||
| for _ in range(count): | ||
| triton.runtime.driver.active.clear_cache(cache) | ||
| fn() | ||
| di.synchronize() | ||
| end = time.time_ns() / 1_000_000 | ||
| estimate_ms = (end - start) / count | ||
|
|
||
| # defaults for `do_bench` in ms | ||
| warmup_time = 25 | ||
| rep_time = 100 | ||
|
|
||
| # compute n_warmup and n_repeat times | ||
| n_warmup = max(1, int(warmup_time / estimate_ms)) | ||
| n_repeat = max(1, int(rep_time / estimate_ms)) | ||
|
Comment on lines
+201
to
+202
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The iteration determination procedure is as similar as possible to the one used before. I believe the changes in the results can be fully attributed to the consequences of the transition from implicit |
||
|
|
||
| return do_bench(fn, *args, n_warmup=n_warmup, n_repeat=n_repeat, **kwargs) | ||
|
|
||
| return autotuner_do_bench | ||
|
|
||
|
|
||
| def assert_close(x_fn, y_fn, atol=None, rtol=None, err_msg=""): | ||
| if VERIFY: | ||
| triton_assert_close(x_fn(), y_fn(), atol, rtol, err_msg) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.