]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/log
pkg/ggml/sources/whisper.cpp
13 months agoexamples : add support for decoding input with ffmpeg (Linux) (#2133)
William Tambellini [Tue, 21 May 2024 15:31:41 +0000 (08:31 -0700)]
examples : add support for decoding input with ffmpeg (Linux) (#2133)

- search for ffmpeg libs/headers at cmake time
- added ffmpeg-transcode.cpp into libcommon if ffmpeg on
- hooked ffmpeg trancoding in common read_wav(...)
- passed test:
./main -m ggml-base.en.bin -f samples/jfk.mp3

13 months agonode : add flash_attn param (#2170)
Pedro Probst [Mon, 20 May 2024 06:08:48 +0000 (03:08 -0300)]
node : add flash_attn param (#2170)

13 months agoci: Update build.yml to suppress warnings about node.js versions (#2166)
Tamotsu Takahashi [Sun, 19 May 2024 08:49:26 +0000 (17:49 +0900)]
ci: Update build.yml to suppress warnings about node.js versions (#2166)

* Update actions to suppress warnings about old node.js

https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/

* Update actions/upload-artifact, specify android cmdline-tools-version

* Use java 20

gradle 8.1 complains against 21
https://docs.gradle.org/current/userguide/compatibility.html

13 months agorelease : v1.6.0
Georgi Gerganov [Wed, 15 May 2024 06:59:48 +0000 (09:59 +0300)]
release : v1.6.0

13 months agowhisper : use flash attention (#2152)
Georgi Gerganov [Wed, 15 May 2024 06:38:19 +0000 (09:38 +0300)]
whisper : use flash attention (#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 agotalk-llama : reject runs without required arguments (#2153)
petterreinholdtsen [Tue, 14 May 2024 18:32:41 +0000 (20:32 +0200)]
talk-llama : reject runs without required arguments (#2153)

* Extended talk-llama example to reject runs without required arguments.

Print warning and exit if models are not specified on the command line.

* Update examples/talk-llama/talk-llama.cpp

* Update examples/talk-llama/talk-llama.cpp

---------

Co-authored-by: Georgi Gerganov <redacted>
13 months agosync : ggml
Georgi Gerganov [Tue, 14 May 2024 16:16:32 +0000 (19:16 +0300)]
sync : ggml

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:15:35 +0000 (19:15 +0300)]
scripts : sync ggml-rpc

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

* fix: model path encoding in windows

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

13 months agoserver : return utf-8 (#2138)
Georgi Gerganov [Mon, 13 May 2024 12:33:46 +0000 (15:33 +0300)]
server : return utf-8 (#2138)

13 months agonode : add audio_ctx and audio buffer params (#2123)
Pedro Probst [Mon, 13 May 2024 12:22:23 +0000 (09:22 -0300)]
node : add audio_ctx and audio buffer params (#2123)

* node : add audio_ctx param

* node : support passing audio buffer directly

* node : parse audio_ctx in index.js

---------

Co-authored-by: Georgi Gerganov <redacted>
13 months agocmake : fix HIP/ROCm build (#2102)
aldorof [Mon, 13 May 2024 12:18:43 +0000 (08:18 -0400)]
cmake : fix HIP/ROCm build (#2102)

13 months agonode : add additional params (#2000)
valVk [Mon, 13 May 2024 12:15:43 +0000 (15:15 +0300)]
node : add additional params (#2000)

* Add additional params to addon.node

* Add comma_in_time as parameter

* Fix tests

13 months agojs : remove un-needed request header from fetchRemote (#2119)
Mark Karpelès [Mon, 13 May 2024 12:13:19 +0000 (21:13 +0900)]
js : remove un-needed request header from fetchRemote (#2119)

13 months agocmake : fix metal embed sources path (#2110)
Georgi Gerganov [Mon, 13 May 2024 12:09:35 +0000 (15:09 +0300)]
cmake : fix metal embed sources path (#2110)

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

Signed-off-by: Daniel Ziegenberg <redacted>
13 months agomain : add options for temperature control (#2088)
Daniel Ziegenberg [Mon, 13 May 2024 11:59:44 +0000 (13:59 +0200)]
main : add options for temperature control (#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 (#0)
Georgi Gerganov [Mon, 13 May 2024 11:43:43 +0000 (14:43 +0300)]
whisper : switch back to F32 mask (#0)

13 months agowhisper.android : update example, add field to print timestamp (#2072)
zhangjixiong [Mon, 13 May 2024 11:30:03 +0000 (19:30 +0800)]
whisper.android : update example, add field to print timestamp (#2072)

13 months agocmake : fix json INTERFACE library (#2069)
Xingchen Song(宋星辰) [Mon, 13 May 2024 11:29:39 +0000 (19:29 +0800)]
cmake : fix json INTERFACE library (#2069)

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

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

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

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

13 months agoggml : remove oboslete alibi code (skipme) (#0)
Georgi Gerganov [Sun, 12 May 2024 17:55:57 +0000 (20:55 +0300)]
ggml : remove oboslete alibi code (skipme) (#0)

13 months agotalk-llama : sync llama.cpp
Georgi Gerganov [Sun, 12 May 2024 17:12:46 +0000 (20:12 +0300)]
talk-llama : sync llama.cpp

13 months agosync : ggml
Georgi Gerganov [Sun, 12 May 2024 16:23:22 +0000 (19:23 +0300)]
sync : ggml

13 months agoggml : optimize for ppc64le using VSX intrinsics (ggml/784)
Hong Bo PENG [Sun, 12 May 2024 09:17:18 +0000 (17:17 +0800)]
ggml : optimize for ppc64le using VSX intrinsics (ggml/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 agometal : fix indent (ggml/0)
Georgi Gerganov [Sat, 11 May 2024 13:57:53 +0000 (16:57 +0300)]
metal : fix indent (ggml/0)

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

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

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>
13 months agoadd device version in device list (llama/6959)
Neo Zhang [Sun, 28 Apr 2024 14:40:31 +0000 (22:40 +0800)]
add device version in device list (llama/6959)

Co-authored-by: arthw <>
13 months agoReset schedule earlier to allow overlap with ggml graph computation on device (llama...
agray3 [Fri, 26 Apr 2024 18:08:30 +0000 (19:08 +0100)]
Reset schedule earlier to allow overlap with ggml graph computation on device (llama/6933)

* Reset schedule earlier to allow overlap with graph computation on device

13 months agoadd basic tensor data validation function (llama/6884)
slaren [Fri, 26 Apr 2024 16:39:58 +0000 (18:39 +0200)]
add basic tensor data validation function (llama/6884)

* add basic tensor data validation function

* add --check-tensors command line argument

tensor validation is disabled by default and can be enabled by adding
`--check-tensors` to the command line arguments.

quantize always validates tensors.

13 months agogguf : fix mismatch between alloc and free functions (llama/6929)
slaren [Fri, 26 Apr 2024 15:07:42 +0000 (17:07 +0200)]
gguf : fix mismatch between alloc and free functions (llama/6929)

13 months agoMerge pull request from GHSA-p5mv-gjc5-mwqv
Georgi Gerganov [Fri, 26 Apr 2024 07:41:53 +0000 (10:41 +0300)]
Merge pull request from GHSA-p5mv-gjc5-mwqv

* always use calloc

clamp n_kv on failure to read a kv

* ggml : alternative ctx->header.n_kv update

---------

Co-authored-by: slaren <redacted>
13 months agoggml : fix redefinition of vaddvq_f32 for 32-bit ARM (llama/6906)
Georgi Gerganov [Thu, 25 Apr 2024 12:48:25 +0000 (15:48 +0300)]
ggml : fix redefinition of vaddvq_f32 for 32-bit ARM (llama/6906)

13 months agoggml : fix MIN / MAX macros (llama/6904)
Georgi Gerganov [Thu, 25 Apr 2024 12:12:28 +0000 (15:12 +0300)]
ggml : fix MIN / MAX macros (llama/6904)

ggml-ci

13 months agoggml : move 32-bit arm compat in ggml-impl.h (llama/6865)
Georgi Gerganov [Wed, 24 Apr 2024 09:00:07 +0000 (12:00 +0300)]
ggml : move 32-bit arm compat in ggml-impl.h (llama/6865)

ggml-ci

13 months agollamafile : improve sgemm.cpp (llama/6796)
Justine Tunney [Mon, 22 Apr 2024 19:00:36 +0000 (15:00 -0400)]
llamafile : improve sgemm.cpp (llama/6796)

* llamafile : improve sgemm.cpp

- Re-enable by default
- Fix issue described in #6716
- Make code more abstract, elegant, and maintainable
- Faster handling of weirdly shaped `m` an `n` edge cases

* Address review comments

* Help clang produce fma instructions

* Address review comments

13 months agoggml : fix calloc argument ordering. (llama/6820)
Dave Airlie [Mon, 22 Apr 2024 14:05:06 +0000 (00:05 +1000)]
ggml : fix calloc argument ordering. (llama/6820)

Latest gcc complains here:
/home/airlied/devel/llama.cpp/ggml-alloc.c: In function ‘ggml_gallocr_new_n’:
/home/airlied/devel/llama.cpp/ggml-alloc.c:374:59: warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
  374 |     ggml_gallocr_t galloc = (ggml_gallocr_t)calloc(sizeof(struct ggml_gallocr), 1);
      |                                                           ^~~~~~
/home/airlied/devel/llama.cpp/ggml-alloc.c:374:59: note: earlier argument should specify number of elements, later size of each element

and a bunch more.

calloc is specified to take nmemb first then size, so realign the code.

In a couple of places there was a * x, 1 so I fixed those to use calloc properly.

13 months agoggml : fix ggml_backend_cpu_supports_op() for CPY (llama/0)
Georgi Gerganov [Sun, 21 Apr 2024 13:47:57 +0000 (16:47 +0300)]
ggml : fix ggml_backend_cpu_supports_op() for CPY (llama/0)

13 months agoggml : group all experts in a single ggml_mul_mat_id (llama/6505)
slaren [Thu, 18 Apr 2024 13:18:48 +0000 (15:18 +0200)]
ggml : group all experts in a single ggml_mul_mat_id (llama/6505)

* ggml : group all experts in a single ggml_mul_mat_id
cuda : improve mmid row copy

* cuda : fix bin bcast with non-cont src0

* test-backend-ops : only run all mul mat tests for base types

* llama : disable moe offloading with SYCL

---------

Co-authored-by: Georgi Gerganov <redacted>
13 months agoggml : fix llamafile sgemm wdata offsets (llama/6710)
Georgi Gerganov [Tue, 16 Apr 2024 20:50:22 +0000 (23:50 +0300)]
ggml : fix llamafile sgemm wdata offsets (llama/6710)

ggml-ci

13 months agoggml : add llamafile sgemm (llama/6414)
Justine Tunney [Tue, 16 Apr 2024 18:55:30 +0000 (14:55 -0400)]
ggml : add llamafile sgemm (llama/6414)

This change upstreams llamafile's cpu matrix multiplication kernels
which improve image and prompt evaluation speed. For starters, Q4_0
and Q8_0 weights should go ~40% faster on CPU. The biggest benefits
are with data types like f16 / f32, which process prompts 2x faster
thus making them faster than quantized data types for prompt evals.

This change also introduces bona fide AVX512 support since tinyBLAS
is able to exploit the larger register file. For example, on my CPU
llama.cpp llava-cli processes an image prompt at 305 tokens/second,
using the Q4_K and Q4_0 types, which has always been faster than if
we used f16 LLaVA weights, which at HEAD go 188 tokens/second. With
this change, f16 LLaVA performance leap frogs to 464 tokens/second.

On Intel Core i9-14900K this change improves F16 prompt perf by 5x.
For example, using llama.cpp at HEAD with Mistral 7b f16 to process
a 215 token prompt will go 13 tok/sec. This change has fixes making
it go 52 tok/sec. It's mostly thanks to my vectorized outer product
kernels but also because I added support for correctly counting the
number of cores on Alderlake, so the default thread count discounts
Intel's new efficiency cores. Only Linux right now can count cores.

This work was sponsored by Mozilla who's given permission to change
the license of this code from Apache 2.0 to MIT. To read more about
what's improved, and how it works, see: https://justine.lol/matmul/

13 months agollama : add qwen2moe (llama/6074)
Shijie [Tue, 16 Apr 2024 15:40:48 +0000 (23:40 +0800)]
llama : add qwen2moe (llama/6074)

* support qwen2moe

* fix-review

* metal : support unary ops for nelements % 4 != 0

* metal : require contiguousness for float4 unary kernels

* metal : require contiguousness for float4 unary kernels (cont)

* fix-review

* names : for brevity "SHARED_EXP" -> "SHEXP"

* llama : reuse build_moe_ffn()

* llama : add model type name

---------

Co-authored-by: Georgi Gerganov <redacted>
13 months agofix mul_mat_id() for new input, make the ut pass (llama/6682)
Neo Zhang Jianyu [Mon, 15 Apr 2024 09:12:26 +0000 (17:12 +0800)]
fix mul_mat_id() for new input, make the ut pass (llama/6682)

13 months agoAdded support for GGML_OP_CLAMP in Metal (llama/6662)
Dave [Sun, 14 Apr 2024 11:14:19 +0000 (07:14 -0400)]
Added support for GGML_OP_CLAMP in Metal (llama/6662)

* Added support for GGML_OP_CLAMP in Metal

* Corrected size

---------

Co-authored-by: dave-fl <redacted>
13 months agofix memcpy() crash, add missed cmd in guide, fix softmax (llama/6622)
Neo Zhang Jianyu [Sun, 14 Apr 2024 02:42:29 +0000 (10:42 +0800)]
fix memcpy() crash, add missed cmd in guide, fix softmax (llama/6622)

* disable mmap to fix memcpy crash, add missed cmd in guide, fix softmax

* refactor to disable mmap for SYCL backend

* fix compile error in other os

* refactor the solution, use host buf to fix it, instead of disable mmap

* keep to support mmap()

* use host buff to reduce malloc times

* revert to malloc/free solution, for threaad safe

13 months agoCUDA: fix matrix multiplication logic for tests (llama/6667)
Johannes Gäßler [Sat, 13 Apr 2024 22:21:55 +0000 (00:21 +0200)]
CUDA: fix matrix multiplication logic for tests (llama/6667)

13 months agometal : unify mul_mv_id kernels (llama/6556)
slaren [Fri, 12 Apr 2024 16:13:20 +0000 (18:13 +0200)]
metal : unify mul_mv_id kernels (llama/6556)

13 months agollama : add gguf_remove_key + remove split meta during quantize (llama/6591)
jiez [Fri, 12 Apr 2024 10:45:06 +0000 (18:45 +0800)]
llama : add gguf_remove_key + remove split meta during quantize (llama/6591)

* Remove split metadata when quantize model shards

* Find metadata key by enum

* Correct loop range for gguf_remove_key and code format

* Free kv memory

---------

Co-authored-by: z5269887 <redacted>
13 months agofeat: implemented sigmoid function (ggml/806)
Justina Cho [Wed, 1 May 2024 21:44:26 +0000 (14:44 -0700)]
feat: implemented sigmoid function (ggml/806)

* added sigmoid function

* implemented metal kernel for sigmoid

* implemented cuda kernel for sigmoid

* added sigmoid unary op and incremented count

13 months agobuild: fix and ignore msvc warnings (ggml/805)
Borislav Stanimirov [Thu, 25 Apr 2024 14:24:07 +0000 (17:24 +0300)]
build: fix and ignore msvc warnings (ggml/805)

13 months agoggml : expose SSE3 and SSSE3 for MSVC when AVX is available (#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 (#2128)

13 months agobuild : improve disabling AVX-512 (#2129)
Przemysław Pawełczyk [Wed, 8 May 2024 15:32:43 +0000 (17:32 +0200)]
build : improve disabling AVX-512 (#2129)

* cmake : make WHISPER_NO_AVX512=ON disable all subsets of AVX-512

Previously it happened only for MSVC, but it makes sense to have the
same behavior for other compilers too.

* make : reorder x86 ISA extensions in chronological order

And update compiler flags at the end to ease modifying conditions.

* make : support WHISPER_NO_AVX512=1 for disabling all AVX-512 subsets.

That way you do not have to override each AVX-512 subset setting
individually if it has been turned on during autodetection.

13 months agominor: add CMakeSettings.json to gitignore (#2094)
Borislav Stanimirov [Wed, 8 May 2024 08:03:21 +0000 (11:03 +0300)]
minor: add CMakeSettings.json to gitignore (#2094)

13 months agoexamples : fix node compilation (#2115)
Pedro Probst [Thu, 2 May 2024 21:52:55 +0000 (18:52 -0300)]
examples : fix node compilation (#2115)

* node : fix compilation and update examples

* node : fix readme

* Update addon.node test

14 months agomake : change GNU make default CXX from g++ to c++ (#2100)
Przemysław Pawełczyk [Sun, 28 Apr 2024 21:54:21 +0000 (23:54 +0200)]
make : change GNU make default CXX from g++ to c++ (#2100)

14 months agoRemove unnecessary memory reallocation in fft (#2080)
goldwaving [Sun, 28 Apr 2024 17:36:12 +0000 (15:06 -0230)]
Remove unnecessary memory reallocation in fft (#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.

14 months agomodels : disable old script (#2079)
Georgi Gerganov [Wed, 24 Apr 2024 11:56:30 +0000 (14:56 +0300)]
models : disable old script (#2079)

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

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

14 months agoreadme : add up-to-date repository for Python bindings (#2063)
AIWintermuteAI [Tue, 16 Apr 2024 11:15:52 +0000 (19:15 +0800)]
readme : add up-to-date repository for Python bindings (#2063)

README

14 months agorelease : v1.5.5
Georgi Gerganov [Tue, 16 Apr 2024 11:08:31 +0000 (14:08 +0300)]
release : v1.5.5

14 months agoserver : add dtw (#2044)
Emmanuel Schmidbauer [Mon, 15 Apr 2024 19:16:58 +0000 (15:16 -0400)]
server : add dtw (#2044)

* server.cpp: add dtw

* Update examples/server/server.cpp

---------

Co-authored-by: Georgi Gerganov <redacted>
14 months agobuild : fix embedded Metal library generation (#2045)
Didzis Gosko [Mon, 15 Apr 2024 17:23:05 +0000 (20:23 +0300)]
build : fix embedded Metal library generation (#2045)

14 months agonode : support no timestamps (#2048)
Pedro Probst [Mon, 15 Apr 2024 17:03:34 +0000 (14:03 -0300)]
node : support no timestamps (#2048)

* fix: node: do not compute timestamps if you do not need them

* feat: add no_timestamps parameter to node addon

14 months agobuild : detect AVX512 in Makefile, add AVX512 option in CMake (#2043)
Didzis Gosko [Mon, 15 Apr 2024 17:02:09 +0000 (20:02 +0300)]
build : detect AVX512 in Makefile, add AVX512 option in CMake (#2043)

* make : add AVX512 detection to Makefile and CMakeLists.txt

* make : autodetect more AVX512 instruction subsets

* cmake : do not default to AVX512, must be enabled explicitly

* cmake : enable a set of AVX512 subsets, when AVX512 is turned on

* make : consolidate AVX512 subsets, add AVX512 VBMI

* cmake : revert to NO AVX512 setting, add settings for AVX512 VNNI and VBMI

* make : re-introduce AVX512VNNI back

* cmake : remove superfluous comment line

14 months agowhisper.nvim : fix missing reference to "model" variable (#2049)
Kendrick Taylor [Mon, 15 Apr 2024 16:41:28 +0000 (09:41 -0700)]
whisper.nvim : fix missing reference to "model" variable (#2049)

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

preceeding -> preceding

14 months agosync : ggml
Georgi Gerganov [Tue, 9 Apr 2024 17:27:55 +0000 (20:27 +0300)]
sync : ggml

14 months agolicense : update copyright notice + add AUTHORS
Georgi Gerganov [Tue, 9 Apr 2024 17:27:44 +0000 (20:27 +0300)]
license : update copyright notice + add AUTHORS

14 months agollama : add Command R Plus support (llama/6491)
Carolinabanana [Tue, 9 Apr 2024 08:16:13 +0000 (09:16 +0100)]
llama : add Command R Plus support (llama/6491)

* Add Command R Plus GGUF

* Add Command R Plus GGUF

* Loading works up to LayerNorm2D

* Export new tensors in 1D so they are not quantized.

* Fix embedding layer based on Noeda's example

* Whitespace

* Add line

* Fix unexpected tokens on MPS. Re-add F16 fix. ((Noeda)

* dranger003: Fix block index overflow in CUDA dequantizing.

* Reverted blocked multiplication code as it still has issues and could affect other Llama arches

* export norms as f32

* fix overflow issues during quant and other cleanup

* Type convention

Co-authored-by: Georgi Gerganov <redacted>
* dranger003: Fix more int overflow during quant.

---------

Co-authored-by: S <redacted>
Co-authored-by: S <redacted>
Co-authored-by: slaren <redacted>
Co-authored-by: Georgi Gerganov <redacted>
14 months agoremove row=1 cond (llama/6532)
Abhilash Majumder [Mon, 8 Apr 2024 08:26:01 +0000 (13:56 +0530)]
remove row=1 cond (llama/6532)

14 months agosupport/fix OPs GGML_TYPE_IQ4_NL, GGML_TYPE_IQ4_XS, GGML_TYPE_IQ3_XXS, GGML_TYPE_IQ3_...
Neo Zhang Jianyu [Sun, 7 Apr 2024 02:55:59 +0000 (10:55 +0800)]
support/fix OPs GGML_TYPE_IQ4_NL, GGML_TYPE_IQ4_XS, GGML_TYPE_IQ3_XXS, GGML_TYPE_IQ3_S, GGML_TYPE_IQ2_XXS, GGML_TYPE_IQ2_XS, GGML_TYPE_IQ2_S, GGML_TYPE_IQ1_S, GGML_TYPE_IQ1_M (llama/6521)