-
Notifications
You must be signed in to change notification settings - Fork 5
Enable automatic endianness conversion, SIMD & MASS support #4
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
IgorTodorovskiIBM
merged 5 commits into
zopencommunity:main
from
PESU-IBM-GRM-zOS-AI-Inferencing:main
Aug 6, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d4b22d3
Working patches with latest branch and z/OS specific formatting for p…
VyoJ 7372716
Auto-endianness integrated!
VyoJ 14ee1cd
Fixed curl test issues and added Charan's patches for SIMD and MASS
VyoJ b52f31b
Fixed build warnings, updated test case regex to correctly parse chec…
VyoJ 5d337b7
Implemented fixes suggested in PR review
VyoJ 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
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
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,53 @@ | ||
| diff --git a/ggml/src/ggml-cpu/CMakeLists.txt b/ggml/src/ggml-cpu/CMakeLists.txt | ||
| index 66a5ad8d..f71c7dec 100644 | ||
| --- a/ggml/src/ggml-cpu/CMakeLists.txt | ||
| +++ b/ggml/src/ggml-cpu/CMakeLists.txt | ||
| @@ -51,7 +51,7 @@ function(ggml_add_cpu_backend_variant_impl tag_name) | ||
|
|
||
| target_compile_features(${GGML_CPU_NAME} PRIVATE c_std_11 cxx_std_17) | ||
| target_include_directories(${GGML_CPU_NAME} PRIVATE . ggml-cpu) | ||
| - | ||
| + list(APPEND ARCH_FLAGS -fzvector -m64 -march=z15) | ||
| if (APPLE AND GGML_ACCELERATE) | ||
| find_library(ACCELERATE_FRAMEWORK Accelerate) | ||
| if (ACCELERATE_FRAMEWORK) | ||
| @@ -94,7 +94,7 @@ function(ggml_add_cpu_backend_variant_impl tag_name) | ||
| target_compile_definitions(${GGML_CPU_NAME} PRIVATE GGML_USE_CPU_HBM) | ||
|
|
||
| target_link_libraries(${GGML_CPU_NAME} PUBLIC memkind) | ||
| - endif() | ||
| + endif() | ||
|
|
||
| if (GGML_SYSTEM_ARCH STREQUAL "ARM") | ||
| message(STATUS "ARM detected") | ||
| @@ -463,11 +463,10 @@ function(ggml_add_cpu_backend_variant_impl tag_name) | ||
| message(WARNING "Unknown target. If you are compiling for z14 and earlier, you might have to add -DGGML_VXE=OFF.") | ||
| list(APPEND ARCH_FLAGS -march=native -mtune=native) | ||
| endif() | ||
| - | ||
| if (GGML_VXE) | ||
| message(STATUS "VX/VXE/VXE2 enabled") | ||
| list(APPEND ARCH_FLAGS -mvx -mzvector) | ||
| - list(APPEND ARCH_DEFINITIONS GGML_VXE) | ||
| + list(APPEND ARCH_DEFINITIONS GGML_VXE) | ||
| endif() | ||
|
|
||
| if (GGML_NNPA) | ||
| @@ -480,6 +479,17 @@ function(ggml_add_cpu_backend_variant_impl tag_name) | ||
| else() | ||
| message(WARNING "Unknown CPU architecture. Falling back to generic implementations.") | ||
| list(APPEND ARCH_FLAGS -DGGML_CPU_GENERIC) | ||
| + list(APPEND ARCH_DEFINITIONS GGML_VXE) | ||
| + message(STATUS "Added GGML_VXE Flag") | ||
| + if(NOT DEFINED TARGET_ARCH) | ||
| + set(TARGET_ARCH 13) | ||
| + endif() | ||
| + if(TARGET_ARCH GREATER 13) | ||
| + target_compile_options(${GGML_CPU_NAME} PRIVATE "-qarch=${TARGET_ARCH}") | ||
| + endif() | ||
| + target_include_directories(${GGML_CPU_NAME} PRIVATE /usr/include) | ||
| + target_link_libraries(${GGML_CPU_NAME} PRIVATE "/usr/lpp/cbclib/lib/libmass.arch${TARGET_ARCH}.a") | ||
| + message(STATUS "Found MASS: /usr/lpp/cbclib/lib/libmass.arch${TARGET_ARCH}.a") | ||
| endif() | ||
|
|
||
| if (GGML_CPU_REPACK) |
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,12 @@ | ||
| diff --git a/tools/mtmd/clip.cpp b/tools/mtmd/clip.cpp | ||
| index a4b62f9a..2d89d4b1 100644 | ||
| --- a/tools/mtmd/clip.cpp | ||
| +++ b/tools/mtmd/clip.cpp | ||
| @@ -2028,6 +2028,7 @@ struct clip_model_loader { | ||
| struct gguf_init_params params = { | ||
| /*.no_alloc = */ true, | ||
| /*.ctx = */ &meta, | ||
| + /*.allow_byteswapping = */ true, | ||
| }; | ||
|
|
||
| ctx_gguf = gguf_context_ptr(gguf_init_from_file(fname, params)); |
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,12 @@ | ||
| diff --git a/examples/convert-llama2c-to-ggml/convert-llama2c-to-ggml.cpp b/examples/convert-llama2c-to-ggml/convert-llama2c-to-ggml.cpp | ||
| index bdf0eed2..b36170bc 100644 | ||
| --- a/examples/convert-llama2c-to-ggml/convert-llama2c-to-ggml.cpp | ||
| +++ b/examples/convert-llama2c-to-ggml/convert-llama2c-to-ggml.cpp | ||
| @@ -535,6 +535,7 @@ static void load_vocab(const char * filename, const Config * config, struct my_l | ||
| struct gguf_init_params params = { | ||
| /*.no_alloc = */ false, | ||
| /*.ctx = */ &ctx_data, | ||
| + /*.allow_byteswapping = */ true, | ||
| }; | ||
|
|
||
| struct gguf_context * ctx = gguf_init_from_file(filename, params); |
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,12 @@ | ||
| diff --git a/examples/gguf/gguf.cpp b/examples/gguf/gguf.cpp | ||
| index f31989c8..94ac3e5a 100644 | ||
| --- a/examples/gguf/gguf.cpp | ||
| +++ b/examples/gguf/gguf.cpp | ||
| @@ -87,6 +87,7 @@ static bool gguf_ex_read_0(const std::string & fname) { | ||
| struct gguf_init_params params = { | ||
| /*.no_alloc = */ false, | ||
| /*.ctx = */ NULL, | ||
| + /*.allow_byteswapping = */ true, | ||
| }; | ||
|
|
||
| struct gguf_context * ctx = gguf_init_from_file(fname.c_str(), params); |
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,12 @@ | ||
| diff --git a/tools/export-lora/export-lora.cpp b/tools/export-lora/export-lora.cpp | ||
| index f038019b..bf750ab9 100644 | ||
| --- a/tools/export-lora/export-lora.cpp | ||
| +++ b/tools/export-lora/export-lora.cpp | ||
| @@ -50,6 +50,7 @@ static struct gguf_context * load_gguf(std::string & fname, struct ggml_context | ||
| struct gguf_init_params params = { | ||
| /*.no_alloc = */ true, | ||
| /*.ctx = */ ctx_ggml, | ||
| + /*.allow_byteswapping = */ true, | ||
| }; | ||
| struct gguf_context * ctx_gguf = gguf_init_from_file(fname.c_str(), params); | ||
| if (!ctx_gguf) { |
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 |
|---|---|---|
| @@ -1,15 +1,15 @@ | ||
| diff --git a/ggml/src/ggml-backend-reg.cpp b/ggml/src/ggml-backend-reg.cpp | ||
| index 405d8e3..b3682a9 100644 | ||
| index f0cdac31..29247c6a 100644 | ||
| --- a/ggml/src/ggml-backend-reg.cpp | ||
| +++ b/ggml/src/ggml-backend-reg.cpp | ||
| @@ -556,7 +556,9 @@ static ggml_backend_reg_t ggml_backend_load_best(const char * name, bool silent, | ||
| @@ -561,7 +561,9 @@ static ggml_backend_reg_t ggml_backend_load_best(const char * name, bool silent, | ||
| } | ||
|
|
||
| void ggml_backend_load_all() { | ||
| - ggml_backend_load_all_from_path(nullptr); | ||
| +#ifdef GGML_BACKEND_DL | ||
| + ggml_backend_load_all_from_path(nullptr); | ||
| +#endif | ||
| } | ||
|
|
||
| void ggml_backend_load_all_from_path(const char * dir_path) { |
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,31 @@ | ||
| diff --git a/ggml/src/ggml-cpu/ggml-cpu-impl.h b/ggml/src/ggml-cpu/ggml-cpu-impl.h | ||
| index d839cf5c..3f8532f7 100644 | ||
| --- a/ggml/src/ggml-cpu/ggml-cpu-impl.h | ||
| +++ b/ggml/src/ggml-cpu/ggml-cpu-impl.h | ||
| @@ -68,6 +68,15 @@ struct ggml_compute_params { | ||
| #endif // __VXE2__ | ||
| #endif // __s390x__ && __VEC__ | ||
|
|
||
| +#if defined(__MVS__) && defined(__VEC__) | ||
| +#ifndef __VXE__ | ||
| +#define __VXE__ | ||
| +#endif // __VXE__ | ||
| +#ifndef __VXE2__ | ||
| +#define __VXE2__ | ||
| +#endif // __VXE2__ | ||
| +#endif // __MVS__ && __VEC__ | ||
| + | ||
| #if defined(__s390x__) && defined(GGML_NNPA) | ||
| #ifndef __NNPA__ | ||
| #define __NNPA__ | ||
| @@ -352,8 +361,9 @@ inline static int32x4_t ggml_vdotq_s32(int32x4_t acc, int8x16_t a, int8x16_t b) | ||
| #endif | ||
|
|
||
| #if defined(__VXE__) || defined(__VXE2__) | ||
| +#ifndef __VEC__ | ||
| #include <vecintrin.h> | ||
| - | ||
| +#endif | ||
| #define vec_neg(a) (-(a)) // Vector Negate | ||
| #define vec_add(a, b) ((a) + (b)) // Vector Add | ||
| #define vec_sub(a, b) ((a) - (b)) // Vector Subtract |
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 |
|---|---|---|
| @@ -1,12 +1,13 @@ | ||
| diff --git a/ggml/src/ggml-cpu/ggml-cpu.c b/ggml/src/ggml-cpu/ggml-cpu.c | ||
| index c7426df..e074799 100644 | ||
| index c5271b77..6a547e4b 100644 | ||
| --- a/ggml/src/ggml-cpu/ggml-cpu.c | ||
| +++ b/ggml/src/ggml-cpu/ggml-cpu.c | ||
| @@ -17,7 +17,7 @@ | ||
|
|
||
| #if defined(_MSC_VER) || defined(__MINGW32__) | ||
| #include <malloc.h> // using malloc.h with MSC/MINGW | ||
| -#elif !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) | ||
| +#elif !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__MVS__) | ||
| #include <alloca.h> | ||
| #endif | ||
|
|
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.
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.
Is this change intentional?
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.
No, it's some kind of encoding issue with the send symbol on the demo website (I have attached a picture of it)
We weren't able to
git restorethe file to its original state, and it seemed to be a one-time issue with encoding that character so we just committed it for now.