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

Add Blog Post on Autotuning for Kokkos with APEX #130

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

vlkale
Copy link

@vlkale vlkale commented Dec 10, 2024

This PR adds a blog post on auto-tuning for Kokkos APEX. It includes discussion of its new features in Kokkos 4.5. It is a collaboration between @khuck and I, and the ideas and key points for the blog post have been discussed with @crtrott. I discussed with @dalg24 today.

It would be good to get this out and online by end of this week or otherwise in early January. I will be gone starting next week through Jan 9th, and in any case @khuck wanted to have it released very soon if possible and assuming this PR is approved.

I want to note that I followed the instructions to create the blog post through the README provided. When I got to the last step to test the addition, I couldn't see the blog post, i.e., I tried to build the website locally with npm run start, but I don't see the website locally. In terms of the text, everything has been reviewed by @khuck and the blog posts directions have been run by @crtrott.

@vlkale
Copy link
Author

vlkale commented Dec 10, 2024

Here is what I see when I build the website locally on the command-line

Screenshot 2024-12-10 at 3 32 45 PM

and in my browser (using Google Chrome) at http://localhost:1313/

Screenshot 2024-12-10 at 3 19 12 PM

@khuck
Copy link

khuck commented Dec 11, 2024

@vlkale it took me some poking around, but because the post date is after today's date, it won't render. If you change the date to 2024-12-10, it will show up. Also, we should try to find/make a higher resolution image with the two logos together...

@khuck
Copy link

khuck commented Dec 11, 2024

@vlkale oh, and you forgot to upload APEX-tuning.jpeg

@vlkale
Copy link
Author

vlkale commented Dec 11, 2024

@vlkale oh, and you forgot to upload APEX-tuning.jpeg

Thanks for that catch - actually, the problem is that file should be referenced in the text as kokkos-blog-post9.png. This is what I understand is their naming convention for all images for blog posts, having looked at the other blog posts' references to image files.

@vlkale
Copy link
Author

vlkale commented Dec 11, 2024

@vlkale it took me some poking around, but because the post date is after today's date, it won't render. If you change the date to 2024-12-10, it will show up. Also, we should try to find/make a higher resolution image with the two logos together...

Wow - thanks for that! I also now see the role of each element in that header better after looking at the Markdown's documentation. I have fixed the date to today.

Here is the Google Slide source from which the synergized logo/thumbnail was created:
https://docs.google.com/presentation/d/1w1JDszvUE9z1UuMF8U2aQ2DTjPCBkbIZeya1LmdD-no/edit?usp=sharing

I just pasted the logos images I downloaded from the web and put them in the Google Slide. From that, I downloaded the slide as a PNG. I think the source itself needs a clearer image. I can look for a Kokkos logo image.

If others have suggestions for higher-resolution image for Kokkos logo, let me know.

@vlkale
Copy link
Author

vlkale commented Dec 11, 2024

I have tested the website locally and it works. Here are two screenshots to show how it looks.
Screenshot 2024-12-11 at 2 26 01 PM
Screenshot 2024-12-11 at 2 26 52 PM

@khuck I have updated the Google Slides source for the APEX-Kokkos thumbnail to make it a higher resolution. I found and re-used the logo image of Kokkos in the assets/img directory that was already there.

Copy link
Member

@dalg24 dalg24 left a comment

Choose a reason for hiding this comment

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

Please segregate the images and figures you are adding into their own subdirectory.


# How it Works

Kokkos includes a Tuning API (TuningInterface) that can be used to construct a tuning context around a computational kernel, declare input variables that define the context state, declare output variables to be tuned, and request output variables when the kernel is executed. The Kokkos Tools infrastructure provide integrated support to utilize this API during Kokkos application execution, i.e., online, rather than offline [2]. Together, Kokkos Tools and the Tuning API is used in APEX to tune at runtime Kokkos kernel parameters running in any execution space / policy combination. We note through this Kokkos auto-tuning capability from APEX allows for (a) switching its tuning heuristics between Kokkos Execution Spaces (i.e. choose between serial or OpenMP depending on the problem size, etc.) or execution policies and (b) auto-tuning any arbitrary parameter within an application that uses Kokkos - solver choices, algorithmic parameters, tolerances, etc.
Copy link
Member

Choose a reason for hiding this comment

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

What is "TuningInterface" referring to?

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Kokkos includes a Tuning API (TuningInterface) that can be used to construct a tuning context around a computational kernel, declare input variables that define the context state, declare output variables to be tuned, and request output variables when the kernel is executed. The Kokkos Tools infrastructure provide integrated support to utilize this API during Kokkos application execution, i.e., online, rather than offline [2]. Together, Kokkos Tools and the Tuning API is used in APEX to tune at runtime Kokkos kernel parameters running in any execution space / policy combination. We note through this Kokkos auto-tuning capability from APEX allows for (a) switching its tuning heuristics between Kokkos Execution Spaces (i.e. choose between serial or OpenMP depending on the problem size, etc.) or execution policies and (b) auto-tuning any arbitrary parameter within an application that uses Kokkos - solver choices, algorithmic parameters, tolerances, etc.
Kokkos includes a Tuning API (TuningInterface) that can be used to construct a tuning context around a computational kernel, declare input variables that define the context state, declare output variables to be tuned, and request output variables when the kernel is executed. The Kokkos Tools infrastructure provide integrated support to utilize this API during Kokkos application execution, i.e., online, rather than offline [2]. Together, Kokkos Tools and the Tuning API is used in APEX to tune at runtime Kokkos kernel parameters running in any execution space / policy combination. We note through this Kokkos auto-tuning capability from APEX allows for (a) switching its tuning heuristics between Kokkos Execution Spaces (i.e. choose between Serial or OpenMP depending on the problem size, etc.) or execution policies and (b) auto-tuning any arbitrary parameter within an application that uses Kokkos - solver choices, algorithmic parameters, tolerances, etc.

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we can come up with a code snippet illustrating how one declare tunable variables and whether it would help here. Thoughts?

Copy link
Author

Choose a reason for hiding this comment

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

I wonder if we can come up with a code snippet illustrating how one declare tunable variables and whether it would help here. Thoughts?

Yes, I think we could show the matrix multiplication code that is being experimented with. The code and setup with the Tuning API is a bit long (about 50 lines of code) and all of it is needed. @khuck and I discussed it but decided it's not needed to be shown here - maybe we can go into more detail in that Wiki Post we linked in the Outcomes Section.

Copy link
Author

Choose a reason for hiding this comment

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

What is "TuningInterface" referring to?

This is what @khuck and I used to refer to the set of functions in Kokkos::Tools that helps declare tuning parameter variables and tuning contexts in which those variables should be tuned, e.g., the function Kokkos::Tools::declareTuningVariable() is part of that interface.

I think the text TuningInterface could actually be taken out and we can link to the Wiki Post for more information.

Also, maybe this can documented better in Kokkos or Kokkos Tools right now - this GitHub issue is probably the best documentation for its use: kokkos/kokkos-tools#90

Copy link

Choose a reason for hiding this comment

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

I wonder if we can come up with a code snippet illustrating how one declare tunable variables and whether it would help here. Thoughts?

Well... that's one of the issues with the current API, it is kind of complicated to create a variable...

@@ -0,0 +1,37 @@
---
authors: ["kokkos-team"]
title: "Kokkos Releases New Autotuning Features"
Copy link
Member

Choose a reason for hiding this comment

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

Be more specific, this title will look confusing in 1y, even more so in 3.
Try something like "Kokkos 4.5 Release Introduces New Auto-Tuning Features" or whatnot.

Copy link
Author

Choose a reason for hiding this comment

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

I used your suggestion for the more specific title. Perhaps we can say "...Introduces New Online Auto-Tuning Features" to be even more specific. As described in the blog, this Online Auto-Tuning relies on Kokkos Tools infrastructure. I wonder if that makes it too long.

@khuck Feel free to suggest a different title.


# Motivation

By default, internal Kokkos execution space parameters are empirically or heuristically hand-tuned with fixed parameter values to provide "one size fits most" performance, with the goal of minimizing the effect of the abstraction overhead and approximating the performance of an optimized, lower-level implementation. Can these parameters be tuned for a particular application and architecture for programmers to easily tackle further performance opportunities? The Kokkos Tools APEX auto-tuning connector [5], a git submodule in Kokkos Tools with a stable version released in Kokkos 4.5 [4], offers an answer.
Copy link
Member

Choose a reason for hiding this comment

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

Is the git-submodule part important? I would not mention it.
Also I don't quite get what you mean by "a stable version released in 4.5". There is currently still no Kokkos Tools releases in lock step with Kokkos and Kokkos Kernels releases.


{{< image src="img/kokkos-blog-post9.png" style="float: center; height=10">}}

For an in-depth example on how to use the Kokkos Tools runtime auto-tuning API with the APEX performance measurement and runtime adaptation tool, see the Wiki post at [https://github.com/UO-OACISS/apex/wiki/Kokkos-Runtime-Auto-Tuning-with-APEX](https://github.com/UO-OACISS/apex/wiki/Kokkos-Runtime-Auto-Tuning-with-APEX).
Copy link
Member

Choose a reason for hiding this comment

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

You mean for the URL to appear rather than making "Wiki post" an hyper reference?

assets/img/kokkos-blog-post9.png Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

You added a whole lot of duplicated images with various quality and format. Was it intentional?

Copy link
Member

Choose a reason for hiding this comment

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

Did you mean to commit changes to that file?

Copy link
Author

Choose a reason for hiding this comment

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

No, looks like that was done by mistake. I have restored the original version of package-lock.json. The diff only has three files added/changed, i.e., the new markdown file for the text of the blog post, the thumbnail image, and the plot in the third section of the post.

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.

3 participants