From 0787b80db8b78398061b7256e9cbf045cbcccb72 Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Mon, 22 Jan 2024 17:42:05 -0500 Subject: [PATCH] kompute : remove broken mulrow kernel -> 1 less test failure --- CMakeLists.txt | 2 -- ggml-kompute.cpp | 55 ++++++---------------------------- kompute-shaders/op_mulrow.comp | 25 ---------------- 3 files changed, 9 insertions(+), 73 deletions(-) delete mode 100644 kompute-shaders/op_mulrow.comp diff --git a/CMakeLists.txt b/CMakeLists.txt index 01f01bfee..c3533b969 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -520,7 +520,6 @@ if (LLAMA_KOMPUTE) kompute-shaders/op_add.comp kompute-shaders/op_addrow.comp kompute-shaders/op_mul.comp - kompute-shaders/op_mulrow.comp kompute-shaders/op_silu.comp kompute-shaders/op_relu.comp kompute-shaders/op_gelu.comp @@ -553,7 +552,6 @@ if (LLAMA_KOMPUTE) shaderop_add.h shaderop_addrow.h shaderop_mul.h - shaderop_mulrow.h shaderop_silu.h shaderop_relu.h shaderop_gelu.h diff --git a/ggml-kompute.cpp b/ggml-kompute.cpp index 163b0a29a..45a579b3b 100644 --- a/ggml-kompute.cpp +++ b/ggml-kompute.cpp @@ -9,7 +9,6 @@ #include "shaderop_add.h" #include "shaderop_addrow.h" #include "shaderop_mul.h" -#include "shaderop_mulrow.h" #include "shaderop_silu.h" #include "shaderop_relu.h" #include "shaderop_gelu.h" @@ -671,37 +670,6 @@ static void ggml_vk_mul( seq.record(s_algo); } -static void ggml_vk_mulrow(kp::Sequence& seq, - const std::shared_ptr& inA, - const std::shared_ptr& inB, - const std::shared_ptr& out, - uint32_t inAOff, uint32_t inBOff, uint32_t outOff, - uint32_t size, uint32_t row = 0) { - - const static auto spirv = getSpirvShader(kp::shader_data::op_mulrow_comp_spv, - kp::shader_data::op_mulrow_comp_spv_len); - - struct PushConstants { - uint32_t inAOff, inBOff, outOff; - uint32_t row; - } const pushConsts { - safe_divide(inAOff, 4), safe_divide(inBOff, 4), safe_divide(outOff, 4), - row - }; - - std::shared_ptr s_algo = nullptr; - if (!komputeManager()->hasAlgorithm(__func__)) - s_algo = komputeManager()->algorithm(__func__, s_kompute_context->pool.get(), {inA, inB, out}, spirv, {size}, {}, {pushConsts}); - else { - s_algo = komputeManager()->getAlgorithm(__func__); - s_algo->setTensors({inA, inB, out}); - s_algo->setWorkgroup({size}); - s_algo->setPushConstants({pushConsts}); - s_algo->updateDescriptors(s_kompute_context->pool.get()); - } - seq.record(s_algo); -} - static void ggml_vk_scale(kp::Sequence& seq, const std::shared_ptr& in, const std::shared_ptr& out, @@ -1516,20 +1484,15 @@ void ggml_vk_graph_compute(struct ggml_kompute_context * ctx, struct ggml_cgraph } break; case GGML_OP_MUL: { - if (ggml_nelements(src1) == ne10) { - // src1 is a row - ggml_vk_mulrow(seq, id_src0, id_src1, id_dst, off_src0, off_src1, off_dst, ggml_nelements(dst)/4, ne00); - } else { - ggml_vk_mul( - seq, id_src0, id_src1, id_dst, off_src0, off_src1, off_dst, - ne00, ne01, ne02, ne03, - nb00, nb01, nb02, nb03, - ne10, ne11, ne12, ne13, - nb10, nb11, nb12, nb13, - ne0, - nb0, nb1, nb2, nb3 - ); - } + ggml_vk_mul( + seq, id_src0, id_src1, id_dst, off_src0, off_src1, off_dst, + ne00, ne01, ne02, ne03, + nb00, nb01, nb02, nb03, + ne10, ne11, ne12, ne13, + nb10, nb11, nb12, nb13, + ne0, + nb0, nb1, nb2, nb3 + ); } break; case GGML_OP_SCALE: { diff --git a/kompute-shaders/op_mulrow.comp b/kompute-shaders/op_mulrow.comp deleted file mode 100644 index ae7106320..000000000 --- a/kompute-shaders/op_mulrow.comp +++ /dev/null @@ -1,25 +0,0 @@ -#version 450 - -#include "common.comp" - -layout(local_size_x = 1) in; - -layout(binding = 0) buffer restrict readonly tensorInA { float inA[]; }; -layout(binding = 1) buffer restrict readonly tensorInB { float inB[]; }; -layout(binding = 2) buffer restrict writeonly tensorOut { float out_[]; }; - -layout(push_constant) uniform PushConstants { - uint inAOff; - uint inBOff; - uint outOff; - uint row; -} pcs; - -void main() { - const uint baseIndex = gl_WorkGroupID.x * 4; - - for (uint x = 0; x < 4; x++) { - const uint i = baseIndex + x; - out_[i + pcs.outOff] = inA[i + pcs.inAOff] * inB[(i % pcs.row) + pcs.inBOff]; - } -} \ No newline at end of file