-
Notifications
You must be signed in to change notification settings - Fork 19.8k
vulkan: fuse snake activation (mul, sin, sqr, mul, add) #22855
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
Merged
ServeurpersoCom
merged 5 commits into
ggml-org:master
from
ServeurpersoCom:ggml/vulkan-snake-fusion
May 21, 2026
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7e14e1a
vulkan: fuse snake activation (mul, sin, sqr, mul, add)
ServeurpersoCom 6f350d0
vulkan: address jeffbolznv review for fused snake activation
ServeurpersoCom 0048ab5
vulkan: tighten snake fusion type checks for all operands (address je…
ServeurpersoCom a4f2dd3
vulkan: reject snake fusion when ne[2] or ne[3] > 1 (address jeffbolz…
ServeurpersoCom 6d869a6
vulkan: address 0cc4m review for fused snake activation
ServeurpersoCom 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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| #version 450 | ||
|
|
||
| #include "types.glsl" | ||
|
|
||
| layout (binding = 0) readonly buffer X {A_TYPE data_x[];}; | ||
| layout (binding = 1) readonly buffer A {float data_a[];}; | ||
|
ServeurpersoCom marked this conversation as resolved.
Outdated
|
||
| layout (binding = 2) readonly buffer INVB {float data_inv_b[];}; | ||
| layout (binding = 3) writeonly buffer D {D_TYPE data_d[];}; | ||
|
|
||
| layout(local_size_x = 256, local_size_y = 1, local_size_z = 1) in; | ||
|
|
||
| layout (push_constant) uniform parameter { | ||
| uint32_t T; | ||
|
ServeurpersoCom marked this conversation as resolved.
Outdated
|
||
| uint32_t C; | ||
| } p; | ||
|
|
||
| // Load A_TYPE to float | ||
| float load_val(uint32_t idx) { | ||
| #if defined(DATA_A_BF16) | ||
| return bf16_to_fp32(uint32_t(data_x[idx])); | ||
| #else | ||
| return float(data_x[idx]); | ||
| #endif | ||
| } | ||
|
|
||
| // Store float as D_TYPE | ||
| void store_val(uint32_t idx, float v) { | ||
| #if defined(DATA_D_BF16) | ||
| data_d[idx] = D_TYPE(fp32_to_bf16(v)); | ||
| #else | ||
| data_d[idx] = D_TYPE(v); | ||
| #endif | ||
| } | ||
|
|
||
| void main() { | ||
| const uint32_t t = gl_GlobalInvocationID.x; | ||
| const uint32_t c = gl_GlobalInvocationID.y; | ||
| if (t >= p.T || c >= p.C) return; | ||
|
|
||
| const uint32_t idx = t + c * p.T; | ||
| const float xi = load_val(idx); | ||
| const float s = sin(data_a[c] * xi); | ||
| store_val(idx, xi + s * s * data_inv_b[c]); | ||
| } | ||
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.