Skip to content

Commit fe4acc6

Browse files
Merge branch 'ggml-org:master' into master
2 parents b2cc147 + fab647e commit fe4acc6

30 files changed

+484
-114
lines changed

.github/workflows/build-linux-cross.yml

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,25 @@ on:
44
workflow_call:
55

66
jobs:
7-
ubuntu-latest-riscv64-cpu-cross:
8-
runs-on: ubuntu-latest
7+
ubuntu-24-riscv64-cpu-cross:
8+
runs-on: ubuntu-24.04
99

1010
steps:
1111
- uses: actions/checkout@v4
1212
- name: Setup Riscv
1313
run: |
1414
sudo dpkg --add-architecture riscv64
15-
sudo sed -i 's|http://azure.archive.ubuntu.com/ubuntu|http://ports.ubuntu.com/ubuntu-ports|g' \
16-
/etc/apt/sources.list /etc/apt/apt-mirrors.txt
17-
sudo apt-get clean
18-
sudo apt-get update
15+
16+
# Add arch-specific repositories for non-amd64 architectures
17+
cat << EOF | sudo tee /etc/apt/sources.list.d/riscv64-ports.list
18+
deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports/ noble main universe
19+
deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports/ noble-updates main universe
20+
deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports/ noble-security main universe
21+
deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports/ noble-backports main universe
22+
EOF
23+
24+
sudo apt-get update || true ;# Prevent failure due to missing URLs.
25+
1926
sudo apt-get install -y --no-install-recommends \
2027
build-essential \
2128
gcc-14-riscv64-linux-gnu \
@@ -40,21 +47,25 @@ jobs:
4047
4148
cmake --build build --config Release -j $(nproc)
4249
43-
ubuntu-latest-riscv64-vulkan-cross:
44-
runs-on: ubuntu-latest
50+
ubuntu-24-riscv64-vulkan-cross:
51+
runs-on: ubuntu-24.04
4552

4653
steps:
4754
- uses: actions/checkout@v4
48-
with:
49-
fetch-depth: 0
50-
5155
- name: Setup Riscv
5256
run: |
5357
sudo dpkg --add-architecture riscv64
54-
sudo sed -i 's|http://azure.archive.ubuntu.com/ubuntu|http://ports.ubuntu.com/ubuntu-ports|g' \
55-
/etc/apt/sources.list /etc/apt/apt-mirrors.txt
56-
sudo apt-get clean
57-
sudo apt-get update
58+
59+
# Add arch-specific repositories for non-amd64 architectures
60+
cat << EOF | sudo tee /etc/apt/sources.list.d/riscv64-ports.list
61+
deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports/ noble main universe
62+
deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports/ noble-updates main universe
63+
deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports/ noble-security main universe
64+
deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports/ noble-backports main universe
65+
EOF
66+
67+
sudo apt-get update || true ;# Prevent failure due to missing URLs.
68+
5869
sudo apt-get install -y --no-install-recommends \
5970
build-essential \
6071
glslc \
@@ -82,21 +93,25 @@ jobs:
8293
8394
cmake --build build --config Release -j $(nproc)
8495
85-
ubuntu-latest-arm64-vulkan-cross:
86-
runs-on: ubuntu-latest
96+
ubuntu-24-arm64-vulkan-cross:
97+
runs-on: ubuntu-24.04
8798

8899
steps:
89100
- uses: actions/checkout@v4
90-
with:
91-
fetch-depth: 0
92-
93101
- name: Setup Arm64
94102
run: |
95103
sudo dpkg --add-architecture arm64
96-
sudo sed -i 's|http://azure.archive.ubuntu.com/ubuntu|http://ports.ubuntu.com/ubuntu-ports|g' \
97-
/etc/apt/sources.list /etc/apt/apt-mirrors.txt
98-
sudo apt-get clean
99-
sudo apt-get update
104+
105+
# Add arch-specific repositories for non-amd64 architectures
106+
cat << EOF | sudo tee /etc/apt/sources.list.d/arm64-ports.list
107+
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ noble main universe
108+
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ noble-updates main universe
109+
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ noble-security main universe
110+
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ noble-backports main universe
111+
EOF
112+
113+
sudo apt-get update || true ;# Prevent failure due to missing URLs.
114+
100115
sudo apt-get install -y --no-install-recommends \
101116
build-essential \
102117
glslc \

.github/workflows/build.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,9 +601,8 @@ jobs:
601601
-DGGML_SYCL_F16=ON
602602
cmake --build build --config Release -j $(nproc)
603603
604-
# Disabled for now due to sporadic issue syncing.
605-
# build-linux-cross:
606-
# uses: ./.github/workflows/build-linux-cross.yml
604+
build-linux-cross:
605+
uses: ./.github/workflows/build-linux-cross.yml
607606

608607
macOS-latest-cmake-ios:
609608
runs-on: macos-latest

cmake/build-info.cmake

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,20 @@ endif()
4141

4242
if(MSVC)
4343
set(BUILD_COMPILER "${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION}")
44-
set(BUILD_TARGET ${CMAKE_VS_PLATFORM_NAME})
44+
if (CMAKE_VS_PLATFORM_NAME)
45+
set(BUILD_TARGET ${CMAKE_VS_PLATFORM_NAME})
46+
else()
47+
set(BUILD_TARGET "${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_PROCESSOR}")
48+
endif()
4549
else()
4650
execute_process(
47-
COMMAND sh -c "\"$@\" --version | head -1" _ ${CMAKE_C_COMPILER}
51+
COMMAND ${CMAKE_C_COMPILER} --version
4852
OUTPUT_VARIABLE OUT
4953
OUTPUT_STRIP_TRAILING_WHITESPACE
5054
)
55+
string(REGEX REPLACE " *\n.*" "" OUT "${OUT}")
5156
set(BUILD_COMPILER ${OUT})
57+
5258
execute_process(
5359
COMMAND ${CMAKE_C_COMPILER} -dumpmachine
5460
OUTPUT_VARIABLE OUT

common/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ add_custom_command(
3939
COMMENT "Generating build details from Git"
4040
COMMAND ${CMAKE_COMMAND} -DMSVC=${MSVC} -DCMAKE_C_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION}
4141
-DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} -DCMAKE_VS_PLATFORM_NAME=${CMAKE_VS_PLATFORM_NAME}
42-
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/build-info-gen-cpp.cmake"
42+
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
43+
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DCMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}
44+
-P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/build-info-gen-cpp.cmake"
4345
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.."
4446
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/build-info.cpp.in" ${GIT_INDEX}
4547
VERBATIM

common/arg.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2783,7 +2783,10 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
27832783
).set_examples({LLAMA_EXAMPLE_SERVER}).set_env("LLAMA_ARG_THREADS_HTTP"));
27842784
add_opt(common_arg(
27852785
{"--cache-reuse"}, "N",
2786-
string_format("min chunk size to attempt reusing from the cache via KV shifting (default: %d)", params.n_cache_reuse),
2786+
string_format(
2787+
"min chunk size to attempt reusing from the cache via KV shifting (default: %d)\n"
2788+
"[(card)](https://ggml.ai/f0.png)", params.n_cache_reuse
2789+
),
27872790
[](common_params & params, int value) {
27882791
params.n_cache_reuse = value;
27892792
}

convert_hf_to_gguf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,9 @@ def get_model_part_names(dir_model: Path, prefix: str, suffix: str) -> list[str]
419419
@staticmethod
420420
def load_hparams(dir_model: Path):
421421
try:
422-
return AutoConfig.from_pretrained(dir_model).to_dict()
422+
# for security reason, we don't allow loading remote code by default
423+
# if a model need remote code, we will fallback to config.json
424+
return AutoConfig.from_pretrained(dir_model, trust_remote_code=False).to_dict()
423425
except Exception as e:
424426
logger.warning(f"Failed to load model config from {dir_model}: {e}")
425427
logger.warning("Trying to load config.json instead")

examples/llava/clip.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2561,7 +2561,7 @@ struct llava_uhd {
25612561

25622562
// no pinpoints, dynamically calculate the grid size (e.g. minicpmv)
25632563

2564-
auto best_size = get_best_resize(original_size, slice_size, patch_size, has_slices);
2564+
auto best_size = get_best_resize(original_size, slice_size, patch_size, !has_slices);
25652565
res.overview_size = best_size;
25662566

25672567
if (!has_slices) {

examples/server/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ The project is under active development, and we are [looking for feedback and co
154154
| `--ssl-cert-file FNAME` | path to file a PEM-encoded SSL certificate<br/>(env: LLAMA_ARG_SSL_CERT_FILE) |
155155
| `-to, --timeout N` | server read/write timeout in seconds (default: 600)<br/>(env: LLAMA_ARG_TIMEOUT) |
156156
| `--threads-http N` | number of threads used to process HTTP requests (default: -1)<br/>(env: LLAMA_ARG_THREADS_HTTP) |
157-
| `--cache-reuse N` | min chunk size to attempt reusing from the cache via KV shifting (default: 0)<br/>(env: LLAMA_ARG_CACHE_REUSE) |
157+
| `--cache-reuse N` | min chunk size to attempt reusing from the cache via KV shifting (default: 0)<br/>[(card)](https://ggml.ai/f0.png)<br/>(env: LLAMA_ARG_CACHE_REUSE) |
158158
| `--metrics` | enable prometheus compatible metrics endpoint (default: disabled)<br/>(env: LLAMA_ARG_ENDPOINT_METRICS) |
159159
| `--slots` | enable slots monitoring endpoint (default: disabled)<br/>(env: LLAMA_ARG_ENDPOINT_SLOTS) |
160160
| `--props` | enable changing global properties via POST /props (default: disabled)<br/>(env: LLAMA_ARG_ENDPOINT_PROPS) |

ggml/CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,3 +360,27 @@ write_basic_package_version_file(
360360
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ggml-config.cmake
361361
${CMAKE_CURRENT_BINARY_DIR}/ggml-version.cmake
362362
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ggml)
363+
364+
if (MSVC)
365+
set(MSVC_WARNING_FLAGS
366+
/wd4005 # Macro redefinition
367+
/wd4244 # Conversion from one type to another type, possible loss of data
368+
/wd4267 # Conversion from 'size_t' to a smaller type, possible loss of data
369+
)
370+
function(disable_msvc_warnings target_name)
371+
if(TARGET ${target_name})
372+
target_compile_options(${target_name} PRIVATE ${MSVC_WARNING_FLAGS})
373+
endif()
374+
endfunction()
375+
376+
disable_msvc_warnings(ggml-base)
377+
disable_msvc_warnings(ggml)
378+
disable_msvc_warnings(ggml-cpu)
379+
disable_msvc_warnings(ggml-cpu-x64)
380+
disable_msvc_warnings(ggml-cpu-sse42)
381+
disable_msvc_warnings(ggml-cpu-sandybridge)
382+
disable_msvc_warnings(ggml-cpu-haswell)
383+
disable_msvc_warnings(ggml-cpu-skylakex)
384+
disable_msvc_warnings(ggml-cpu-icelake)
385+
disable_msvc_warnings(ggml-cpu-alderlake)
386+
endif()

ggml/src/ggml-alloc.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,10 @@ static void ggml_gallocr_init_tensor(ggml_gallocr_t galloc, struct ggml_tensor *
816816
static bool ggml_gallocr_node_needs_realloc(ggml_gallocr_t galloc, struct ggml_tensor * node, struct tensor_alloc * talloc) {
817817
size_t node_size = 0;
818818
if (!node->data && !node->view_src) {
819-
GGML_ASSERT(talloc->buffer_id >= 0); // prevent segfault when misusing the API
819+
// If we previously had data but don't now then reallocate
820+
if (talloc->buffer_id < 0) {
821+
return false;
822+
}
820823
node_size = ggml_backend_buft_get_alloc_size(galloc->bufts[talloc->buffer_id], node);
821824
}
822825
return talloc->size_max >= node_size;

0 commit comments

Comments
 (0)