Skip to content

Commit a82fce4

Browse files
committed
Merge remote-tracking branch 'origin/master' into allozaur/import-export-ux-improvements
2 parents f28598a + 0398752 commit a82fce4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1901
-225
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ jobs:
134134
include:
135135
- build: 'x64'
136136
os: ubuntu-22.04
137+
- build: 's390x-z15' # z15 because our CI runners are on z15
138+
os: ubuntu-22.04-s390x
137139
# GGML_BACKEND_DL and GGML_CPU_ALL_VARIANTS are not currently supported on arm
138140
# - build: 'arm64'
139141
# os: ubuntu-22.04-arm

.github/workflows/update-ops-docs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ name: Update Operations Documentation
33
on:
44
push:
55
paths:
6+
- 'docs/ops.md'
67
- 'docs/ops/**'
78
- 'scripts/create_ops_docs.py'
89
pull_request:
910
paths:
11+
- 'docs/ops.md'
1012
- 'docs/ops/**'
1113
- 'scripts/create_ops_docs.py'
1214

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
/ggml/src/ggml-cuda/common.cuh @slaren
5656
/ggml/src/ggml-cuda/fattn* @JohannesGaessler
5757
/ggml/src/ggml-cuda/ggml-cuda.cu @slaren
58-
/ggml/src/ggml-cuda/mmf.* @JohannesGaessler
58+
/ggml/src/ggml-cuda/mmf.* @JohannesGaessler @am17an
5959
/ggml/src/ggml-cuda/mmq.* @JohannesGaessler
6060
/ggml/src/ggml-cuda/mmvf.* @JohannesGaessler
6161
/ggml/src/ggml-cuda/mmvq.* @JohannesGaessler

ci/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ if [ ! -z ${GG_BUILD_ROCM} ]; then
7575
exit 1
7676
fi
7777

78-
CMAKE_EXTRA="${CMAKE_EXTRA} -DAMDGPU_TARGETS=${GG_BUILD_AMDGPU_TARGETS}"
78+
CMAKE_EXTRA="${CMAKE_EXTRA} -DGPU_TARGETS=${GG_BUILD_AMDGPU_TARGETS}"
7979
fi
8080

8181
if [ ! -z ${GG_BUILD_SYCL} ]; then

common/json-schema-to-grammar.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ static std::string build_repetition(const std::string & item_rule, int min_items
4141
return result;
4242
}
4343

44-
static void _build_min_max_int(int min_value, int max_value, std::stringstream & out, int decimals_left = 16, bool top_level = true) {
45-
auto has_min = min_value != std::numeric_limits<int>::min();
46-
auto has_max = max_value != std::numeric_limits<int>::max();
44+
static void _build_min_max_int(int64_t min_value, int64_t max_value, std::stringstream & out, int decimals_left = 16, bool top_level = true) {
45+
auto has_min = min_value != std::numeric_limits<int64_t>::min();
46+
auto has_max = max_value != std::numeric_limits<int64_t>::max();
4747

4848
auto digit_range = [&](char from, char to) {
4949
out << "[";
@@ -159,7 +159,7 @@ static void _build_min_max_int(int min_value, int max_value, std::stringstream &
159159
if (has_min) {
160160
if (min_value < 0) {
161161
out << "\"-\" (";
162-
_build_min_max_int(std::numeric_limits<int>::min(), -min_value, out, decimals_left, /* top_level= */ false);
162+
_build_min_max_int(std::numeric_limits<int64_t>::min(), -min_value, out, decimals_left, /* top_level= */ false);
163163
out << ") | [0] | [1-9] ";
164164
more_digits(0, decimals_left - 1);
165165
} else if (min_value == 0) {
@@ -194,7 +194,7 @@ static void _build_min_max_int(int min_value, int max_value, std::stringstream &
194194
}
195195
digit_range(c, c);
196196
out << " (";
197-
_build_min_max_int(std::stoi(min_s.substr(1)), std::numeric_limits<int>::max(), out, less_decimals, /* top_level= */ false);
197+
_build_min_max_int(std::stoll(min_s.substr(1)), std::numeric_limits<int64_t>::max(), out, less_decimals, /* top_level= */ false);
198198
out << ")";
199199
if (c < '9') {
200200
out << " | ";
@@ -216,7 +216,7 @@ static void _build_min_max_int(int min_value, int max_value, std::stringstream &
216216
_build_min_max_int(0, max_value, out, decimals_left, /* top_level= */ true);
217217
} else {
218218
out << "\"-\" (";
219-
_build_min_max_int(-max_value, std::numeric_limits<int>::max(), out, decimals_left, /* top_level= */ false);
219+
_build_min_max_int(-max_value, std::numeric_limits<int64_t>::max(), out, decimals_left, /* top_level= */ false);
220220
out << ")";
221221
}
222222
return;
@@ -925,17 +925,17 @@ class SchemaConverter {
925925
int max_len = schema.contains("maxLength") ? schema["maxLength"].get<int>() : std::numeric_limits<int>::max();
926926
return _add_rule(rule_name, "\"\\\"\" " + build_repetition(char_rule, min_len, max_len) + " \"\\\"\" space");
927927
} else if (schema_type == "integer" && (schema.contains("minimum") || schema.contains("exclusiveMinimum") || schema.contains("maximum") || schema.contains("exclusiveMaximum"))) {
928-
int min_value = std::numeric_limits<int>::min();
929-
int max_value = std::numeric_limits<int>::max();
928+
int64_t min_value = std::numeric_limits<int64_t>::min();
929+
int64_t max_value = std::numeric_limits<int64_t>::max();
930930
if (schema.contains("minimum")) {
931-
min_value = schema["minimum"].get<int>();
931+
min_value = schema["minimum"].get<int64_t>();
932932
} else if (schema.contains("exclusiveMinimum")) {
933-
min_value = schema["exclusiveMinimum"].get<int>() + 1;
933+
min_value = schema["exclusiveMinimum"].get<int64_t>() + 1;
934934
}
935935
if (schema.contains("maximum")) {
936-
max_value = schema["maximum"].get<int>();
936+
max_value = schema["maximum"].get<int64_t>();
937937
} else if (schema.contains("exclusiveMaximum")) {
938-
max_value = schema["exclusiveMaximum"].get<int>() - 1;
938+
max_value = schema["exclusiveMaximum"].get<int64_t>() - 1;
939939
}
940940
std::stringstream out;
941941
out << "(";

docs/ops.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ Legend:
100100
| SOFT_MAX_BACK ||| 🟡 | 🟡 ||| 🟡 |||
101101
| SQR ||||| 🟡 ||| 🟡 ||
102102
| SQRT ||||| 🟡 |||||
103-
| SSM_CONV |||||||| ||
104-
| SSM_SCAN |||||||| ||
103+
| SSM_CONV |||||||| ||
104+
| SSM_SCAN |||||||| ||
105105
| STEP |||| 🟡 | 🟡 || 🟡 |||
106106
| SUB ||||| 🟡 | 🟡 ||||
107107
| SUM ||||||||||

ggml/include/ggml-rpc.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ GGML_BACKEND_API ggml_backend_buffer_type_t ggml_backend_rpc_buffer_type(const c
2121
GGML_BACKEND_API void ggml_backend_rpc_get_device_memory(const char * endpoint, uint32_t device, size_t * free, size_t * total);
2222

2323
GGML_BACKEND_API void ggml_backend_rpc_start_server(const char * endpoint, const char * cache_dir,
24-
size_t n_threads, size_t n_devices,
25-
ggml_backend_dev_t * devices, size_t * free_mem, size_t * total_mem);
24+
size_t n_threads, size_t n_devices, ggml_backend_dev_t * devices);
2625

2726
GGML_BACKEND_API ggml_backend_reg_t ggml_backend_rpc_reg(void);
2827
GGML_BACKEND_API ggml_backend_reg_t ggml_backend_rpc_add_server(const char * endpoint);

ggml/src/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,10 @@ function(ggml_add_cpu_backend_variant tag_name)
307307
foreach (feat ${ARGN})
308308
set(GGML_INTERNAL_${feat} ON)
309309
endforeach()
310+
elseif (GGML_SYSTEM_ARCH STREQUAL "s390x")
311+
foreach (feat ${ARGN})
312+
set(GGML_INTERNAL_${feat} ON)
313+
endforeach()
310314
endif()
311315

312316
ggml_add_cpu_backend_variant_impl(${tag_name})
@@ -371,6 +375,14 @@ if (GGML_CPU_ALL_VARIANTS)
371375
else()
372376
message(FATAL_ERROR "Unsupported PowerPC target OS: ${CMAKE_SYSTEM_NAME}")
373377
endif()
378+
elseif (GGML_SYSTEM_ARCH STREQUAL "s390x")
379+
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
380+
ggml_add_cpu_backend_variant(s390x_z15 Z15 VXE)
381+
# ggml_add_cpu_backend_variant(s390x_z16 Z16 VXE)
382+
# ggml_add_cpu_backend_variant(s390x_z17 Z17 VXE)
383+
else()
384+
message(FATAL_ERROR "Unsupported s390x target OS: ${CMAKE_SYSTEM_NAME}")
385+
endif()
374386
else()
375387
message(FATAL_ERROR "GGML_CPU_ALL_VARIANTS not yet supported with ${GGML_SYSTEM_ARCH} on ${CMAKE_SYSTEM_NAME}")
376388
endif()

ggml/src/ggml-cpu/CMakeLists.txt

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -466,29 +466,45 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
466466
list(APPEND ARCH_FLAGS "-march=${MARCH_STR}" -mabi=lp64d)
467467
elseif (GGML_SYSTEM_ARCH STREQUAL "s390x")
468468
message(STATUS "s390x detected")
469-
list(APPEND GGML_CPU_SOURCES ggml-cpu/arch/s390/quants.c)
470-
file(READ "/proc/cpuinfo" CPUINFO_CONTENTS)
471-
string(REGEX REPLACE "machine[ \t\r\n]*=[ \t\r\n]*([0-9]+)" "\\1" S390X_M ${CPUINFO_CONTENTS})
472-
473-
# TODO: Separation to determine activation of VX/VXE/VXE2
474-
if (${S390X_M} MATCHES "8561|8562")
475-
message(STATUS "z15 target")
476-
list(APPEND ARCH_FLAGS -march=z15)
477-
elseif (${S390X_M} MATCHES "3931")
478-
message(STATUS "z16 target")
479-
list(APPEND ARCH_FLAGS -march=z16)
480-
elseif (${S390X_M} MATCHES "9175|9176")
481-
# NOTE: Only available from GCC 15.1.0 onwards. Any z17 machine with compile issues must first verify their GCC version.
482-
# binutils must also be updated to the latest for the -march=z17 flag to work. Otherwise, use -march=arch15.
483-
message(STATUS "z17 target")
484-
list(APPEND ARCH_FLAGS -march=arch15)
485-
else()
486-
message(STATUS "Unknown target")
487-
message(WARNING "Unknown target. If you are compiling for z14 and earlier, you might have to add -DGGML_VXE=OFF.")
488-
list(APPEND ARCH_FLAGS -march=native -mtune=native)
469+
list(APPEND GGML_CPU_SOURCES
470+
ggml-cpu/arch/s390/quants.c)
471+
472+
# for native compilation
473+
if (GGML_NATIVE)
474+
# check machine level to determine target
475+
file(READ "/proc/cpuinfo" CPUINFO_CONTENTS)
476+
string(REGEX REPLACE "machine[ \t\r\n]*=[ \t\r\n]*([0-9]+)" "\\1" S390X_M ${CPUINFO_CONTENTS})
477+
478+
# TODO: Separation to determine activation of VX/VXE/VXE2
479+
if (${S390X_M} MATCHES "8561|8562")
480+
message(STATUS "z15 target")
481+
list(APPEND ARCH_FLAGS -march=z15)
482+
elseif (${S390X_M} MATCHES "3931")
483+
message(STATUS "z16 target")
484+
list(APPEND ARCH_FLAGS -march=z16)
485+
elseif (${S390X_M} MATCHES "9175|9176")
486+
# NOTE: Only available from GCC 15.1.0 onwards. Any z17 machine with compile issues must first verify their GCC version.
487+
# binutils must also be updated to the latest for the -march=z17 flag to work. Otherwise, use -march=arch15.
488+
message(STATUS "z17 target")
489+
list(APPEND ARCH_FLAGS -march=arch15)
490+
else()
491+
message(STATUS "Unknown target")
492+
message(WARNING "Unknown target. If you are compiling for z14 and earlier, you might have to add -DGGML_VXE=OFF.")
493+
list(APPEND ARCH_FLAGS -march=native -mtune=native)
494+
endif()
495+
# for cross-compilation
496+
elseif(GGML_CPU_ALL_VARIANTS)
497+
# range through IBM z15 to z17
498+
# NOTE: update when a new hardware level is released
499+
foreach (ZHW RANGE 15 17)
500+
if(DEFINED GGML_INTERNAL_Z${ZHW})
501+
message(STATUS "z${ZHW} cross-compile target")
502+
list(APPEND ARCH_FLAGS -march=z${ZHW})
503+
endif()
504+
endforeach()
489505
endif()
490506

491-
if (GGML_VXE)
507+
if (GGML_VXE OR GGML_INTERNAL_VXE)
492508
message(STATUS "VX/VXE/VXE2 enabled")
493509
list(APPEND ARCH_FLAGS -mvx -mzvector)
494510
list(APPEND ARCH_DEFINITIONS GGML_VXE)

ggml/src/ggml-cpu/spacemit/ime.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,9 @@ template <typename BLOC_TYPE, int64_t INTER_SIZE, int64_t NB_COLS> class tensor_
485485
int32_t start = ith * task_per_thread;
486486
int32_t end = std::min((ith + 1) * task_per_thread, task_count);
487487
for (int32_t compute_idx = start; compute_idx < end; compute_idx++) {
488-
int32_t gemm_idx = compute_idx / block_size_m;
489-
int32_t m_idx = compute_idx % block_size_m * block_size_m;
488+
int32_t gemm_idx = compute_idx / per_gemm_block_count_m;
489+
int32_t block_idx_in_gemm = compute_idx % per_gemm_block_count_m;
490+
int32_t m_idx = block_idx_in_gemm * block_size_m;
490491
const qnbitgemm_spacemit_ime_args & data = qnbitgemm_args[gemm_idx];
491492
int32_t rows_tobe_handled = (gemm_m - m_idx) > block_size_m ? block_size_m : (gemm_m - m_idx);
492493

0 commit comments

Comments
 (0)