Skip to content

Commit 989d981

Browse files
committed
llamafile : improve sgemm.cpp
- Re-enable by default - Fix issue described in ggml-org#6716 - Make code more abstract, elegant, and maintainable - Faster handling of weirdly shaped `m` an `n` edge cases
1 parent b8109bc commit 989d981

File tree

3 files changed

+366
-545
lines changed

3 files changed

+366
-545
lines changed

Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,10 +384,6 @@ ifdef LLAMA_OPENBLAS
384384
MK_LDFLAGS += $(shell pkg-config --libs openblas)
385385
endif # LLAMA_OPENBLAS
386386

387-
# TODO: temporary disable until MoE is fixed
388-
# https://github.com/ggerganov/llama.cpp/pull/6716
389-
LLAMA_NO_LLAMAFILE := 1
390-
391387
ifndef LLAMA_NO_LLAMAFILE
392388
MK_CPPFLAGS += -DGGML_USE_LLAMAFILE
393389
OBJS += sgemm.o

ggml.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10825,7 +10825,7 @@ static void ggml_compute_forward_mul_mat(
1082510825
#endif
1082610826

1082710827
#if GGML_USE_LLAMAFILE
10828-
if (nb10 == ggml_type_size(src1->type)) {
10828+
if (src1_cont) {
1082910829
for (int64_t i13 = 0; i13 < ne13; i13++)
1083010830
for (int64_t i12 = 0; i12 < ne12; i12++)
1083110831
if (!llamafile_sgemm(ne01, ne11, ne00/ggml_blck_size(src0->type),
@@ -10878,7 +10878,7 @@ UseGgmlGemm1:;
1087810878
const size_t row_size = ggml_row_size(vec_dot_type, ne10);
1087910879

1088010880
#if GGML_USE_LLAMAFILE
10881-
if (nb10 == ggml_type_size(src1->type) || src1->type != vec_dot_type) {
10881+
if (src1_cont) {
1088210882
for (int64_t i13 = 0; i13 < ne13; i13++)
1088310883
for (int64_t i12 = 0; i12 < ne12; i12++)
1088410884
if (!llamafile_sgemm(ne01, ne11, ne00/ggml_blck_size(src0->type),

0 commit comments

Comments
 (0)