Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ggml/src/ggml-vulkan/vulkan-shaders/rope_multi.comp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ void main() {
const uint ix = channel_x*p.s2 + row_x*p.s1 + i0/2;

if (i0 >= p.n_dims) {
#ifdef ROPE_SAME_TYPE
data_d[idst + i0/2 + 0] = data_a[ix + i0/2 + 0];
data_d[idst + i0/2 + 1] = data_a[ix + i0/2 + 1];
#else
data_d[idst + i0/2 + 0] = D_TYPE(data_a[ix + i0/2 + 0]);
data_d[idst + i0/2 + 1] = D_TYPE(data_a[ix + i0/2 + 1]);
#endif

return;
}
Expand Down
5 changes: 5 additions & 0 deletions ggml/src/ggml-vulkan/vulkan-shaders/rope_neox.comp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ void main() {
}

if (i0 >= p.n_dims) {
#ifdef ROPE_SAME_TYPE
data_d[idst + i0/2 + 0] = data_a[ix + i0/2 + 0];
data_d[idst + i0/2 + 1] = data_a[ix + i0/2 + 1];
#else
data_d[idst + i0/2 + 0] = D_TYPE(data_a[ix + i0/2 + 0]);
data_d[idst + i0/2 + 1] = D_TYPE(data_a[ix + i0/2 + 1]);
#endif

return;
}
Expand Down
5 changes: 5 additions & 0 deletions ggml/src/ggml-vulkan/vulkan-shaders/rope_norm.comp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ void main() {
}

if (i0 >= p.n_dims) {
#ifdef ROPE_SAME_TYPE
data_d[idst + 0] = data_a[ix + 0];
data_d[idst + 1] = data_a[ix + 1];
#else
data_d[idst + 0] = D_TYPE(data_a[ix + 0]);
data_d[idst + 1] = D_TYPE(data_a[ix + 1]);
#endif

return;
}
Expand Down
7 changes: 5 additions & 2 deletions ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,7 @@ void string_to_spv_func(std::string name, std::string in_path, std::string out_p

// disable spirv-opt for coopmat shaders for https://github.com/ggerganov/llama.cpp/issues/10734
// disable spirv-opt for bf16 shaders for https://github.com/ggml-org/llama.cpp/issues/15344
// disable spirv-opt for rope shaders for https://github.com/ggml-org/llama.cpp/issues/16860
std::string opt_level = (coopmat || name.find("bf16") != std::string::npos || name.find("rope") != std::string::npos) ? "" : "-O";
std::string opt_level = (coopmat || name.find("bf16") != std::string::npos) ? "" : "-O";

#ifdef _WIN32
std::vector<std::string> cmd = {GLSLC, "-fshader-stage=compute", target_env, opt_level, "\"" + in_path + "\"", "-o", "\"" + out_path + "\""};
Expand All @@ -339,6 +338,10 @@ void string_to_spv_func(std::string name, std::string in_path, std::string out_p
for (const auto& define : defines) {
cmd.push_back("-D" + define.first + "=" + define.second);
}
// disable D_TYPE same as A_TYPE cast for rope shaders https://github.com/ggml-org/llama.cpp/issues/16860
if (name.find("rope") != std::string::npos && defines["D_TYPE"] == defines["A_TYPE"] ) {
cmd.push_back("-DROPE_SAME_TYPE");
}

std::string command;
for (const auto& part : cmd) {
Expand Down