]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/log
pkg/ggml/sources/llama.cpp
14 months agoUpdate LOG_IMPL and LOG_TEE_IMPL (#7029)
Andrew Downing [Wed, 1 May 2024 21:31:30 +0000 (17:31 -0400)]
Update LOG_IMPL and LOG_TEE_IMPL (#7029)

ROCm clang defines _MSC_VER which results in the wrong implementation of LOG_IMPL and LOG_TEE_IMPL being compiled.

This fixes https://github.com/ggerganov/llama.cpp/issues/6972

14 months agomain : fix off by one error for context shift (#6921)
l3utterfly [Wed, 1 May 2024 19:27:41 +0000 (04:27 +0900)]
main : fix off by one error for context shift (#6921)

14 months agoServer: add tests for batch size, different seeds (#6950)
Johannes Gäßler [Wed, 1 May 2024 15:52:55 +0000 (17:52 +0200)]
Server: add tests for batch size, different seeds (#6950)

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

14 months agoci : exempt confirmed bugs from being tagged as stale (#7014)
slaren [Wed, 1 May 2024 05:13:59 +0000 (07:13 +0200)]
ci : exempt confirmed bugs from being tagged as stale (#7014)

14 months agoperplexity: more statistics, added documentation (#6936)
Johannes Gäßler [Tue, 30 Apr 2024 21:36:27 +0000 (23:36 +0200)]
perplexity: more statistics, added documentation (#6936)

* perplexity: more statistics, added documentation

* add LLaMA 3 8b scoreboard

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

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

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

14 months agoggml : add Flash Attention (#5021)
Georgi Gerganov [Tue, 30 Apr 2024 09:16:08 +0000 (12:16 +0300)]
ggml : add Flash Attention (#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 (#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 (#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>
14 months agoconvert : use utf8 encoding (#7000)
Georgi Gerganov [Tue, 30 Apr 2024 08:05:25 +0000 (11:05 +0300)]
convert : use utf8 encoding (#7000)

* convert : use utf8 encoding

* convert : update instructions and warning message

14 months agoImprove usability of --model-url & related flags (#6930)
Olivier Chafik [Mon, 29 Apr 2024 23:52:50 +0000 (00:52 +0100)]
Improve usability of --model-url & related flags (#6930)

* args: default --model to models/ + filename from --model-url or --hf-file (or else legacy models/7B/ggml-model-f16.gguf)

* args: main & server now call gpt_params_handle_model_default

* args: define DEFAULT_MODEL_PATH + update cli docs

* curl: check url of previous download (.json metadata w/ url, etag & lastModified)

* args: fix update to quantize-stats.cpp

* curl: support legacy .etag / .lastModified companion files

* curl: rm legacy .etag file support

* curl: reuse regex across headers callback calls

* curl: unique_ptr to manage lifecycle of curl & outfile

* curl: nit: no need for multiline regex flag

* curl: update failed test (model file collision) + gitignore *.gguf.json

14 months agoExtending grammar integration tests (#6644)
Clint Herron [Mon, 29 Apr 2024 18:40:14 +0000 (14:40 -0400)]
Extending grammar integration tests (#6644)

* Cleaning up integration tests to share code between tests and make it simpler to add new tests.

* Add tests around quantifiers to ensure both matching and non-matching compliance.

* Add slightly more complex grammar with quantifiers to test references with quantifiers.

* Fixing build when C++17 is not present.

* Separating test calls to give more helpful stack traces on failure. Adding verbose messages to give visibility for what is being tested.

* Adding quotes around strings to explicitly show whitespace

* Removing trailing whitespace.

* Implementing suggestions from @ochafik -- grammars and test strings now print and flush before tests to aid in debugging segfaults and whatnot.

* Cleaning up forgotten symbols. Modifying simple test to use test harness. Added comments for more verbose descriptions of what each test is accomplishing.

* Unicode symbol modifications to hopefully make log easier to parse visually.

14 months agomain : fix typo in comment in main.cpp (#6985)
Daniel Bevenius [Mon, 29 Apr 2024 17:56:59 +0000 (19:56 +0200)]
main : fix typo in comment in main.cpp (#6985)

Signed-off-by: Daniel Bevenius <redacted>
14 months agobuild(cmake): simplify instructions (`cmake -B build && cmake --build build ...`...
Olivier Chafik [Mon, 29 Apr 2024 16:02:45 +0000 (17:02 +0100)]
build(cmake): simplify instructions (`cmake -B build && cmake --build build ...`) (#6964)

* readme: cmake . -B build && cmake --build build

* build: fix typo

Co-authored-by: Jared Van Bortel <redacted>
* build: drop implicit . from cmake config command

* build: remove another superfluous .

* build: update MinGW cmake commands

* Update README-sycl.md

Co-authored-by: Neo Zhang Jianyu <redacted>
* build: reinstate --config Release as not the default w/ some generators + document how to build Debug

* build: revert more --config Release

* build: nit / remove -H from cmake example

* build: reword debug instructions around single/multi config split

---------

Co-authored-by: Jared Van Bortel <redacted>
Co-authored-by: Neo Zhang Jianyu <redacted>
14 months agoci : tmp disable gguf-split (#6983)
Georgi Gerganov [Mon, 29 Apr 2024 15:36:39 +0000 (18:36 +0300)]
ci : tmp disable gguf-split (#6983)

ggml-ci

14 months agoggml : fix __MSC_VER -> _MSC_VER (#6977)
Georgi Gerganov [Mon, 29 Apr 2024 14:55:02 +0000 (17:55 +0300)]
ggml : fix __MSC_VER -> _MSC_VER (#6977)

ggml-ci

14 months agollava-cli : multiple images (#6969)
cpumaxx [Mon, 29 Apr 2024 14:34:24 +0000 (07:34 -0700)]
llava-cli : multiple images (#6969)

Co-authored-by: root <redacted>
14 months agoreadme : update hot topics
Georgi Gerganov [Mon, 29 Apr 2024 14:06:19 +0000 (17:06 +0300)]
readme : update hot topics

14 months agollama : fix BPE pre-tokenization (#6920)
Georgi Gerganov [Mon, 29 Apr 2024 13:58:41 +0000 (16:58 +0300)]
llama : fix BPE pre-tokenization (#6920)

* merged the changes from deepseeker models to main branch

* Moved regex patterns to unicode.cpp and updated unicode.h

* Moved header files

* Resolved issues

* added and refactored unicode_regex_split and related functions

* Updated/merged the deepseek coder pr

* Refactored code

* Adding unicode regex mappings

* Adding unicode regex function

* Added needed functionality, testing remains

* Fixed issues

* Fixed issue with gpt2 regex custom preprocessor

* unicode : fix? unicode_wstring_to_utf8

* lint : fix whitespaces

* tests : add tokenizer tests for numbers

* unicode : remove redundant headers

* tests : remove and rename tokenizer test scripts

* tests : add sample usage

* gguf-py : reader prints warnings on duplicate keys

* llama : towards llama3 tokenization support (wip)

* unicode : shot in the dark to fix tests on Windows

* unicode : first try custom implementations

* convert : add "tokenizer.ggml.pre" GGUF KV (wip)

* llama : use new pre-tokenizer type

* convert : fix pre-tokenizer type writing

* lint : fix

* make : add test-tokenizer-0-llama-v3

* wip

* models : add llama v3 vocab file

* llama : adapt punctuation regex + add llama 3 regex

* minor

* unicode : set bomb

* unicode : set bomb

* unicode : always use std::wregex

* unicode : support \p{N}, \p{L} and \p{P} natively

* unicode : try fix windows

* unicode : category support via std::regex

* unicode : clean-up

* unicode : simplify

* convert : add convert-hf-to-gguf-update.py

ggml-ci

* lint : update

* convert : add falcon

ggml-ci

* unicode : normalize signatures

* lint : fix

* lint : fix

* convert : remove unused functions

* convert : add comments

* convert : exercise contractions

ggml-ci

* lint : fix

* cmake : refactor test targets

* tests : refactor vocab tests

ggml-ci

* tests : add more vocabs and tests

ggml-ci

* unicode : cleanup

* scripts : ignore new update script in check-requirements.sh

* models : add phi-3, mpt, gpt-2, starcoder

* tests : disable obsolete

ggml-ci

* tests : use faster bpe test

ggml-ci

* llama : more prominent warning for old BPE models

* tests : disable test-tokenizer-1-bpe due to slowness

ggml-ci

---------

Co-authored-by: Jaggzh <redacted>
Co-authored-by: Kazim Abrar Mahi <redacted>
14 months agosampling : use std::random_device{}() for default random seed (#6962)
David Renshaw [Mon, 29 Apr 2024 13:35:45 +0000 (09:35 -0400)]
sampling : use std::random_device{}() for default random seed (#6962)

14 months agoconvert : fix conversion of some BERT embedding models (#6937)
Christian Zhou-Zheng [Mon, 29 Apr 2024 13:34:41 +0000 (09:34 -0400)]
convert : fix conversion of some BERT embedding models (#6937)

14 months agomake : change GNU make default CXX from g++ to c++ (#6966)
Przemysław Pawełczyk [Mon, 29 Apr 2024 13:08:20 +0000 (15:08 +0200)]
make : change GNU make default CXX from g++ to c++ (#6966)

14 months agoci : add building in MSYS2 environments (Windows) (#6967)
Przemysław Pawełczyk [Mon, 29 Apr 2024 12:59:47 +0000 (14:59 +0200)]
ci : add building in MSYS2 environments (Windows) (#6967)

14 months agollama : fix typo LAMMAFILE -> LLAMAFILE (#6974)
Johannes Gäßler [Mon, 29 Apr 2024 12:36:22 +0000 (14:36 +0200)]
llama : fix typo LAMMAFILE -> LLAMAFILE (#6974)

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

* Fix more int overflow during quant.

* Fix some more int overflow in softmax.

* Revert back to int64_t.

14 months agogguf : enforce that tensor names are unique (#6905)
Xuan Son Nguyen [Sun, 28 Apr 2024 15:36:18 +0000 (17:36 +0200)]
gguf : enforce that tensor names are unique (#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>
14 months agoadd device version in device list (#6959)
Neo Zhang [Sun, 28 Apr 2024 14:40:31 +0000 (22:40 +0800)]
add device version in device list (#6959)

Co-authored-by: arthw <>
14 months agoflake.lock: Update
github-actions[bot] [Sun, 28 Apr 2024 00:18:27 +0000 (00:18 +0000)]
flake.lock: Update

Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/5c24cf2f0a12ad855f444c30b2421d044120c66f?narHash=sha256-XtTSSIB2DA6tOv%2Bl0FhvfDMiyCmhoRbNB%2B0SeInZkbk%3D' (2024-04-19)
  → 'github:NixOS/nixpkgs/7bb2ccd8cdc44c91edba16c48d2c8f331fb3d856?narHash=sha256-Drmja/f5MRHZCskS6mvzFqxEaZMeciScCTFxWVLqWEY%3D' (2024-04-25)

14 months agoReplace "alternative" boolean operator in conditional compilation directive (#6949)
mgroeber9110 [Sat, 27 Apr 2024 19:02:06 +0000 (21:02 +0200)]
Replace "alternative" boolean operator in conditional compilation directive (#6949)

14 months agoci: server: tests python env on github container ubuntu latest / fix n_predict (...
Pierrick Hymbert [Sat, 27 Apr 2024 15:50:48 +0000 (17:50 +0200)]
ci: server: tests python env on github container ubuntu latest / fix n_predict (#6935)

* ci: server: fix python env

* ci: server: fix server tests after #6638

* ci: server: fix windows is not building PR branch

14 months agoReset schedule earlier to allow overlap with ggml graph computation on device (#6933)
agray3 [Fri, 26 Apr 2024 18:08:30 +0000 (19:08 +0100)]
Reset schedule earlier to allow overlap with ggml graph computation on device (#6933)

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

14 months agoquantize: add imatrix and dataset metadata in GGUF (#6658)
Pierrick Hymbert [Fri, 26 Apr 2024 18:06:33 +0000 (20:06 +0200)]
quantize: add imatrix and dataset metadata in GGUF (#6658)

* imatrix: save the dataset file used in the output file

* llama: support kv overrides type string string

* common: factorize KV Overrides parsing between common and server

* quantize: add imatrix n entries and dataset KV metadata
quantize: factorize KV Overrides parsing between common
#6656

* llama: remove kv override str_value initialization as it does not compile on some toolchain

* quantize: add imatrix m_last_call as `quantize.imatrix.chunks_count`

* quantize: add imatrix filename in KV

* llama: add llama_model_kv_override_free

* common: add llama_model_kv_override_free
common: free kv override if used after model loading

* llama: finally move the string KV override value to the stack

* llama : minor

* no need to add a NUL to the std::vector, std::string can be initialized from a pair of iterators.

Co-authored-by: slaren <redacted>
* kv override: ensure string termination

---------

Co-authored-by: Georgi Gerganov <redacted>
Co-authored-by: slaren <redacted>
14 months agoadd basic tensor data validation function (#6884)
slaren [Fri, 26 Apr 2024 16:39:58 +0000 (18:39 +0200)]
add basic tensor data validation function (#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.

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

14 months agollamafile : use 64-bit integers in sgemm (#6928)
Justine Tunney [Fri, 26 Apr 2024 14:05:33 +0000 (10:05 -0400)]
llamafile : use 64-bit integers in sgemm (#6928)

14 months agoci: server: fix python installation (#6925)
Pierrick Hymbert [Fri, 26 Apr 2024 10:27:25 +0000 (12:27 +0200)]
ci: server: fix python installation (#6925)

14 months agoserver: stop generation at `n_ctx_train` if `n_predict` is not set (#6638)
Pierrick Hymbert [Fri, 26 Apr 2024 10:15:30 +0000 (12:15 +0200)]
server: stop generation at `n_ctx_train` if `n_predict` is not set (#6638)

* server: cap n_predict if not set to n_ctx_train

* server: fix infinite loop

* server: infinite loop, move in process_token
server: infinite loop: set stop limit to true

* minor: spaces

* minor: spaces

* server: include prompt tokens in the EOS limit

14 months agoci: server: fix python installation (#6922)
Pierrick Hymbert [Fri, 26 Apr 2024 09:11:51 +0000 (11:11 +0200)]
ci: server: fix python installation (#6922)

14 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>
14 months agoci: server: fix python installation (#6918)
Pierrick Hymbert [Fri, 26 Apr 2024 07:27:49 +0000 (09:27 +0200)]
ci: server: fix python installation (#6918)

14 months agoci: fix concurrency for pull_request_target (#6917)
Pierrick Hymbert [Fri, 26 Apr 2024 07:26:59 +0000 (09:26 +0200)]
ci: fix concurrency for pull_request_target (#6917)

14 months agobench: server add stop word for PHI-2 (#6916)
Pierrick Hymbert [Fri, 26 Apr 2024 07:26:16 +0000 (09:26 +0200)]
bench: server add stop word for PHI-2 (#6916)

14 months agollava : add support for moondream vision language model (#6899)
vik [Thu, 25 Apr 2024 19:38:31 +0000 (12:38 -0700)]
llava : add support for moondream vision language model (#6899)

* add support for moondream vision language model

This required making the following changes to the CLIP model:

1. Support for patch embedding bias.
2. Make class embedding and pre-layernorm optional.
3. Add support for post-layernorm.

* Update examples/llava/clip.cpp

---------

Co-authored-by: Georgi Gerganov <redacted>
14 months agocmake : restore LLAMA_LLAMAFILE_DEFAULT
Georgi Gerganov [Thu, 25 Apr 2024 18:31:17 +0000 (21:31 +0300)]
cmake : restore LLAMA_LLAMAFILE_DEFAULT

14 months agocmake : remove obsolete ANDROID check
Georgi Gerganov [Thu, 25 Apr 2024 15:59:51 +0000 (18:59 +0300)]
cmake : remove obsolete ANDROID check

14 months agollama : synchronize before get/set session data (#6911)
slaren [Thu, 25 Apr 2024 15:59:03 +0000 (17:59 +0200)]
llama : synchronize before get/set session data (#6911)

14 months agoci : tmp disable slow tests
Georgi Gerganov [Thu, 25 Apr 2024 14:06:27 +0000 (17:06 +0300)]
ci : tmp disable slow tests

14 months agoreadme : update model list (#6908)
BarfingLemurs [Thu, 25 Apr 2024 13:52:28 +0000 (09:52 -0400)]
readme : update model list (#6908)

* Update README.md

* missing space

* llama3 !

14 months agollama : check that all the tensor data is in the model file (#6885)
slaren [Thu, 25 Apr 2024 13:23:47 +0000 (15:23 +0200)]
llama : check that all the tensor data is in the model file (#6885)

* llama : check that all the tensor data is in the model file

* also check for unsigned overflow

14 months agoggml : fix redefinition of vaddvq_f32 for 32-bit ARM (#6906)
Georgi Gerganov [Thu, 25 Apr 2024 12:48:25 +0000 (15:48 +0300)]
ggml : fix redefinition of vaddvq_f32 for 32-bit ARM (#6906)

14 months agoclip : rename lerp function to avoid conflict (#6894)
Daniel Bevenius [Thu, 25 Apr 2024 12:38:14 +0000 (14:38 +0200)]
clip : rename lerp function to avoid conflict (#6894)

This commit renamesthe lerp (linear interpolation) function in clip.cpp
to avoid a conflict with the lerp function in the <cmath> standard C++
library when using c++20.

The motivation for this change is to enable projects that use c++20 to
be able to compile clip.cpp without having to resort to patching it. The
lerp function was added to cmath in version C++20 (202002L) and is why
this is not causing any issue at the moment as C++11/C++17 is currently
used by llama.cpp.

I realize that llama.cpp uses either C++11 (or C++17 in the case for
SYCL) but wanted to ask if this would be an acceptable change just the
same.

Refs: https://en.cppreference.com/w/cpp/numeric/lerp

Signed-off-by: Daniel Bevenius <redacted>
14 months agoggml : fix MIN / MAX macros (#6904)
Georgi Gerganov [Thu, 25 Apr 2024 12:12:28 +0000 (15:12 +0300)]
ggml : fix MIN / MAX macros (#6904)

ggml-ci

14 months agotests : minor bash stuff (#6902)
Georgi Gerganov [Thu, 25 Apr 2024 11:27:20 +0000 (14:27 +0300)]
tests : minor bash stuff (#6902)

* tests : minor bash stuff

ggml-ci

* llama : fix build

ggml-ci

* tests : fix CUR_DIR -> ROOT_DIR

ggml-ci

* tests : fix fname

ggml-ci

14 months agoquantize : add '--keep-split' to quantize model into shards (#6688)
jiez [Thu, 25 Apr 2024 10:29:35 +0000 (18:29 +0800)]
quantize : add '--keep-split' to quantize model into shards (#6688)

* Implement '--keep-split' to quantize model into several shards

* Add test script

* Update examples/quantize/quantize.cpp

Co-authored-by: Georgi Gerganov <redacted>
* Split model correctly even if tensor id is out-of-order

* Update llama_model_quantize_params

* Fix preci failures

---------

Co-authored-by: z5269887 <redacted>
Co-authored-by: Georgi Gerganov <redacted>
14 months agoREADME: add graphic for matrix multiplication (#6881)
Johannes Gäßler [Wed, 24 Apr 2024 19:29:13 +0000 (21:29 +0200)]
README: add graphic for matrix multiplication (#6881)

14 months agollama : add llama_get_pooling_type function (#6862)
Douglas Hanley [Wed, 24 Apr 2024 13:10:07 +0000 (08:10 -0500)]
llama : add llama_get_pooling_type function (#6862)

* add llama_get_pooling_type function

* fix argument name, move with ctx funcs

14 months agoserver : do not apply Markdown formatting in code sections (#6850)
mgroeber9110 [Wed, 24 Apr 2024 10:54:24 +0000 (12:54 +0200)]
server : do not apply Markdown formatting in code sections (#6850)

14 months agocommon : revert showing control tokens by default for server (#6860)
Kyle Mistele [Wed, 24 Apr 2024 10:15:29 +0000 (05:15 -0500)]
common : revert showing control tokens by default for server (#6860)

* fix: revert showing control tokens by default

* feat: revert changes to default behavior of llama_token_to_piece; provide overridden declaration to receive "bool special" param to toggle showing control tokens

* feat: use the overridden declaration of llama_token_to_piece from common/common.cpp to specify "false" so that control tokens are not shown in chat completion responses"

* common : simplify

---------

Co-authored-by: Georgi Gerganov <redacted>
14 months agoServer: fix seed for multiple slots (#6835)
Johannes Gäßler [Wed, 24 Apr 2024 09:08:36 +0000 (11:08 +0200)]
Server: fix seed for multiple slots (#6835)

* Server: add tests for consistent results

* sampling: separate rng per sampling context

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

ggml-ci

14 months agollama : add phi 3 chat template (#6857)
Tristan Druyen [Wed, 24 Apr 2024 08:52:37 +0000 (10:52 +0200)]
llama : add phi 3 chat template (#6857)

* Add phi 3 chat template & tests

* test : fix chat template result

---------

Co-authored-by: Georgi Gerganov <redacted>
14 months agoconvert : add support of codeqwen due to tokenizer (#6707)
Junyang Lin [Wed, 24 Apr 2024 07:16:21 +0000 (15:16 +0800)]
convert : add support of codeqwen due to tokenizer (#6707)

* add support of codeqwen due to tokenizer

* override load_hparams

* fix typo

* fix load_params

* convert : fix whitespace

---------

Co-authored-by: Georgi Gerganov <redacted>
14 months agollama : add phi3 support (#6852)
liuwei-git [Wed, 24 Apr 2024 07:00:37 +0000 (15:00 +0800)]
llama : add phi3 support (#6852)

* add explicit phi3 support

* add explicit phi3 support

* remove unused code

* convert : add BOS token

* llama : match EOT token <|end|>

* llama : minor / style

* llama : tabs -> spaces

* convert : fix lint checks

---------

Co-authored-by: Georgi Gerganov <redacted>
14 months ago[SYCL] Windows default build instructions without -DLLAMA_SYCL_F16 flag activated...
Anas Ahouzi [Tue, 23 Apr 2024 00:53:18 +0000 (02:53 +0200)]
[SYCL] Windows default build instructions without -DLLAMA_SYCL_F16 flag activated (#6767)

* Fix FP32/FP16 build instructions

* Fix typo

* Recommended build instruction

Co-authored-by: Neo Zhang Jianyu <redacted>
* Recommended build instruction

Co-authored-by: Neo Zhang Jianyu <redacted>
* Recommended build instruction

Co-authored-by: Neo Zhang Jianyu <redacted>
* Add comments in Intel GPU linux

---------

Co-authored-by: Anas Ahouzi <redacted>
Co-authored-by: Neo Zhang Jianyu <redacted>
14 months agollamafile : improve sgemm.cpp (#6796)
Justine Tunney [Mon, 22 Apr 2024 19:00:36 +0000 (15:00 -0400)]
llamafile : improve sgemm.cpp (#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

14 months agoggml : fix calloc argument ordering. (#6820)
Dave Airlie [Mon, 22 Apr 2024 14:05:06 +0000 (00:05 +1000)]
ggml : fix calloc argument ordering. (#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.

14 months agollama : fix typo in <|im_end|> token text (#6745)
Georgi Gerganov [Mon, 22 Apr 2024 12:41:11 +0000 (15:41 +0300)]
llama : fix typo in <|im_end|> token text (#6745)

14 months agoci: fix job are cancelling each other (#6781)
Pierrick Hymbert [Mon, 22 Apr 2024 11:22:54 +0000 (13:22 +0200)]
ci: fix job are cancelling each other (#6781)

14 months agoflake.lock: Update
github-actions[bot] [Sun, 21 Apr 2024 00:17:47 +0000 (00:17 +0000)]
flake.lock: Update

Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/1042fd8b148a9105f3c0aca3a6177fd1d9360ba5?narHash=sha256-3sbWO1mbpWsLepZGbWaMovSO7ndZeFqDSdX0hZ9nVyw%3D' (2024-04-10)
  → 'github:NixOS/nixpkgs/5c24cf2f0a12ad855f444c30b2421d044120c66f?narHash=sha256-XtTSSIB2DA6tOv%2Bl0FhvfDMiyCmhoRbNB%2B0SeInZkbk%3D' (2024-04-19)

14 months ago`build`: generate hex dump of server assets during build (#6661)
Olivier Chafik [Sun, 21 Apr 2024 17:48:53 +0000 (18:48 +0100)]
`build`: generate hex dump of server assets during build (#6661)

* `build`: generate hex dumps of server assets on the fly

* build: workaround lack of -n on gnu xxd

* build: don't use xxd in cmake

* build: don't call xxd from build.zig

* build: more idiomatic hexing

* build: don't use xxd in Makefile (od hackery instead)

* build: avoid exceeding max cmd line limit in makefile hex dump

* build: hex dump assets at cmake build time (not config time)

14 months agollama : add option to render special/control tokens (#6807)
Georgi Gerganov [Sun, 21 Apr 2024 15:36:45 +0000 (18:36 +0300)]
llama : add option to render special/control tokens (#6807)

* make : fix common dep on llama.h

* llama : add option to render special tokens

* readme : add API change notice

ggml-ci

* swift : fix build

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

14 months agollama : add llama-3 chat template (#6751)
Wouter [Sun, 21 Apr 2024 13:03:39 +0000 (15:03 +0200)]
llama : add llama-3 chat template (#6751)

* Added llama-3 chat template

* Update llama.cpp

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

Co-authored-by: Samuel Tallet <redacted>
* Update tests/test-chat-template.cpp

Co-authored-by: Samuel Tallet <redacted>
* Added EOS stop sequence according to https://github.com/ggerganov/llama.cpp/pull/6751#issuecomment-2065602862

* Removed adding of BOS token before first message

* Removed bos token from expected output from llama-3

* Update tests/test-chat-template.cpp

Co-authored-by: Rene Leonhardt <redacted>
* Update tests/test-chat-template.cpp

Co-authored-by: Rene Leonhardt <redacted>
* Added <|end_of_text|> as another stop token

* Reverted last change of adding the end_of_text stop word for llama 3

---------

Co-authored-by: Wouter Tichelaar <redacted>
Co-authored-by: Samuel Tallet <redacted>
Co-authored-by: Rene Leonhardt <redacted>
Co-authored-by: Georgi Gerganov <redacted>
14 months agogguf-py : add IQ1_M to GGML_QUANT_SIZES (#6761)
pmysl [Sun, 21 Apr 2024 12:49:30 +0000 (14:49 +0200)]
gguf-py : add IQ1_M to GGML_QUANT_SIZES (#6761)

14 months agodoc : add link to falcon (#6789)
Jan Boon [Sun, 21 Apr 2024 12:35:40 +0000 (20:35 +0800)]
doc : add link to falcon (#6789)

14 months agoreadme : add Fedora instructions (#6783)
Mohammadreza Hendiani [Sun, 21 Apr 2024 12:32:05 +0000 (16:02 +0330)]
readme : add Fedora instructions (#6783)

* added fedora to list of distros that may need the package (the packages have the same name on Fedora)

* how to add clblast that is avalible in the fedora repos

14 months agollava : use logger in llava-cli (#6797)
Justine Tunney [Sun, 21 Apr 2024 12:19:04 +0000 (08:19 -0400)]
llava : use logger in llava-cli (#6797)

This change removes printf() logging so llava-cli is shell scriptable.

14 months agollama : support Llama 3 HF conversion (#6745)
Pedro Cuenca [Sun, 21 Apr 2024 11:50:41 +0000 (13:50 +0200)]
llama : support Llama 3 HF conversion (#6745)

* Support Llama 3 conversion

The tokenizer is BPE.

* style

* Accept suggestion

Co-authored-by: Sourab Mangrulkar <redacted>
* llama : add llama_token_is_eog()

ggml-ci

* llama : auto-detect more EOT tokens when missing in KV data

* convert : replacing EOS token is a hack

* llama : fix codegemma EOT token + add TODOs

* llama : fix model type string for 8B model

---------

Co-authored-by: Sourab Mangrulkar <redacted>
Co-authored-by: Georgi Gerganov <redacted>
14 months agodoc : server tests require llama to be built with curl enabled (#6788)
Jan Boon [Sat, 20 Apr 2024 16:29:50 +0000 (00:29 +0800)]
doc : server tests require llama to be built with curl enabled (#6788)

14 months agocommon : try to fix Android CI (#6780)
Georgi Gerganov [Sat, 20 Apr 2024 10:27:12 +0000 (13:27 +0300)]
common : try to fix Android CI (#6780)

* common : disable get_math_cpu_count() until Android CI gets fixed

* common : another try

14 months agoci: add ubuntu latest release and fix missing build number (mac & ubuntu) (#6748)
loonerin [Fri, 19 Apr 2024 17:03:35 +0000 (13:03 -0400)]
ci: add ubuntu latest release and fix missing build number (mac & ubuntu) (#6748)

14 months agoserver: static: upstream upgrade (#6765)
Pierrick Hymbert [Fri, 19 Apr 2024 11:19:01 +0000 (13:19 +0200)]
server: static: upstream upgrade (#6765)

14 months agoImplement the OLMo architecture (#6741)
nopperl [Fri, 19 Apr 2024 09:35:54 +0000 (09:35 +0000)]
Implement the OLMo architecture (#6741)

* implement olmo architecture

* remove unused variable

* remove unused moe branch

* remove check for weight

* remove superfluous moe, bias and rope tensors

* clarified comment

* fix clamp_kqv setting

* remove obsolete parameter name filter

14 months agotrain : add general name (#6752)
Austin [Fri, 19 Apr 2024 07:16:45 +0000 (03:16 -0400)]
train : add general name (#6752)

* llama : make general.name optional

* train: Add 'general.name' to model metadata

Signed-off-by: teleprint-me <redacted>
---------

Signed-off-by: teleprint-me <redacted>
Co-authored-by: Georgi Gerganov <redacted>
14 months agofix wrong parameter in cmd in readme-sycl.md (#6755)
Neo Zhang [Fri, 19 Apr 2024 01:16:31 +0000 (09:16 +0800)]
fix wrong parameter in cmd in readme-sycl.md (#6755)

Co-authored-by: jianyuzh <redacted>
14 months agoggml : group all experts in a single ggml_mul_mat_id (#6505)
slaren [Thu, 18 Apr 2024 13:18:48 +0000 (15:18 +0200)]
ggml : group all experts in a single ggml_mul_mat_id (#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>
14 months agoconvert : support models with multiple chat templates (#6588)
Sigbjørn Skjæret [Thu, 18 Apr 2024 11:49:01 +0000 (13:49 +0200)]
convert : support models with multiple chat templates (#6588)

* Support converting models with multiple chat templates

Adds the following metadata:
* tokenizer.chat_templates
* tokenizer.chat_template.<name1>
* tokenizer.chat_template.<name2>
* tokenizer.chat_template.<...>

Where `tokenizer.chat_templates` is an array of the template names (except `default`), `default` is added to the regular `tokenizer.chat_template`.

* replace filtered characters with underscore

* New script to add/modify/remove metadata

This scripts creates a copy of a GGUF file and allows you to add/modify/remove metadata in the process.

Most importantly this allows you to update chat templates, either as a string or directly from an updated tokenizer_config.json file.

* Add files via upload

add new script to project/readme

* flake--

14 months agoQwen2 : assume tied weights if lm_head/output weights is missing (#6738)
Ren Xuancheng [Thu, 18 Apr 2024 11:38:04 +0000 (19:38 +0800)]
Qwen2 : assume tied weights if lm_head/output weights is missing (#6738)

14 months agollama : fix compatibility with old 2 expert models (#6735)
slaren [Thu, 18 Apr 2024 07:04:47 +0000 (09:04 +0200)]
llama : fix compatibility with old 2 expert models (#6735)

14 months agollamafile : tmp disable + build sgemm.o when needed (#6716)
Georgi Gerganov [Wed, 17 Apr 2024 20:58:26 +0000 (23:58 +0300)]
llamafile : tmp disable + build sgemm.o when needed (#6716)

* build : sgemm.o only when needed

ggml-ci

* llamafile : tmp disable due to MoE bug

ggml-ci

14 months agoreadme : add UI (#6724)
Yaroslav [Wed, 17 Apr 2024 12:47:50 +0000 (14:47 +0200)]
readme : add UI (#6724)

* Update README.md

* Update README.md

---------

Co-authored-by: Georgi Gerganov <redacted>
14 months agoconvert : fix autoawq gemma (#6704)
Zheng.Deng [Tue, 16 Apr 2024 20:51:07 +0000 (04:51 +0800)]
convert : fix autoawq gemma (#6704)

* fix autoawq quantized gemma model convert error

using autoawq to quantize gemma model will include a lm_head.weight tensor in model-00001-of-00002.safetensors. it result in this situation that convert-hf-to-gguf.py can't map lm_head.weight. skip loading this tensor could prevent this error.

* change code to full string match and print necessary message

change code to full string match and print a short message to inform users that lm_head.weight has been skipped.

---------

Co-authored-by: Zheng.Deng <redacted>
14 months agollama : make general.name optional (#6709)
Georgi Gerganov [Tue, 16 Apr 2024 20:50:38 +0000 (23:50 +0300)]
llama : make general.name optional (#6709)

14 months agoggml : fix llamafile sgemm wdata offsets (#6710)
Georgi Gerganov [Tue, 16 Apr 2024 20:50:22 +0000 (23:50 +0300)]
ggml : fix llamafile sgemm wdata offsets (#6710)

ggml-ci

14 months agoggml : add llamafile sgemm (#6414)
Justine Tunney [Tue, 16 Apr 2024 18:55:30 +0000 (14:55 -0400)]
ggml : add llamafile sgemm (#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/

14 months agollama : add StableLM2 12B (#6635)
Ashish [Tue, 16 Apr 2024 15:48:35 +0000 (08:48 -0700)]
llama : add StableLM2 12B (#6635)

* StableLM2 12B support for huggingface -> GGUF

* StableLM12 tensormapping and constants

* StableLM-2-12b model support

* fix

* Added 12B support

* Removed autoformatting; resolved bug where model_arch was not selecting StableLM2

* Formatting

* Do QK norm stacking in model conversion step

* Converge StableLM and StableLM2 code to simplify graph construction

* Fix accidental removal

* Removed warnings

* Revert formatter

* Move QK norm stack to private function so it's easier to read

* refactor stablelm graph builder to support 1.6, 3b and 12b more efficiently

* Proper check for None type for new_name to avoid crash; formatting; revert change to base class `write_tensors()`

* Format

* Formatting

* format

Co-authored-by: compilade <redacted>
* Fix incorrect check for K norm

* space after commas; Keep indentation multiple of 4 spaces

* Flake8 format

* Removed unnecessary conditional branches

* Removed unused comment

* Fixed incorrect tensor passing

* Format

---------

Co-authored-by: compilade <redacted>
14 months agollama : add qwen2moe (#6074)
Shijie [Tue, 16 Apr 2024 15:40:48 +0000 (23:40 +0800)]
llama : add qwen2moe (#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>
14 months agogritlm : add --outdir option to hf.sh script (#6699)
Daniel Bevenius [Tue, 16 Apr 2024 06:34:06 +0000 (08:34 +0200)]
gritlm : add --outdir option to hf.sh script (#6699)

This commit updates the hf.sh script usage to include the --outdir option
and specifies the models directory as the output directory.

The motivation for this is to avoid cluttering the root directory with
model files.

Signed-off-by: Daniel Bevenius <redacted>
14 months agoperplexity : require positive --ctx-size arg (#6695)
Georgi Gerganov [Tue, 16 Apr 2024 06:28:33 +0000 (09:28 +0300)]
perplexity : require positive --ctx-size arg (#6695)