]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/log
pkg/ggml/sources/llama.cpp
13 months agoAdd an option to build without CUDA VMM (#7067)
William Tambellini [Mon, 6 May 2024 18:12:14 +0000 (11:12 -0700)]
Add an option to build without CUDA VMM (#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 agoflake.lock: Update (#7079)
Georgi Gerganov [Mon, 6 May 2024 15:36:06 +0000 (18:36 +0300)]
flake.lock: Update (#7079)

Flake lock file updates:

• Updated input 'flake-parts':
    'github:hercules-ci/flake-parts/9126214d0a59633752a136528f5f3b9aa8565b7d?narHash=sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm%2BGpZNw%3D' (2024-04-01)
  → 'github:hercules-ci/flake-parts/e5d10a24b66c3ea8f150e47dfdb0416ab7c3390e?narHash=sha256-yzcRNDoyVP7%2BSCNX0wmuDju1NUCt8Dz9%2BlyUXEI0dbI%3D' (2024-05-02)
• Updated input 'flake-parts/nixpkgs-lib':
    'github:NixOS/nixpkgs/d8fe5e6c92d0d190646fb9f1056741a229980089?dir=lib&narHash=sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk%3D' (2024-03-29)
  → 'https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz?narHash=sha256-QBx10%2Bk6JWz6u7VsohfSw8g8hjdBZEf8CFzXH1/1Z94%3D' (2024-05-02)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/7bb2ccd8cdc44c91edba16c48d2c8f331fb3d856?narHash=sha256-Drmja/f5MRHZCskS6mvzFqxEaZMeciScCTFxWVLqWEY%3D' (2024-04-25)
  → 'github:NixOS/nixpkgs/63c3a29ca82437c87573e4c6919b09a24ea61b0f?narHash=sha256-4cPymbty65RvF1DWQfc%2BBc8B233A1BWxJnNULJKQ1EY%3D' (2024-05-02)

Co-authored-by: github-actions[bot] <redacted>
13 months agominor : fix trailing whitespace
Georgi Gerganov [Mon, 6 May 2024 06:31:30 +0000 (09:31 +0300)]
minor : fix trailing whitespace

13 months agoAdding support for the --numa argument for llama-bench. (#7080)
kunnis [Sun, 5 May 2024 12:17:47 +0000 (07:17 -0500)]
Adding support for the --numa argument for llama-bench. (#7080)

13 months agoDisable benchmark on forked repo (#7034)
Sigbjørn Skjæret [Sun, 5 May 2024 11:38:55 +0000 (13:38 +0200)]
Disable benchmark on forked repo (#7034)

* Disable benchmark on forked repo

* only check owner on schedule event

* check owner on push also

* more readable as multi-line

* ternary won't work

* style++

* test++

* enable actions debug

* test--

* remove debug

* test++

* do debug where we can get logs

* test--

* this is driving me crazy

* correct github.event usage

* remove test condition

* correct github.event usage

* test++

* test--

* event_name is pull_request_target

* test++

* test--

* update ref checks

13 months agoreadme : add note that LLaMA 3 is not supported with convert.py (#7065)
Lyle Dean [Sun, 5 May 2024 05:21:46 +0000 (06:21 +0100)]
readme : add note that LLaMA 3 is not supported with convert.py (#7065)

13 months agocommand-r : add BPE pre-tokenization (#7063)
DAN™ [Sun, 5 May 2024 05:19:30 +0000 (01:19 -0400)]
command-r : add BPE pre-tokenization (#7063)

* Add BPE pre-tokenization for Command-R/R+.

* Bump transformers convert requirement.

* command-r : add individual digits regex

---------

Co-authored-by: Georgi Gerganov <redacted>
13 months agopy : logging and flake8 suppression refactoring (#7081)
Brian [Sun, 5 May 2024 05:07:48 +0000 (15:07 +1000)]
py : logging and flake8 suppression refactoring (#7081)

Set one as executable and add basicConfig()
to another. Also added noqa tag to test scripts.

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

13 months agoTidy Android Instructions README.md (#7016)
Jeximo [Sat, 4 May 2024 16:10:15 +0000 (13:10 -0300)]
Tidy Android Instructions README.md (#7016)

* Tidy Android Instructions README.md

Remove CLBlast instructions(outdated), added OpenBlas.

* don't assume git is installed

Added apt install git, so that git clone works

* removed OpenBlas

Linked to Linux build instructions

* fix typo

Remove word "run"

* correct style

Co-authored-by: slaren <redacted>
* correct grammar

Co-authored-by: slaren <redacted>
* delete reference to Android API

* remove Fdroid reference, link directly to Termux

Fdroid is not required

Co-authored-by: slaren <redacted>
* Update README.md

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

Co-authored-by: slaren <redacted>
13 months agoFix Linux /sys cpu path to guess number of cores (#7064)
viric [Sat, 4 May 2024 13:26:53 +0000 (15:26 +0200)]
Fix Linux /sys cpu path to guess number of cores (#7064)

13 months agoIf first token generated from the server is the stop word the server will crash ...
maor-ps [Sat, 4 May 2024 09:06:40 +0000 (12:06 +0300)]
If first token generated from the server is the stop word the server will crash (#7038)

This will reproduce the issue in llama13b
{
'prompt': 'Q: hello world \nA: ',
 'stop': ['\n'],
 'temperature': 0.0,
 'n_predict': 10,
 'cache_prompt': True,
 'n_probs': 10
}

13 months agotests : add test-tokenizer-0.sh + fix some tokenizers (#7036)
Georgi Gerganov [Sat, 4 May 2024 05:32:32 +0000 (08:32 +0300)]
tests : add test-tokenizer-0.sh + fix some tokenizers (#7036)

* tests : add test-tokenizer-0.sh

* unicode : add all unicode number ranges

* starcoder : fix pre-tokenizer

* tests : add test that fails with DeepSeek tokenizers

* falcon : fix regex

* unicode : regenerate unicode tables

* refact : add tokenizer model

* lint : fix

* tests : disable failing tests

ggml-ci

* refact : add tests files

ggml-ci

* convert : print -> logging

ggml-ci

* lint : fix

* unicode : digit -> number

* phi-3 : update

14 months agoconvert.py : add python logging instead of print() (#6511)
Brian [Fri, 3 May 2024 19:36:41 +0000 (05:36 +1000)]
convert.py : add python logging instead of print() (#6511)

* convert.py: add python logging instead of print()

* convert.py: verbose flag takes priority over dump flag log suppression

* convert.py: named instance logging

* convert.py: use explicit logger id string

* convert.py: convert extra print() to named logger

* convert.py: sys.stderr.write --> logger.error

* *.py: Convert all python scripts to use logging module

* requirements.txt: remove extra line

* flake8: update flake8 ignore and exclude to match ci settings

* gh-actions: add flake8-no-print to flake8 lint step

* pre-commit: add flake8-no-print to flake8 and also update pre-commit version

* convert-hf-to-gguf.py: print() to logger conversion

* *.py: logging basiconfig refactor to use conditional expression

* *.py: removed commented out logging

* fixup! *.py: logging basiconfig refactor to use conditional expression

* constant.py: logger.error then exit should be a raise exception instead

* *.py: Convert logger error and sys.exit() into a raise exception (for atypical error)

* gguf-convert-endian.py: refactor convert_byteorder() to use tqdm progressbar

* verify-checksum-model.py: This is the result of the program, it should be printed to stdout.

* compare-llama-bench.py: add blank line for readability during missing repo response

* reader.py: read_gguf_file() use print() over logging

* convert.py: warning goes to stderr and won't hurt the dump output

* gguf-dump.py: dump_metadata() should print to stdout

* convert-hf-to-gguf.py: print --> logger.debug or ValueError()

* verify-checksum-models.py: use print() for printing table

* *.py: refactor logging.basicConfig()

* gguf-py/gguf/*.py: use __name__ as logger name

Since they will be imported and not run directly.

* python-lint.yml: use .flake8 file instead

* constants.py: logger no longer required

* convert-hf-to-gguf.py: add additional logging

* convert-hf-to-gguf.py: print() --> logger

* *.py: fix flake8 warnings

* revert changes to convert-hf-to-gguf.py for get_name()

* convert-hf-to-gguf-update.py: use triple quoted f-string instead

* *.py: accidentally corrected the wrong line

* *.py: add compilade warning suggestions and style fixes

14 months agollama : rename ctx to user_data in progress_callback (#7045)
Daniel Bevenius [Fri, 3 May 2024 13:24:30 +0000 (15:24 +0200)]
llama : rename ctx to user_data in progress_callback (#7045)

* llama : rename ctx to user_data in progress_callback

This commit renames the `ctx` parameter to `user_data` in the
`llama_progress_callback` typedef.

The motivation for this is that other callbacks use `user_data` or
`data`, and using `ctx` in this case might be confusing as it could be
confused with `llama_context`.

---------

Signed-off-by: Daniel Bevenius <redacted>
14 months agoRemove .attention from skipped tensors to match more accurately (#7051)
Bartowski [Thu, 2 May 2024 23:49:09 +0000 (19:49 -0400)]
Remove .attention from skipped tensors to match more accurately (#7051)

14 months agochore: fix typo in llama.cpp (#7032)
alwqx [Thu, 2 May 2024 15:56:41 +0000 (23:56 +0800)]
chore: fix typo in llama.cpp (#7032)

Co-authored-by: Jared Van Bortel <redacted>
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)