Improve KE for commandline and programmatically tuning dispatch#18778
Merged
Improve KE for commandline and programmatically tuning dispatch#18778
Conversation
Contributor
Author
|
For example: import os
import sys
sys.path.insert(0, "/home/guangyunhan/onnxruntime/onnxruntime/python/tools/kernel_explorer/kernels")
sys.path.insert(0, "/home/guangyunhan/onnxruntime/build_rocm/Release")
os.environ["KERNEL_EXPLORER_BUILD_DIR"] = "/home/guangyunhan/onnxruntime/build_rocm/Release"
import multiprocessing as mp
from multiprocessing import Pool, current_process
def profile(name, *args, **kwargs):
import kernel_explorer as ke
ke.set_return_tuning_results()
ke.set_dispatchable_pattern("*Tunable*")
print(os.environ["HIP_VISIBLE_DEVICES"])
if name == "gemm":
from gemm_test import profile_with_args as profile
return profile(*args, **kwargs)
elif name == "softmax":
from softmax_test import profile_with_args as profile
return profile(*args, **kwargs)
else:
return []
def init():
pidx = int(current_process()._identity[0]) - 1
start_gpu = 2
num_gpu = 14
os.environ["HIP_VISIBLE_DEVICES"] = str(pidx % num_gpu + start_gpu)
if __name__ == "__main__":
configs = [
("gemm", "float16", False, False, 1, 8912, 8912),
("gemm", "float16", False, False, 8, 8912, 8912),
("gemm", "float16", False, False, 16, 8912, 8912),
("gemm", "float16", False, False, 24, 8912, 8912),
("gemm", "float16", False, False, 32, 8912, 8912),
("gemm", "float16", False, False, 40, 8912, 8912),
("gemm", "float16", False, False, 48, 8912, 8912),
("softmax", 1, 1024, False, "float16"),
("softmax", 2, 1024, False, "float16"),
]
mp.set_start_method("spawn")
with Pool(processes=4, initializer=init) as pool:
ret = pool.starmap(profile, configs, chunksize=1)
from pprint import pprint
from onnxruntime.tools.offline_tuning import Merger
m = Merger()
for tr in ret:
m.merge(tr)
pprint(m.get_merged()) |
| _ke_context.instance_dispatchable[f.__name__] = f | ||
|
|
||
| @wraps(f) | ||
| def wrapper(*args, **kwargs): |
Check notice
Code scanning / CodeQL
Explicit returns mixed with implicit (fall through) returns
mindest
reviewed
Dec 15, 2023
Contributor
mindest
left a comment
There was a problem hiding this comment.
Thanks for this PR. Tested locally, it worked fine. Please fix the lint warnings/errors.
65698f4 to
d4310c3
Compare
kailums
previously approved these changes
Feb 26, 2024
187a52c to
09e2bf8
Compare
mindest
previously approved these changes
Feb 26, 2024
Contributor
mindest
left a comment
There was a problem hiding this comment.
Thanks for the new feature support.
mindest
previously approved these changes
Feb 27, 2024
1f9ee51 to
aeec2ed
Compare
mindest
approved these changes
Apr 8, 2024
TedThemistokleous
pushed a commit
to TedThemistokleous/onnxruntime
that referenced
this pull request
May 7, 2024
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.