-
Notifications
You must be signed in to change notification settings - Fork 92
[ggml] Imported frequently used ggml functions into nntrainer #3429
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
base: main
Are you sure you want to change the base?
Conversation
07adfd2
to
d54ccb7
Compare
I think it is OK to include the code to remove the ggml submodule. |
ad3b72a
to
b95b19b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make it one commit PR
b95b19b
to
c2e18b2
Compare
9ad293e
to
af4b4e0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This patch would not work correctly for all platforms.
For instance, you need to modify the Android.mk file under jni and test/jni. There are still ggml dependencies left.
For instance,
Lines 95 to 131 in bce948a
MESON_HAS_GGML := @MESON_HAS_GGML@ | |
ifeq ($(MESON_HAS_GGML),1) | |
LOCAL_MODULE := ggml | |
LOCAL_SRC_FILES := @MESON_GGML_ROOT@/src/ggml-backend.cpp \ | |
@MESON_GGML_ROOT@/src/ggml-cpu/ggml-cpu-hbm.cpp \ | |
@MESON_GGML_ROOT@/src/ggml-cpu/unary-ops.cpp \ | |
@MESON_GGML_ROOT@/src/ggml-cpu/vec.cpp \ | |
@MESON_GGML_ROOT@/src/ggml-cpu/ggml-cpu-traits.cpp \ | |
@MESON_GGML_ROOT@/src/ggml-cpu/llamafile/sgemm.cpp \ | |
@MESON_GGML_ROOT@/src/ggml-cpu/ops.cpp \ | |
@MESON_GGML_ROOT@/src/ggml-cpu/amx/mmq.cpp \ | |
@MESON_GGML_ROOT@/src/ggml-cpu/amx/amx.cpp \ | |
@MESON_GGML_ROOT@/src/ggml-cpu/binary-ops.cpp \ | |
@MESON_GGML_ROOT@/src/ggml-cpu/ggml-cpu-aarch64.cpp \ | |
@MESON_GGML_ROOT@/src/ggml-cpu/cpu-feats-x86.cpp \ | |
@MESON_GGML_ROOT@/src/ggml-backend-reg.cpp \ | |
@MESON_GGML_ROOT@/src/ggml-opt.cpp \ | |
@MESON_GGML_ROOT@/src/gguf.cpp \ | |
@MESON_GGML_ROOT@/src/ggml-threading.cpp \ | |
@MESON_GGML_ROOT@/src/ggml-alloc.c \ | |
@MESON_GGML_ROOT@/src/ggml-quants.c \ | |
@MESON_GGML_ROOT@/src/ggml-cpu/ggml-cpu.cpp \ | |
@MESON_GGML_ROOT@/src/ggml-cpu/ggml-cpu_c.c \ | |
@MESON_GGML_ROOT@/src/ggml-cpu/ggml-cpu-quants.c \ | |
@MESON_GGML_ROOT@/src/ggml.c | |
LOCAL_CXXFLAGS += -std=c++17 -O3 -fexceptions | |
LOCAL_C_INCLUDES := @MESON_GGML_ROOT@/include \ | |
@MESON_GGML_ROOT@/src \ | |
@MESON_GGML_ROOT@/src/ggml-cpu | |
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) | |
include $(BUILD_SHARED_LIBRARY) | |
endif # MESON_HAS_GGML |
Lines 57 to 62 in bce948a
include $(CLEAR_VARS) | |
LOCAL_MODULE := ggml | |
LOCAL_SRC_FILES := $(NNTRAINER_ROOT)/builddir/jni/$(TARGET_ARCH_ABI)//libggml.so | |
include $(PREBUILT_SHARED_LIBRARY) |
Additionally, I don't think the |
@@ -442,11 +436,6 @@ ln -sf %{_libdir}/pkgconfig/capi-nnstreamer.pc %{_libdir}/pkgconfig/capi-ml-comm | |||
# Setup Ruy | |||
tar -xf packaging/ruy.tar.gz -C subprojects | |||
|
|||
# Setup GGML | |||
%if 0%{?enable_ggml} | |||
tar -xf packaging/ggml.tar.gz -C subprojects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please delete the packaging/ggml.tar.gz
file as well.
Removed GGML as a dependency and introduced the 'nntr_ggml_impl' directory with implementation of necessary functions Signed-off-by: p-debski2 <[email protected]>
065a679
to
d175017
Compare
All PR comments have been addressed, and I believe it should work correctly for all platforms now. However, I keep having trouble with Ubuntu Meson tests on CI after removing the Locally it works fine for me, and different builds with similar configurations also pass the unit tests phase (see Ubuntu pdebuild & Ubuntu Meson with Clang). It's also concerning that for those workflows that pass the CI, this test usually takes ~20s to finish, while here it times out in 60s. |
d175017
to
0e88783
Compare
Removed the enable-ggml option from Meson and use of ENABLE_GGML macro from code according to PR suggestions Signed-off-by: p-debski2 <[email protected]>
0e88783
to
d4809fd
Compare
I've investigated the issue with timeouts on Here's the results from unit tests as they were ran on CI before this PR (note that GGML is disabled in this configuration):
Here's the results from the same commit before my changes, but this time with GGML enabled:
And finally, the default configuration with changes from this PR:
We can see that the last two configurations with GGML enabled give very similar results in terms of time, but they also run longer then the first one, which was previously ran on CI for This behavior seems to be the expected one. Maybe Github Actions agents don't have enough resources to run the tests in 60s, so I tried raising the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add dequantize_row_q4_0
as well?
Added dequantize_row_q4_0 and dequantize_row_q8_0 to the nntr_ggml_impl Signed-off-by: p-debski2 <[email protected]>
I checked this PR is compatible with our recent applications, CausalLM (Linux & Android). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Summary
nntr_ggml_impl
directory and used those instead of the actual GGML in theggml_interface
functionsggml_interface
Signed-off-by: p-debski2 [email protected]