]> git.djapps.eu Git - pkg/ggml/sources/ggml/log
pkg/ggml/sources/ggml
13 months agoAdd freq factors (llama/7495)
AidanBeltonS [Mon, 27 May 2024 12:34:09 +0000 (13:34 +0100)]
Add freq factors (llama/7495)

13 months agometal : add GGML_OP_REPEAT kernels (llama/7557)
Georgi Gerganov [Mon, 27 May 2024 09:10:19 +0000 (12:10 +0300)]
metal : add GGML_OP_REPEAT kernels (llama/7557)

ggml-ci

13 months agometal : disable FA kernel for HS=256 (llama/7556)
Georgi Gerganov [Mon, 27 May 2024 07:38:39 +0000 (10:38 +0300)]
metal : disable FA kernel for HS=256 (llama/7556)

ggml-ci

13 months agoggml : restore ggml_rope_xpos_inplace (#0)
Georgi Gerganov [Sun, 26 May 2024 15:35:23 +0000 (18:35 +0300)]
ggml : restore ggml_rope_xpos_inplace (#0)

ggml-ci

13 months agosync : llama.cpp
Georgi Gerganov [Sun, 26 May 2024 15:00:48 +0000 (18:00 +0300)]
sync : llama.cpp

ggml-ci

13 months agoggml: aarch64: SVE kernels for q8_0_q8_0, q4_0_q8_0 vector dot (llama/7433)
Masaya, Kato [Sat, 25 May 2024 08:42:31 +0000 (17:42 +0900)]
ggml: aarch64: SVE kernels for q8_0_q8_0, q4_0_q8_0 vector dot (llama/7433)

* Add SVE support for q4_0_q8_0 q8_0_q8_0

* remove ifdef

13 months agoggml : silence UB sanitizer error during iq2_xxs quantization (llama/0)
Georgi Gerganov [Thu, 23 May 2024 14:17:43 +0000 (17:17 +0300)]
ggml : silence UB sanitizer error during iq2_xxs quantization (llama/0)

13 months agoggml : remove ggml_flash_attn and ggml_flash_ff (llama/7463)
Georgi Gerganov [Thu, 23 May 2024 07:00:44 +0000 (10:00 +0300)]
ggml : remove ggml_flash_attn and ggml_flash_ff (llama/7463)

ggml-ci

13 months agoggml : drop support for QK_K=64 (llama/7473)
Georgi Gerganov [Thu, 23 May 2024 07:00:21 +0000 (10:00 +0300)]
ggml : drop support for QK_K=64 (llama/7473)

* ggml : drop support for QK_K=64

ggml-ci

* opencl : restore QK_K=256 define

13 months agoUpdate vulkan rope implementation to support frequency factors (llama/7475)
0cc4m [Thu, 23 May 2024 06:59:59 +0000 (08:59 +0200)]
Update vulkan rope implementation to support frequency factors (llama/7475)

13 months agoCUDA: fix FA out-of-bounds reads (llama/7479)
Johannes Gäßler [Wed, 22 May 2024 22:31:20 +0000 (00:31 +0200)]
CUDA: fix FA out-of-bounds reads (llama/7479)

13 months agoCUDA: fix FA out-of-bounds writes (llama/7465)
Johannes Gäßler [Wed, 22 May 2024 15:58:25 +0000 (17:58 +0200)]
CUDA: fix FA out-of-bounds writes (llama/7465)

13 months agocuda : fix compile warning (llama/7454)
Georgi Gerganov [Wed, 22 May 2024 09:36:37 +0000 (12:36 +0300)]
cuda : fix compile warning (llama/7454)

13 months agoCUDA: remove incorrect precision check (llama/7454)
Johannes Gäßler [Wed, 22 May 2024 08:24:29 +0000 (10:24 +0200)]
CUDA: remove incorrect precision check (llama/7454)

13 months agocuda : fix rope + add tests (llama/7452)
Georgi Gerganov [Wed, 22 May 2024 08:01:35 +0000 (11:01 +0300)]
cuda : fix rope + add tests (llama/7452)

* cuda : fix rope pos data

ggml-ci

* ggml : drop mode & 1 == 1 support for ggml_rope

ggml-ci

* ggml : support freq_factors for f16 rope (CPU)

ggml-ci

* tests : add rope tests using frequency factors

ggml-ci

13 months agollama : add phi3 128K model support (llama/7225)
liuwei-git [Tue, 21 May 2024 20:28:32 +0000 (04:28 +0800)]
llama : add phi3 128K model support (llama/7225)

* add phi3 128k support in convert-hf-to-gguf

* add phi3 128k support in cuda

* address build warnings on llama.cpp

* adjust index value in cuda long rope freq factors

* add long rope support in ggml cpu backend

* make freq factors only depend on ctx size

* remove unused rope scaling type 'su' frin gguf converter

* fix flint warnings on convert-hf-to-gguf.py

* set to the short freq factor when context size is small than trained context size

* add one line of comments

* metal : support rope freq_factors

* ggml : update ggml_rope_ext API to support freq. factors

* backends : add dev messages to support rope freq. factors

* minor : style

* tests : update to use new rope API

* backends : fix pragma semicolons

* minor : cleanup

* llama : move rope factors from KV header to tensors

* llama : remove tmp assert

* cuda : fix compile warning

* convert : read/write n_head_kv

* llama : fix uninitialized tensors

---------

Co-authored-by: Georgi Gerganov <redacted>
13 months agometal : handle F16 inf values, fix FA partial offload (llama/7434)
Georgi Gerganov [Tue, 21 May 2024 20:03:42 +0000 (23:03 +0300)]
metal : handle F16 inf values, fix FA partial offload (llama/7434)

ggml-ci

13 months agoCUDA: fix unused warning in mmq.cu (llama/7442)
Johannes Gäßler [Tue, 21 May 2024 17:27:12 +0000 (19:27 +0200)]
CUDA: fix unused warning in mmq.cu (llama/7442)

13 months agoCUDA: deduplicate mmq code (llama/7397)
Johannes Gäßler [Tue, 21 May 2024 14:02:12 +0000 (16:02 +0200)]
CUDA: deduplicate mmq code (llama/7397)

13 months agorpc : track allocated buffers (llama/7411)
Radoslav Gerganov [Mon, 20 May 2024 13:36:55 +0000 (16:36 +0300)]
rpc : track allocated buffers (llama/7411)

* rpc : track allocated buffers

ref: #7407

* rpc : pack rpc_tensor tightly

13 months agoUpdate SYCL upscale operation (llama/7321)
AidanBeltonS [Mon, 20 May 2024 11:08:23 +0000 (12:08 +0100)]
Update SYCL upscale operation (llama/7321)

* Update SYCL upscale operation

* Formatting

* Remove messages

13 months agoggml-opencl, llama: using reserve() if count already known (llama/7272)
Herman Semenov [Mon, 20 May 2024 07:33:21 +0000 (07:33 +0000)]
ggml-opencl, llama: using reserve() if count already known (llama/7272)

13 months agoggml : add loongarch lsx and lasx support (llama/6454)
junchao-loongson [Mon, 20 May 2024 07:19:21 +0000 (15:19 +0800)]
ggml : add loongarch lsx and lasx support (llama/6454)

* add loongarch lsx and lasx optimize code

* Add loongarch compilation support to makefile

* revert stb_image.h

* opt bytes_from_nibbles_32 and sum_i16_pairs_float

* fix undeclared

* format code

* update

* update 2

---------

Co-authored-by: Jinyang He <redacted>
13 months agoAdd provisions for windows support for BF16 code including CMake provision for enabli...
Srihari-mcw [Mon, 20 May 2024 02:18:39 +0000 (19:18 -0700)]
Add provisions for windows support for BF16 code including CMake provision for enabling AVX512_BF16 (llama/7258)

13 months agoVulkan Embedding Fix (llama/7360)
0cc4m [Sun, 19 May 2024 15:19:53 +0000 (17:19 +0200)]
Vulkan Embedding Fix (llama/7360)

* Fix empty Vulkan host buffers

Add fp32 fp16 matmul shader

Fix matmul shader alignment

* Remove deprecated tensor->backend uses

* Fix Vulkan validation errors on embedding models with no offloaded layers

* Fix Vulkan llava segfault when not offloading layers

13 months agoggml : fix another case of quants nans (llama/7387)
slaren [Sun, 19 May 2024 15:08:46 +0000 (17:08 +0200)]
ggml : fix another case of quants nans (llama/7387)

13 months agoggml: implement quantized KV cache for FA (llama/7372)
Johannes Gäßler [Sun, 19 May 2024 14:46:13 +0000 (16:46 +0200)]
ggml: implement quantized KV cache for FA (llama/7372)

13 months agocuda : clear error after buffer allocation failure (llama/7376)
slaren [Sun, 19 May 2024 12:19:37 +0000 (14:19 +0200)]
cuda : clear error after buffer allocation failure (llama/7376)

13 months agoCapture CUDA logging output (llama/7298)
fraxy-v [Sat, 18 May 2024 22:44:42 +0000 (01:44 +0300)]
Capture CUDA logging output (llama/7298)

* logging: output capture in cuda module

* fix compile error

* fix: vsnprintf terminates with 0, string use not correct

* post review

* Update llama.cpp

Co-authored-by: slaren <redacted>
* Update llama.cpp

Co-authored-by: slaren <redacted>
---------

Co-authored-by: slaren <redacted>
13 months agoandroid : use "ci-android" branch for CI (llama/7341)
Georgi Gerganov [Sat, 18 May 2024 10:40:39 +0000 (13:40 +0300)]
android : use "ci-android" branch for CI (llama/7341)

* android : use "ci-android" branch for CI

* ggml : disable SIMD exp and silu for 32-bit ARM

ggml-ci

* android : do not fetch, use add_subdirectory instead

* cmake : provide binary dir

13 months agoCUDA: deduplicate FlashAttention code (llama/7352)
Johannes Gäßler [Sat, 18 May 2024 10:36:25 +0000 (12:36 +0200)]
CUDA: deduplicate FlashAttention code (llama/7352)

13 months agocuda : add half2 __shfl_xor() for ROCm 5.5 (llama/7263)
Engininja2 [Sat, 18 May 2024 08:05:17 +0000 (02:05 -0600)]
cuda : add half2 __shfl_xor() for ROCm 5.5 (llama/7263)

13 months agoUpdate and fix Vulkan soft_max and argsort implementations (llama/7237)
0cc4m [Sat, 18 May 2024 06:10:58 +0000 (08:10 +0200)]
Update and fix Vulkan soft_max and argsort implementations (llama/7237)

* Update and fix Vulkan softmax implementation

* Update and fix Vulkan argsort implementation

13 months agoggml : fix quants nans when all the group weights are very close to zero (llama/7313)
slaren [Sat, 18 May 2024 00:39:54 +0000 (02:39 +0200)]
ggml : fix quants nans when all the group weights are very close to zero (llama/7313)

13 months agoCUDA: faster large batch FA without tensor cores (llama/7314)
Johannes Gäßler [Fri, 17 May 2024 16:54:52 +0000 (18:54 +0200)]
CUDA: faster large batch FA without tensor cores (llama/7314)

13 months agorpc : set SO_REUSEADDR for the server socket (llama/7320)
Radoslav Gerganov [Fri, 17 May 2024 14:25:44 +0000 (17:25 +0300)]
rpc : set SO_REUSEADDR for the server socket (llama/7320)

ref: #7293

13 months agoggml-quants, llama : removed excess checks (llama/7274)
Herman Semenov [Fri, 17 May 2024 07:08:49 +0000 (07:08 +0000)]
ggml-quants, llama : removed excess checks (llama/7274)

13 months agoggml : rewrite silu and softmax for cpu (llama/7154)
Justine Tunney [Fri, 17 May 2024 06:58:52 +0000 (02:58 -0400)]
ggml : rewrite silu and softmax for cpu (llama/7154)

This change upstreams llamafile's vectorized expf() functions. This lets
us compute softmax and silu more accurately than the short[65536] lookup
table that GGML previously used to make this operation go faster. We can
support aarch64 and sse2+ with the worst case rounding error of 2ulp. It
makes make -j8 tests && ./tests/test-backend-ops -o SOFT_MAX -b CPU perf
go 1.5x faster for SSE2+FMA, 1.9x faster for AVX2+FMA and 2.1x on AVX512

13 months agorpc : add command line arg for specifying backend memory
Radoslav Gerganov [Wed, 15 May 2024 12:29:07 +0000 (15:29 +0300)]
rpc : add command line arg for specifying backend memory

ref: #7293

13 months agoAdd support for properly optimized Windows ARM64 builds with LLVM and MSVC (llama...
Max Krasnyansky [Thu, 16 May 2024 02:47:36 +0000 (19:47 -0700)]
Add support for properly optimized Windows ARM64 builds with LLVM and MSVC (llama/7191)

* logging: add proper checks for clang to avoid errors and warnings with VA_ARGS

* build: add CMake Presets and toolchian files for Windows ARM64

* matmul-int8: enable matmul-int8 with MSVC and fix Clang warnings

* ci: add support for optimized Windows ARM64 builds with MSVC and LLVM

* matmul-int8: fixed typos in q8_0_q8_0 matmuls

Co-authored-by: Georgi Gerganov <redacted>
* matmul-int8: remove unnecessary casts in q8_0_q8_0

---------

Co-authored-by: Georgi Gerganov <redacted>
13 months agoggml : use dynamic thread scheduling for matrix multiplication (llama/6915)
kunnis [Wed, 15 May 2024 17:59:12 +0000 (12:59 -0500)]
ggml : use dynamic thread scheduling for matrix multiplication (llama/6915)

* Just reordering some structs.

* Adding in the calls to mm_pause

* Passing around the state

* Renaming and moving a bunch of variables around.

* Extracting the logic to it's own function.

* Moving some variable definitions into the chunk function.

* Moving some variables around

* moving src1_cont inside

* Moving row_size

* adding the current_chunk

* Reorg the code.

* Formatting to match the orig patch

* starting to setup the chunking variables

* Starting the buildup of the loop

* The yield shouldn't be necessary.

* adding the looping structure based on the chunk configuration.

* Add in the re-chunking code.

* Making it much more likely to rechunk.

* disable resizing if numa is enabled.

* Updating comments with what we've learned.

* Fix formatting

* Couple more formatting fixes.

* More style fixes.

* Fix Warnings

* Going with unused because there's conditional logic that needs it.

* Update ggml.c

* Update ggml.c

---------

13 months agoAvoid unnecessarily disabling CUDA graphs (llama/7302)
agray3 [Wed, 15 May 2024 13:44:49 +0000 (14:44 +0100)]
Avoid unnecessarily disabling CUDA graphs (llama/7302)

As discussed in PR #6766, CUDA graphs were being disabled in the presence of long prompts.
This fixes the issue by avoiding the consective update counter from incrementing unnecessarily
for tokens in which cuda graphs are disabled due to batch size > 1.

13 months agoggml : tag ggml_tensor::backend as deprecated (llama/7290)
slaren [Wed, 15 May 2024 13:08:48 +0000 (15:08 +0200)]
ggml : tag ggml_tensor::backend as deprecated (llama/7290)

13 months agoAdd missing " (llama/7303)
AidanBeltonS [Wed, 15 May 2024 12:26:30 +0000 (13:26 +0100)]
Add missing " (llama/7303)

13 months agocmake : add Vulkan build (#730)
Andrei [Sat, 25 May 2024 12:42:35 +0000 (08:42 -0400)]
cmake : add Vulkan build (#730)

* Add vulkan shaders from llama.cpp

* Add vulkan build to cmake

* remove autogenerated shaders file

* Update sync scripts

* Remove stale vulkan shaders file

* Add up-to-date shaders file

13 months agogguf : use Qn_K for k-quants instead of KQn (#837)
compilade [Fri, 24 May 2024 20:58:29 +0000 (16:58 -0400)]
gguf : use Qn_K for k-quants instead of KQn (#837)

13 months agogguf.md: add sharding to naming convention (#826)
Brian [Sun, 19 May 2024 08:05:26 +0000 (18:05 +1000)]
gguf.md: add sharding to naming convention (#826)

* gguf.md: add sharding to naming convention [no ci]

* gguf.md: Add note on using gguf metadata for model name, version and expert count [no ci]

* gguf.md: Tighten up wording and add regex example [no ci]

* gguf.md: json output for expertcount and shard is numerical [no ci]

13 months agoAdd ggml rpc to cmake (#827)
Andrei [Fri, 17 May 2024 15:05:08 +0000 (11:05 -0400)]
Add ggml rpc to cmake (#827)

13 months agogguf.md: Add GGUF Naming Convention Section (#822)
Brian [Fri, 17 May 2024 06:09:01 +0000 (16:09 +1000)]
gguf.md: Add GGUF Naming Convention Section (#822)

* gguf.md: Add GGUF Naming Convention Section

* gguf.md: add BF16

* gguf.md: GGUF Filename Parsing Strategy

* gguf.md: include tensor type table and historical context

* gguf.md: minor corrections

* gguf.md: more detailed breakdown of tensor type mapping

* gguf.md: use Encoding Scheme name instead

* gguf.md: minor correction to overall naming convention

* gguf.md: simplify GGUF Naming Convention

13 months agoggml : add `ggml_upscale_ext` (#814)
John Balis [Wed, 15 May 2024 08:52:33 +0000 (03:52 -0500)]
ggml : add `ggml_upscale_ext` (#814)

* initial commit with CPU implementation of upscale to shape and test, cuda implementation next

* experimental commit to see if dst shape is correct

* test version

* test

* removed unnecessary params

* refactor

* fixed tests

* ggml : metal impl + cleanup + sycl dev warnings

* patched ggml_upscale cuda op to handle non-contiguous tensors, added test for non-contiguous behavior

* metal : fix upsacle op to support nb00 + style

---------

Co-authored-by: Georgi Gerganov <redacted>
13 months agosync : whisper.cpp
Georgi Gerganov [Wed, 15 May 2024 07:37:39 +0000 (10:37 +0300)]
sync : whisper.cpp

13 months agowhisper : use flash attention (whisper/2152)
Georgi Gerganov [Wed, 15 May 2024 06:38:19 +0000 (09:38 +0300)]
whisper : use flash attention (whisper/2152)

* whisper : use flash attention in the encoder

* whisper : add kv_pad

* whisper : remove extra backend instance (huh?)

* whisper : use FA for cross-attention

* whisper : use FA for self-attention

* whisper : simplify encoder FA

* whisper : add flash_attn runtime parameter

* scripts : add bench log

* scripts : add M1 Pro bench log

13 months agosync : llama.cpp
Georgi Gerganov [Tue, 14 May 2024 16:13:34 +0000 (19:13 +0300)]
sync : llama.cpp

13 months agometal : support FA without mask + add asserts (llama/7278)
Georgi Gerganov [Tue, 14 May 2024 16:09:30 +0000 (19:09 +0300)]
metal : support FA without mask + add asserts (llama/7278)

* ggml : fa without mask + add asserts

ggml-ci

* metal : support non-contiguous KV

ggml-ci

13 months agoggml : add RPC backend (llama/6829)
Radoslav Gerganov [Tue, 14 May 2024 11:27:19 +0000 (14:27 +0300)]
ggml : add RPC backend (llama/6829)

* ggml : add RPC backend

The RPC backend proxies all operations to a remote server which runs a
regular backend (CPU, CUDA, Metal, etc).

* set TCP_NODELAY

* add CI workflows

* Address review comments

* fix warning

* implement llama_max_devices() for RPC

* Address review comments

* Address review comments

* wrap sockfd into a struct

* implement get_alignment and get_max_size

* add get_device_memory

* fix warning

* win32 support

* add README

* readme : trim trailing whitespace

* Address review comments

* win32 fix

* Address review comments

* fix compile warnings on macos

13 months agorm wait() (llama/7233)
Neo Zhang [Mon, 13 May 2024 10:11:26 +0000 (18:11 +0800)]
rm wait() (llama/7233)

13 months agoCUDA: add FP32 FlashAttention vector kernel (llama/7188)
Johannes Gäßler [Sun, 12 May 2024 17:40:45 +0000 (19:40 +0200)]
CUDA: add FP32 FlashAttention vector kernel (llama/7188)

* CUDA: add FP32 FlashAttention vector kernel

* fixup! CUDA: add FP32 FlashAttention vector kernel

* fixup! fixup! CUDA: add FP32 FlashAttention vector kernel

* fixup! fixup! fixup! CUDA: add FP32 FlashAttention vector kernel

13 months agoscripts : sync ggml-rpc
Georgi Gerganov [Tue, 14 May 2024 16:12:05 +0000 (19:12 +0300)]
scripts : sync ggml-rpc

13 months agosync : whisper.cpp
Georgi Gerganov [Tue, 14 May 2024 12:09:31 +0000 (15:09 +0300)]
sync : whisper.cpp

ggml-ci

13 months agowhisper : fix model path encoding in windows (whisper/2086)
thewh1teagle [Tue, 14 May 2024 06:43:41 +0000 (09:43 +0300)]
whisper : fix model path encoding in windows (whisper/2086)

* fix: model path encoding in windows

* fix: convert model path to wide string only for MSVC compiler

13 months agomain : dont print timings with --no-prints (whisper/2108)
Daniel Ziegenberg [Mon, 13 May 2024 12:00:19 +0000 (14:00 +0200)]
main : dont print timings with --no-prints (whisper/2108)

Signed-off-by: Daniel Ziegenberg <redacted>
13 months agomain : add options for temperature control (whisper/2088)
Daniel Ziegenberg [Mon, 13 May 2024 11:59:44 +0000 (13:59 +0200)]
main : add options for temperature control (whisper/2088)

Add two options:

```
-tp,       --temperature N     [0.00   ] The sampling temperature, between 0 and 1
-tpi,      --temperature-inc N [0.20   ] The increment of temperature, between 0 and 1
```

The sampling temperature, between 0 and 1. Higher values like 0.8 will
make the output more random, while lower values like 0.2 will make it
more focused and deterministic. If set to 0, the model will use log
probability to automatically increase the temperature until certain
thresholds are hit.

Signed-off-by: Daniel Ziegenberg <redacted>
13 months agowhisper : switch back to F32 mask (whisper/0)
Georgi Gerganov [Mon, 13 May 2024 11:43:43 +0000 (14:43 +0300)]
whisper : switch back to F32 mask (whisper/0)

13 months agomain : fix double quote escaping in csv output (whisper/2090)
mashizora [Mon, 13 May 2024 08:55:32 +0000 (16:55 +0800)]
main : fix double quote escaping in csv output (whisper/2090)

13 months agometal : tune soft_max number of threads (whisper/0)
Georgi Gerganov [Mon, 13 May 2024 08:01:07 +0000 (11:01 +0300)]
metal : tune soft_max number of threads (whisper/0)

13 months agowhisper : remove old flash attn code (whisper/0)
Georgi Gerganov [Mon, 13 May 2024 07:41:33 +0000 (10:41 +0300)]
whisper : remove old flash attn code (whisper/0)

13 months agoggml : try fix ppc64 (whisper/0)
Georgi Gerganov [Sun, 12 May 2024 17:36:31 +0000 (20:36 +0300)]
ggml : try fix ppc64 (whisper/0)

13 months agoggml : expose SSE3 and SSSE3 for MSVC when AVX is available (whisper/2128)
Przemysław Pawełczyk [Wed, 8 May 2024 15:33:43 +0000 (17:33 +0200)]
ggml : expose SSE3 and SSSE3 for MSVC when AVX is available (whisper/2128)

13 months agoRemove unnecessary memory reallocation in fft (whisper/2080)
goldwaving [Sun, 28 Apr 2024 17:36:12 +0000 (15:06 -0230)]
Remove unnecessary memory reallocation in fft (whisper/2080)

fft_out needs to be twice the frame_size, not the frame_step.  It is resized in fft() anyway, but this change prevents an unnecessary reallocation.

n_fft must match the mel filter size, so it is best not to calculate it from the framesize.

We only need to get the magnitudes for half the spectrum since the other half is a mirror and not used in the mel filter loop later.

13 months agowhisper : more prominent log message for sub-1s audio (whisper/2065)
Georgi Gerganov [Wed, 24 Apr 2024 11:45:27 +0000 (14:45 +0300)]
whisper : more prominent log message for sub-1s audio (whisper/2065)

13 months agomain : pass nullptr when regex is empty (whisper/2070)
Georgi Gerganov [Wed, 17 Apr 2024 09:23:47 +0000 (12:23 +0300)]
main : pass nullptr when regex is empty (whisper/2070)

13 months agowhisper : update grammar-parser.cpp (whisper/2058)
Ikko Eltociear Ashimine [Mon, 15 Apr 2024 16:40:27 +0000 (01:40 +0900)]
whisper : update grammar-parser.cpp (whisper/2058)

preceeding -> preceding

13 months agoggml : optimize for ppc64le using VSX intrinsics (#784)
Hong Bo PENG [Sun, 12 May 2024 09:17:18 +0000 (17:17 +0800)]
ggml : optimize for ppc64le using VSX intrinsics (#784)

* optimize for ppc64le using VSX intrinsics

* 1. code clean up by removing comments about overflow concern.

2. fix typo in suffix of scaling.

* Continue to fix typo in suffix of scaling for QK_K <> 256

---------

Co-authored-by: Georgi Gerganov <redacted>
13 months agocuda : remove old alibi sources (#0)
Georgi Gerganov [Sat, 11 May 2024 18:37:29 +0000 (21:37 +0300)]
cuda : remove old alibi sources (#0)

13 months agometal : fix indent (#0)
Georgi Gerganov [Sat, 11 May 2024 13:57:53 +0000 (16:57 +0300)]
metal : fix indent (#0)

13 months agoggml : restore sigmoid decl order (#0)
Georgi Gerganov [Sat, 11 May 2024 13:50:54 +0000 (16:50 +0300)]
ggml : restore sigmoid decl order (#0)

13 months agotests : restore unary tests (#0)
Georgi Gerganov [Sat, 11 May 2024 13:47:45 +0000 (16:47 +0300)]
tests : restore unary tests (#0)

13 months agomnist : clean whitespace
Georgi Gerganov [Sat, 11 May 2024 13:42:01 +0000 (16:42 +0300)]
mnist : clean whitespace

ggml-ci

13 months agoggml : resolve merge (#0)
Georgi Gerganov [Sat, 11 May 2024 13:25:50 +0000 (16:25 +0300)]
ggml : resolve merge (#0)

ggml-ci

13 months agosync : llama.cpp
Georgi Gerganov [Sat, 11 May 2024 13:20:42 +0000 (16:20 +0300)]
sync : llama.cpp

ggml-ci

13 months agoggml : full ALiBi support (llama/7192)
Georgi Gerganov [Sat, 11 May 2024 07:32:41 +0000 (10:32 +0300)]
ggml : full ALiBi support (llama/7192)

* ggml : full ALiBi support

* ggml : update ggml_soft_max_ext() CUDA, SYCL

* ggml : ggml_flash_attn_ext() support ALiBi (CPU)

* ggml : ggml_flash_attn_ext() support ALiBi (Metal)

* ggml : fix warning

* ggml : ggml_flash_attn_ext() support ALiBi (CUDA)

ggml-ci

* ggml : fix assert message

* vulkan : add dev notes

* ggml : require mask when using ALiBi

ggml-ci

* convert : fix convert for refact models

13 months agometal : fix flash attention kernel requirements (llama/7169)
Georgi Gerganov [Fri, 10 May 2024 15:20:10 +0000 (18:20 +0300)]
metal : fix flash attention kernel requirements (llama/7169)

* metal : fix flash attention kernel requirements

ggml-ci

* metal : fix ggml_metal_supports_op

ggml-ci

13 months agoMinor arithmetic improvement to mmvq wrapper kernel (llama/7172)
Ouadie EL FAROUKI [Fri, 10 May 2024 00:32:15 +0000 (01:32 +0100)]
Minor arithmetic improvement to mmvq wrapper kernel (llama/7172)

13 months agoVulkan Bugfixes and Improvements (llama/7084)
0cc4m [Thu, 9 May 2024 18:39:54 +0000 (20:39 +0200)]
Vulkan Bugfixes and Improvements (llama/7084)

* Modify mat mat mul shader for mul_mat_id, modify mat vec mul shaders for single call batch operation

* Further work towards MoE, disabled for now

* Disable MoE code (not ready yet), fix a number of bugs in shaders and Vulkan code

* Add softmax with f16 mask and pos buffer support

* Disable mul_mat_id shaders for now

* Fix flake8

* Fix validation errors caused by empty buffers on larger batch sizes

13 months agoCUDA: generalize FP16 fattn vec kernel (llama/7061)
Johannes Gäßler [Thu, 9 May 2024 12:32:02 +0000 (14:32 +0200)]
CUDA: generalize FP16 fattn vec kernel (llama/7061)

* CUDA: generalize FP16 fattn vec kernel

* disable unsupported head sizes for AMD in test

* try AMD fix

* fix batch size 2-8

* partially revert changes

13 months agoopencl : alignment size converted from bits to bytes (llama/7090)
Albert Jin [Thu, 9 May 2024 09:34:37 +0000 (17:34 +0800)]
opencl : alignment size converted from bits to bytes (llama/7090)

* opencl alignment size should be converted from bits to bytes

Reference: https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_API.html#CL_DEVICE_MEM_BASE_ADDR_ALIGN

> Alignment requirement (in bits) for sub-buffer offsets.

* Update ggml-opencl.cpp for readability using division instead of shift

Co-authored-by: Jared Van Bortel <redacted>
---------

Co-authored-by: Jared Van Bortel <redacted>
13 months agoIntroduction of CUDA Graphs to LLama.cpp (llama/6766)
agray3 [Wed, 8 May 2024 20:55:49 +0000 (21:55 +0100)]
Introduction of CUDA Graphs to LLama.cpp (llama/6766)

* DRAFT: Introduction of CUDA Graphs to LLama.cpp

* FIx issues raised in comments

* Tidied to now only use CUDA runtime (not mixed with driver calls)

* disable for multi-gpu and batch size > 1

* Disable CUDA graphs for old GPU arch and with env var

* added missing CUDA_CHECKs

* Addressed comments

* further addressed comments

* limit to GGML_ALLOW_CUDA_GRAPHS defined in llama.cpp cmake

* Added more comprehensive graph node checking

* With mechanism to fall back if graph capture fails

* Revert "With mechanism to fall back if graph capture fails"

This reverts commit eb9f15fb6fcb81384f732c4601a5b25c016a5143.

* Fall back if graph capture fails and address other comments

* - renamed GGML_ALLOW_CUDA_GRAPHS to GGML_CUDA_USE_GRAPHS

- rename env variable to disable CUDA graphs to GGML_CUDA_DISABLE_GRAPHS

- updated Makefile build to enable CUDA graphs

- removed graph capture failure checking in ggml_cuda_error
  using a global variable to track this is not thread safe, but I am also not safistied with checking an error by string
  if this is necessary to workaround some issues with graph capture with eg. cuBLAS, we can pass the ggml_backend_cuda_context to the error checking macro and store the result in the context

- fixed several resource leaks

- fixed issue with zero node graphs

- changed fixed size arrays to vectors

- removed the count of number of evaluations before start capturing, and instead changed the capture mode to relaxed

- removed the check for multiple devices so that it is still possible to use a single device, instead checks for split buffers to disable cuda graphs with -sm row

- changed the op for checking batch size to GGML_OP_ADD, should be more reliable than GGML_OP_SOFT_MAX

- code style fixes

- things to look into
  - VRAM usage of the cudaGraphExec_t, if it is significant we may need to make it optional
  - possibility of using cudaStreamBeginCaptureToGraph to keep track of which ggml graph nodes correspond to which cuda graph nodes

* fix build without cuda graphs

* remove outdated comment

* replace minimum cc value with a constant

---------

Co-authored-by: slaren <redacted>
13 months agometal : use `vm_allocate` instead of `posix_memalign` on macOS (llama/7078)
Gilad S [Wed, 8 May 2024 19:08:10 +0000 (22:08 +0300)]
metal : use `vm_allocate` instead of `posix_memalign` on macOS (llama/7078)

* fix: use `malloc` instead of `posix_memalign` in `ggml-metal.m` to make it not crash Electron proccesses

* fix: typo

* fix: use `vm_allocate` instead of `posix_memalign`

* fix: don't call `newBufferWithBytesNoCopy` with `NULL` when `ggml_metal_host_malloc` returns `NULL`

* fix: use `vm_allocate` only on macOS

13 months agoggml : introduce bfloat16 support (llama/6412)
Justine Tunney [Wed, 8 May 2024 06:30:09 +0000 (02:30 -0400)]
ggml : introduce bfloat16 support (llama/6412)

* Introduce bfloat16 support

Many models on Hugging Face (e.g. Mistral, TinyLLaMA) use bfloat16 as
their canonical floating point format.

      ┌sign
      │
      │   ┌exponent
      │   │
      │   │      ┌mantissa
      │   │      │
      │┌──┴───┐┌─┴───┐
    0b0000000000000000 brain16

This encoding has the same number of exponent bits as float32. That
makes conversion relatively straightforward, even in the absence of
hardware support. For example, converting brain16 to binary32 means
simply shifting 16 bits to the left.

      ┌sign
      │
      │   ┌exponent
      │   │
      │   │      ┌mantissa
      │   │      │
      │┌──┴───┐┌─┴───────────────────┐
    0b00000000000000000000000000000000 IEEE binary32

The issue is that converting bf16 to fp16 can result in information
loss. Only 13% of bf16 numbers can be precisely represented in fp16
which in practice ends up being 99.71% of Mistral 7b v0.2's weights
however there is currently no way other than fp32 to get the others

      ┌sign
      │
      │  ┌exponent
      │  │
      │  │    ┌mantissa
      │  │    │
      │┌─┴─┐┌─┴──────┐
    0b0000000000000000 IEEE binary16

This change fixes that, by adding a bf16 data type to GGML. Support
for CPU inference has been implemented along with optimizations for
the AVX2, AVX512, and AVX512BF16 ISAs. Perplexity on Mistral 7b 0.2
improves somewhere around -0.0024 to -0.0046 compared to using fp16

* Remove GGML code that's not needed

* Minimize the GGML API surface area for BF16

* Remove bf16 luts

* Make the GGML header look nicer

* Fix documentation

* Apply ggerganov's fixes for test-backend-ops

* Add BF16 code for new ggml_validate_row_data() function

13 months agometal : fix unused warning
Georgi Gerganov [Wed, 8 May 2024 06:14:50 +0000 (09:14 +0300)]
metal : fix unused warning

13 months agoAdd an option to build without CUDA VMM (llama/7067)
William Tambellini [Mon, 6 May 2024 18:12:14 +0000 (11:12 -0700)]
Add an option to build without CUDA VMM (llama/7067)

Add an option to build ggml cuda without CUDA VMM
resolves
https://github.com/ggerganov/llama.cpp/issues/6889
https://forums.developer.nvidia.com/t/potential-nvshmem-allocated-memory-performance-issue/275416/4

13 months agogguf-split: add --no-tensor-first-split (llama/7072)
Xuan Son Nguyen [Sat, 4 May 2024 16:56:22 +0000 (18:56 +0200)]
gguf-split: add --no-tensor-first-split (llama/7072)

13 months agoCUDA: CUDART < 11.7 workaround for __hmax, __hmax2 (llama/7019)
Johannes Gäßler [Wed, 1 May 2024 12:46:37 +0000 (14:46 +0200)]
CUDA: CUDART < 11.7 workaround for __hmax, __hmax2 (llama/7019)

13 months agoswitch to using localizedDescription (llama/7010)
Kevin Gibbons [Tue, 30 Apr 2024 15:14:02 +0000 (08:14 -0700)]
switch to using localizedDescription (llama/7010)

13 months agometal : remove deprecated error code (llama/7008)
Georgi Gerganov [Tue, 30 Apr 2024 12:52:21 +0000 (15:52 +0300)]
metal : remove deprecated error code (llama/7008)

13 months agometal : log more info on error (llama/6987)
Kevin Gibbons [Tue, 30 Apr 2024 09:34:50 +0000 (02:34 -0700)]
metal : log more info on error (llama/6987)

13 months agoggml : add Flash Attention (llama/5021)
Georgi Gerganov [Tue, 30 Apr 2024 09:16:08 +0000 (12:16 +0300)]
ggml : add Flash Attention (llama/5021)

* ggml : add ggml_flash_attn_ext API

* ggml : fix GQA support in ggml_flash_attn_ext

* ggml : online attention (CPU)

* metal : initial implementation

* metal : f16 precision

* metal : reduce branches

* metal : specialize for head size

* wip : 8 rows per simd group

* wip : 4 rows per simd group

* wip : template for rows per warp

* metal : parallelize across KV size

* metal : parallel reduce across heads

* metal : efficient flash_attn_f16 implementation

* metal : avoid redundant loads of the attention

* metal : scale and mask in matrix form

* metal : fix comment

* llama : avoid ggml_cast, use F32 query

* metal : add parallel reduce version (disabled)

* metal : move output into local memory + optimize

- the result from each simdgroup now stays in the registers
- significantly reduced SRAM usage
- more efficient skipping of -INF blocks
- avoid simdgroup barrier in hot loop
- add comments

* metal : add tests, fix scaling, support C > 32

* metal : improve precision

* ggml : fix f16 mad

* metal : minor

* metal : support Q > 8

* tests : add ATTN tests

* metal : disable buffer allocation logs

* tests : more

* metal : faster inner loop for C == 32

* metal : fix array initialization

* tests : ifdef

* ggml : switch to padded F16 mask for ggml_soft_max, ggml_flash_attn_ext

* ggml : fix ggml_soft_max mask requirement

* cuda : fix soft_max to use correct mask size

* cuda : add flash_attn kernel (wip)

* metal : optimize softmax for C > 32

* metal : optimize softmax

* tests : minor fix

* cuda : avoid zeroing fragments

* tests : update dims

* cuda : fix __hisinf() result check

* cuda : avoid warp_reduce for smax

* cuda : use int instead of int64_t

Noticeably improves performance (thanks to Johannes)

* cuda : make loops use the same loop values

Thanks Johannes again for the tip

* cuda : unroll some of the loops

* cuda : avoid __hisinf branches

* cuda : use half2 in softmax

* cuda : switch to 1 warp for bs > 16

* cuda : speed-up reduce part of the kernel

* cuda : unroll Q*K^T loop

* cuda : fix -INF block check

* cuda : simplify softmax

* cuda : fix matrix names

* cuda : minor

* llama : adapt to F16 KQ_pos

* llama : adapt new models to F16 KQ_mask

* ggml : fix F16 store (ARM NEON)

* llama : fix type of KQ_mask and KQ_pos

* ggml : fix CPU soft_max

* tests : add hs=256

* cuda : fix build

* metal : improve perf via smaller int registers

* cuda : adapt soft_max to F16 mask and pos

* CUDA: faster FlashAttention, kernel for bs == 1

* 16 cols for Phi-2

* no vec for hs, no hs==256 ncols==32 for Volta

* adjust kernel selection logic

* 4 warps, 256 stride for all D

* no ncols == 64

* Multiple parallel blocks for batch size 1

* fix compile warnings

* fix excessive KQ_b loads

* fix cmake build

* fix KV cache padding, NaN from INFINITY (llama/6438)

* llama : flash_attn cparam + fix defrag

* server: support flash_attn param

* server: bench: enable flash_attn param

* CUDA: refactor host code, dyn. par. blocks

* fix flash_attn_vec_f16 race condition

* flush softmax exp below threshold to 0

* store temp KQ in registers

* Calculate KQ as FP32 if KQV has GGML_PREC_F32

* Add __hgt2_mask implementation for CUDA 11

* fix KQ FP32 precision fpr parallel_blocks > 1

* llama-bench : add -fa,--flash-attn arg

* metal : add BS=1 kernel for flash attention (llama/6508)

* metal : add BS=1 kernel for flash attention (wip)

* metal : support more than 1 warps

* metal : opts

* metal : opt

* metal : switch to parallel reduce

* metal : reduce registers

* metal : simplify

* metal : initial FA vec kernel

* metal : use F32 attention accumulators

* batched-bench : add fattn arg

* llama : simplify llama_build_kv_store

ggml-ci

* llama : adapt build_olmo to changes

* ggml : fix arm fp16 store on windows

* metal : clean-up

* metal : clean-up kernel code

* metal : minor

* tests : remove benchmarks

ggml-ci

* ggml : fix avx512 const correctness

ggml-ci

* ggml : fix soft_max with bias on CPU

ggml-ci

* common : print --flash-attn in help

* ggml : fix num dimensions in ggml_flash_attn_ext

* llama : force disable flash attention for incompatible models

* ggml : ggml_soft_max support F16/F32 mask/pos

ggml-ci

* cuda : uint -> uint32_t

* cuda : "constexpr dim3" -> "const dim3"

ggml-ci

* cuda : try to fix __hgt2_mask

ggml-ci

* ggml : add TODO's for F16/F32 mask/pos support in other backends

* llama : replace bool need_kq_pos with use_alibi

* llama : prep ALiBi support for BERT models

ggml-ci

* llama : fix n_batch requirements

ggml-ci

* cont

* server : add help for --flash-attn arg

* llama : disable FA for AMD

* tests : remove TMP_ATTN_BENCH

ggml-ci

* llama : support save/load state with FA enabled

ggml-ci

* ci : add CUDA save-load-state tests

ggml-ci

* llama : llama_kv_cache_clear zeroes data + fix save-load seq

ggml-ci

* llama : fix copy-paste errors, add TODO

* llama : disallow incompatible states

* llama : update llama_state_get_size after v_trans field

* metal : remove tmp log

* llama : add static reminder for llama_state_get_size

* metal : fix max nsg

ggml-ci

* ci : fix arg order

ggml-ci

---------

Co-authored-by: Johannes Gäßler <redacted>
Co-authored-by: Pierrick HYMBERT <redacted>
13 months agoggml : fix __MSC_VER -> _MSC_VER (llama/6977)
Georgi Gerganov [Mon, 29 Apr 2024 14:55:02 +0000 (17:55 +0300)]
ggml : fix __MSC_VER -> _MSC_VER (llama/6977)

ggml-ci

13 months agoFix more int overflow during quant (PPL/CUDA). (llama/6563)
DAN™ [Sun, 28 Apr 2024 22:38:44 +0000 (18:38 -0400)]
Fix more int overflow during quant (PPL/CUDA). (llama/6563)

* Fix more int overflow during quant.

* Fix some more int overflow in softmax.

* Revert back to int64_t.

13 months agogguf : enforce that tensor names are unique (llama/6905)
Xuan Son Nguyen [Sun, 28 Apr 2024 15:36:18 +0000 (17:36 +0200)]
gguf : enforce that tensor names are unique (llama/6905)

* not allow adding duplicated tensor name

* no duplicated tensor while reading gguf

* typo

* throw exception inside llama_model_loader

Co-authored-by: slaren <redacted>
---------

Co-authored-by: slaren <redacted>