Commit Graph
100 Commits
Author SHA1 Message Date
Georgi Gerganov e293f17d34 talk-llama : sync llama.cpp 2024-06-18 09:45:37 +03:00
Georgi Gerganovandslaren 5d950c4b8d whisper : use ggml_backend_sched (#2239)
* whisper : use ggml_backend_sched (wip)

* use sched in whisper_allocr

* whisper : single backend in whisper_context

* whisper : remove whisper_state->backends_used

* whisper : remove whisper_context->backend

* whisper : reset scheduler after init

* whisper : fix external encoder (e.g. CoreML)

* whisper : cleanup

* whisper : handle null GPU buffer types + fix sycl

---------

Co-authored-by: slaren <slarengh@gmail.com>
2024-06-18 09:39:40 +03:00
Georgi Gerganov 820446e230 fix : remove extra files 2024-06-18 09:39:40 +03:00
Georgi Gerganov 54d5823ebe scripts : sync ggml-blas 2024-06-18 09:39:40 +03:00
Georgi Gerganov 5181494e9f build : update make / cmake 2024-06-18 09:39:40 +03:00
Georgi Gerganov 4a6e6e8b30 sync : ggml 2024-06-18 09:39:40 +03:00
Georgi Gerganov 63a767a134 scripts : stop sync whisper example from ggml 2024-06-18 09:39:40 +03:00
Georgi Gerganov 30841fa786 cmake : fix sycl build (#0) 2024-06-16 18:19:48 +03:00
Georgi Gerganov 3b1ac03828 ggml : remove OpenCL (#0) 2024-06-16 18:19:48 +03:00
Georgi Gerganov 990de617b5 sycl : sync (#0) 2024-06-16 18:19:48 +03:00
Georgi Gerganov 6975600b4b cuda : enable CUDA graphs (#0) 2024-06-16 18:19:48 +03:00
Georgi Gerganov 061eeb9f61 talk-llama : sync llama.cpp 2024-06-16 18:19:48 +03:00
Georgi Gerganov 4942b1b428 cmake : fix CUDA build (#0) 2024-06-16 18:19:48 +03:00
Georgi Gerganov 3c7cc5c437 sync : ggml
ggml-ci
2024-06-16 18:19:48 +03:00
Georgi Gerganov 7a489af2f3 metal : utilize max shared memory for mul_mat_id (llama/7935) 2024-06-16 18:19:48 +03:00
Georgi Gerganov acf3832c9c tests : add non-cont unary tests (llama/7857)
* tests : add non-cont unary tests

* ggml : update unary asserts and "supports_op"

ggml-ci
2024-06-16 18:19:48 +03:00
Georgi Gerganov d29ac44303 ggml : improve ggml_is_contiguous logic (llama/7856)
* ggml : improve ggml_is_contiguous logic

ggml-ci

* ggml : support more contiguous cases

ggml-ci
2024-06-16 18:19:48 +03:00
Georgi Gerganov abab4500fa ggml : refactor rope norm/neox (llama/7634)
* ggml : unify rope norm/neox (CPU)

* ggml : fix compile warning

* ggml : remove GLM rope mode

ggml-ci

* metal : better rope implementation

ggml-ci

* cuda : better rope implementation

ggml-ci

* naming : n_orig_ctx -> n_ctx_orig

ggml-ci

* dev : add reminders to update backends

ggml-ci

* vulkan : fix ggml_rope_ext() usage

* cuda : fix array size + indents

ggml-ci
2024-06-16 18:19:48 +03:00
Georgi Gerganov 3f869af14c ggml : remove OpenCL (llama/7735)
ggml-ci
2024-06-16 18:19:48 +03:00
Georgi Gerganov cbacb7634c ggml : prevent builds with -ffinite-math-only (llama/7726)
This enforces a check that -fno-finite-math-only was set and that the operating
compiling mode is not in finite maths mode. This is because during rewriting of
silu and softmax for cpu #7154 there emerged an issue where the result that was
observed when >1 slot was nondeterministic as found by @JohannesGaessler.

@LostRuins narrowed the problem down to -ffinite-math-only which was theorised
to be due to SiLU, instead of flushing small values to 0, returns NaN or some
other garbage. @jart proposed a fix that @ggerganov then implemented in this fix

ref https://github.com/ggerganov/llama.cpp/pull/7154#issuecomment-2145661825
2024-06-16 18:19:48 +03:00
Georgi Gerganovandjunchao-loongson 9a16c643e2 ggml : fix loongson compile warnings (llama/7537)
* ggml : fix loongson compile warnings

ggml-ci

* Fix loongarch quantize test fail.

Fix unexpected error introduced during rebase code.

* tests : disable json test due to lack of python on the CI node

ggml-ci

---------

Co-authored-by: junchao-loongson <zhaojunchao@loongson.cn>
2024-06-16 18:19:48 +03:00
Georgi Gerganov e66e9ea25b metal : remove invalid asserts (llama/7617) 2024-06-16 18:19:48 +03:00
Georgi Gerganov 276779a849 metal : add missing asserts (llama/7617) 2024-06-16 18:19:48 +03:00
Georgi Gerganov 1f35ce61c1 ggml : fix YARN + add tests + add asserts (llama/7617)
* tests : add rope tests

ggml-ci

* ggml : fixes (hopefully)

ggml-ci

* tests : add non-cont tests

ggml-ci

* cuda : add asserts for rope/norm + fix DS2

ggml-ci

* ggml : assert contiguousness

* tests : reduce RoPE tests

ggml-ci
2024-06-16 18:19:48 +03:00
Georgi Gerganov 4b19cc3ed4 cuda : non-cont concat support (llama/7610)
* tests : add non-cont concat tests

* cuda : non-cont concat support

ggml-ci
2024-06-16 18:19:48 +03:00
Georgi Gerganov 02fc147a0b examples : adapt to new ggml_concat (ggml/0) 2024-06-16 18:19:48 +03:00
Georgi Gerganov 046834198d sycl : fix assert (llama/7563) 2024-06-16 18:19:48 +03:00
Georgi Gerganov 812787cbc5 ggml : generalize GGML_OP_CONCAT (llama/7563)
* ggml : generalize GGML_OP_CONCAT (WIP)

ggml-ci

* tests : add dim != 2 tests

* metal : generalize concat kernel

* tests : naming

* cuda : generalize concat kernel

ggml-ci

* sycl : add warning and assert

* ggml : fix op params handling

* metal : bugfix kernel

ggml-ci

* ggml : reimplement CPU and Metal

* cuda : add asserts

ggml-ci

* ggml : fix ptrs

ggml-ci
2024-06-16 18:19:48 +03:00
Georgi Gerganov 7091c7ab5a metal : add GGML_OP_REPEAT kernels (llama/7557)
ggml-ci
2024-06-16 18:19:48 +03:00
Georgi Gerganov d70ccb75f5 metal : disable FA kernel for HS=256 (llama/7556)
ggml-ci
2024-06-16 18:19:48 +03:00
Georgi Gerganov 5ee048eb67 ggml : restore ggml_rope_xpos_inplace (ggml/0)
ggml-ci
2024-06-16 18:19:48 +03:00
Georgi Gerganov 8cd7a3df37 ggml : silence UB sanitizer error during iq2_xxs quantization (llama/0) 2024-06-16 18:19:48 +03:00
Georgi Gerganov 04a3279320 ggml : remove ggml_flash_attn and ggml_flash_ff (llama/7463)
ggml-ci
2024-06-16 18:19:48 +03:00
Georgi Gerganov 45ddda8e0c ggml : drop support for QK_K=64 (llama/7473)
* ggml : drop support for QK_K=64

ggml-ci

* opencl : restore QK_K=256 define
2024-06-16 18:19:48 +03:00
Georgi Gerganov 5848dfd9c8 cuda : fix compile warning (llama/7454) 2024-06-16 18:19:48 +03:00
Georgi Gerganov c4d6958b3e 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
2024-06-16 18:19:48 +03:00
Georgi Gerganov bbdbc3fc62 metal : handle F16 inf values, fix FA partial offload (llama/7434)
ggml-ci
2024-06-16 18:19:48 +03:00
Georgi Gerganov 705fe30a02 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
2024-06-16 18:19:48 +03:00
Georgi Gerganov 5b7073cae1 scripts : update sync 2024-06-16 12:41:42 +03:00
Georgi Gerganov 420b6abc54 cuda : fix HIPBLAS build (#2234) 2024-06-11 19:14:38 +03:00
Georgi GerganovandJohannes Gäßler 99804b0f3e cuda : fix bounds check for src0 rows in MMVQ kernel (#2231)
* cuda : fix bounds check for src0 rows in MMVQ kernel

* Update ggml-cuda/mmvq.cu

Co-authored-by: Johannes Gäßler <johannesg@5d6.de>

---------

Co-authored-by: Johannes Gäßler <johannesg@5d6.de>
2024-06-11 17:39:01 +03:00
Georgi Gerganov c55964c956 ci : fix CUDA builds (#2232) 2024-06-11 17:21:30 +03:00
Georgi Gerganov c2bdb960cd whisper : free whisper_mel instances (#2220) 2024-06-10 11:00:15 +03:00
Georgi Gerganov 87acd6d629 whisper : whisper_state/backend fixes (#2217)
* whisper : fixes

* ci : WHISPER_CUBLAS -> WHISPER_CUDA
2024-06-06 18:51:36 +03:00
Georgi Gerganov c7b6988678 release : v1.6.2 2024-05-27 10:35:09 +03:00
Georgi Gerganov 05042a782d Revert "whisper : remove extra backend instance (huh?)" (#2182)
This reverts commit 4caa64b73e.
2024-05-27 10:20:25 +03:00
Georgi Gerganov c10db6ea28 release : v1.6.1 2024-05-21 18:44:37 +03:00
Georgi Gerganov 08981d1bac release : v1.6.0 2024-05-15 09:59:48 +03:00
Georgi Gerganov 7094ea5e75 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
2024-05-15 09:38:19 +03:00
Georgi Gerganov f56b8305c4 sync : ggml 2024-05-14 19:16:32 +03:00
Georgi Gerganov 1056ad762c metal : support FA without mask + add asserts (llama/7278)
* ggml : fa without mask + add asserts

ggml-ci

* metal : support non-contiguous KV

ggml-ci
2024-05-14 19:16:29 +03:00
Georgi Gerganov 130f43e4b8 scripts : sync ggml-rpc 2024-05-14 19:15:35 +03:00
Georgi Gerganov 4ef8d9f44e server : return utf-8 (#2138) 2024-05-13 15:33:46 +03:00
Georgi Gerganov 1da5edcde0 cmake : fix metal embed sources path (#2110) 2024-05-13 15:09:59 +03:00
Georgi Gerganov 2b434c449e whisper : switch back to F32 mask (#0) 2024-05-13 14:43:43 +03:00
Georgi Gerganov e6acaf9d91 metal : tune soft_max number of threads (#0) 2024-05-13 11:02:26 +03:00
Georgi Gerganov 2c81e6fd51 whisper : remove old flash attn code (#0) 2024-05-13 11:02:26 +03:00
Georgi Gerganov 9506267ce5 ggml : try fix ppc64 (#0) 2024-05-13 11:02:26 +03:00
Georgi Gerganov fbeb80b5f0 ggml : remove oboslete alibi code (skipme) (#0) 2024-05-13 11:02:26 +03:00
Georgi Gerganov 3fa7d29876 talk-llama : sync llama.cpp 2024-05-13 11:02:26 +03:00
Georgi Gerganov fe179ae0cc sync : ggml 2024-05-13 11:02:26 +03:00
Georgi Gerganov 5a863fbe18 metal : fix indent (ggml/0) 2024-05-13 11:02:26 +03:00
Georgi Gerganov 91c646c61d ggml : restore sigmoid decl order (ggml/0) 2024-05-13 11:02:26 +03:00
Georgi Gerganov accada542a ggml : resolve merge (ggml/0)
ggml-ci
2024-05-13 11:02:26 +03:00
Georgi Gerganov e54329da7b 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
2024-05-13 11:02:26 +03:00
Georgi Gerganov 284fac39fb metal : fix flash attention kernel requirements (llama/7169)
* metal : fix flash attention kernel requirements

ggml-ci

* metal : fix ggml_metal_supports_op

ggml-ci
2024-05-13 11:02:26 +03:00
Georgi Gerganov 1ae1a9cd56 metal : fix unused warning 2024-05-13 11:02:26 +03:00
Georgi Gerganov 1bce67999d metal : remove deprecated error code (llama/7008) 2024-05-13 11:02:26 +03:00
156a33a990 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 <johannesg@5d6.de>
Co-authored-by: Pierrick HYMBERT <pierrick.hymbert@gmail.com>
2024-05-13 11:02:26 +03:00
Georgi Gerganov 5167ebdfca ggml : fix __MSC_VER -> _MSC_VER (llama/6977)
ggml-ci
2024-05-13 11:02:26 +03:00
Georgi Gerganovandslaren 6f7140f568 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 <slarengh@gmail.com>
2024-05-13 11:02:26 +03:00
Georgi Gerganov 05b17112cf ggml : fix redefinition of vaddvq_f32 for 32-bit ARM (llama/6906) 2024-05-13 11:02:26 +03:00
Georgi Gerganov a15fb5cd79 ggml : fix MIN / MAX macros (llama/6904)
ggml-ci
2024-05-13 11:02:26 +03:00
Georgi Gerganov 63fd148d8f ggml : move 32-bit arm compat in ggml-impl.h (llama/6865)
ggml-ci
2024-05-13 11:02:26 +03:00
Georgi Gerganov 2959686019 ggml : fix ggml_backend_cpu_supports_op() for CPY (llama/0) 2024-05-13 11:02:26 +03:00
Georgi Gerganov c97796aa0f ggml : fix llamafile sgemm wdata offsets (llama/6710)
ggml-ci
2024-05-13 11:02:26 +03:00
Georgi Gerganov 858452d58d models : disable old script (#2079) 2024-04-24 14:56:30 +03:00
Georgi Gerganov 7f85e1d7fd whisper : more prominent log message for sub-1s audio (#2065) 2024-04-24 14:46:06 +03:00
Georgi Gerganov b0c3cbf2e8 main : pass nullptr when regex is empty (#2070) 2024-04-17 12:23:47 +03:00
Georgi Gerganov 7395c70a74 release : v1.5.5 2024-04-16 14:08:31 +03:00
Georgi Gerganov 8f253ef3af sync : ggml 2024-04-09 20:27:55 +03:00
Georgi Gerganov c7dc37f97c license : update copyright notice + add AUTHORS 2024-04-09 20:27:44 +03:00
Georgi Gerganov 3b8aade3c2 scripts : update sync 2024-04-09 20:25:50 +03:00
Georgi Gerganov 52ccd4a3a8 files : rename ./extra to ./scripts 2024-04-09 20:13:41 +03:00
Georgi Gerganov 13c22321d1 sync : ggml 2024-04-07 17:04:56 +03:00
Georgi Gerganov ccbe9d5676 extra : sync grammar-parser 2024-04-07 17:04:22 +03:00
Georgi Gerganov 81a3c41aa0 talk-llama : sync llama.cpp 2024-04-07 16:21:08 +03:00
Georgi Gerganov a50207c65d sync : ggml 2024-04-07 16:18:11 +03:00
Georgi Gerganov 97878e53fd sync : llama.cpp (skip)
ggml-ci
2024-04-07 16:15:57 +03:00
Georgi Gerganov a74fde9b4c extra : sync ggml-cuda folder 2024-04-07 16:10:44 +03:00
Georgi Gerganov 9fb308d90f make : add grammar parser to common objects 2024-03-28 11:59:48 +02:00
Georgi Gerganov 2948c740a2 sync : ggml (#2001)
* sync : update scripts

* sync : ggml

* talk-llama : sync llama.cpp

* make : WHISPER_CUBLAS -> WHISPER_CUDA

* ci : try to fix sycl build

* talk-llama : fix make build
2024-03-27 18:55:10 +02:00
Georgi Gerganov 1558ec5a16 whisper : improve handling of prompts (#1981)
* whisper : improve handling of prompts

* whisper : add whisper_token_count helper
2024-03-25 14:48:19 +02:00
Georgi Gerganov 48a145207e ruby : fix build (#1980) 2024-03-21 07:40:09 +02:00
Georgi Gerganov 725350d4ea whisper : set outputs from conv graph (#1959) 2024-03-16 17:30:55 +02:00
Georgi Gerganov 00d80ff965 cmake : copy ggml-common.h to bin 2024-03-16 17:15:44 +02:00
Georgi Gerganov 1b553b9817 gitignore : .vimspector.json 2024-03-16 16:26:35 +02:00
Georgi Gerganov de4d067f1e talk-llama : sync llama.cpp 2024-03-15 14:21:59 +02:00
Georgi Gerganov e715f6a601 sync : ggml 2024-03-15 14:12:19 +02:00
Georgi Gerganov 3753a2b2a8 ggml : add ggml-common.h 2024-03-15 14:01:14 +02:00