-
Notifications
You must be signed in to change notification settings - Fork 12k
Vulkan generated targets and shader organization #5356
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
Comments
The idea behind bundling it like this was to allow templating and to keep the number of files in the repo low, which I know @ggerganov prefers. But I see the disadvantages. I'm open to a discussion about what we could replace it with that has as few disadvantages as possible. There's a few points to consider:
Also pinging @cebtenzzre who has raised this point before. Let me know what you think. |
Moving the shaders to a |
So here are some basic ideas on this after some consideration. We could keep In CMake a custom target (using On the
In this example a separate header extension is used to distinguish these from regular header files which allows the custom rule to be invoked. Either the user is required to specify VULKAN_DIR or some automated mechanism can be added. I haven't tested any of this code but the flow should at least capture the concept. |
For the sake of build times, I would prefer if we built the shaders as a separate translation unit from ggml-vulkan.cpp - at the very least use a precompiled header; at best, have each shader in its own translation unit. The machine I have my AMD GPU in has an aging 16-thread Xeon, and often when developing the Kompute backend I have watched 15 threads sit idle as it recompiles all of the shader headers serially (as part of ggml-kompute.cpp) every time I touch a single line of C++ code. |
So it appears that I can only have ggm-vulkan-shaders.hpp as an input for now anyway? |
@0cc4m Let me know if you'd like support on the build scripts. I'm not so much familiar with the Vulkan particulars (e.g. for splitting out the embedded shaders into a compile script) but I'd be happy to help integrate things with Make/CMake. If there's a particular branch let me know and I'll take a look. |
Eventually, but I'm busy trying to get MoE models to work and I don't really have the capacity to rework the shaders at the same time. |
is there the stand-alone vulkan shader sub directory now? |
Not yet. :) |
Sorry, just made myself right. I would be able to see the shader code as the kcompute-shader one, right? |
That is the goal being discussed here. However, if you are interested in seeing the shaders right now they are packed within ggml_vk_generate_shaders.py. This script is currently used to create the C++ header file ggml-vulkan-shaders.hpp. |
OK, thanks. I will update this post after i am done trying to update some shaders to improve some performance on particular network |
This issue was closed because it has been inactive for 14 days since being marked as stale. |
@bandoti Sorry this took so long, I'm working on extracting the shader code from the Python file. I'll make a PR that adds those files and adapts the Python file to read them. You could work on replacing the Python file with CMake/Make afterwards. |
I am working on integrating with the build system now. Will post an update once that's finished. |
@bandoti I think we can close this issue, right? |
Uh oh!
There was an error while loading. Please reload this page.
The generated header
ggml-vulkan-shaders.hpp
is 3 MB of generated binary from the packed Vulkan shaders. These should ideally be generated as amake
orCMake
target at build time instead of being placed under source control.In addition, I would like to propose splitting the actual shaders out from
ggml_vk_generate_shaders.py
. It will likely be easier to reason about the shaders (even though there will be many of them) if they are placed within a separate folder (perhaps$LLAMA_ROOT/vulkan
) and then collected/assembled by the python script, instead of having them inline.That way it will be clearer which part of Vulkan is affected by a given change—and also commit conflicts will be lessened if multiple people are working on separate shaders. In addition, if new shaders need to be added they can simply be dropped in the folder, and the python script may glob them before packing into
ggml-vulkan-shaders.hpp
.The hard work to get Vulkan going is greatly appreciated—I look forward to exploring this back-end further. Thank you!
The text was updated successfully, but these errors were encountered: