]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/log
pkg/ggml/sources/llama.cpp
23 months agoggml : remove src0 and src1 from ggml_tensor and rename opt to src (#2178)
Spencer Sutton [Tue, 11 Jul 2023 16:31:10 +0000 (12:31 -0400)]
ggml : remove src0 and src1 from ggml_tensor and rename opt to src (#2178)

* Add ggml changes

* Update train-text-from-scratch for change

* mpi : adapt to new ggml_tensor->src

---------

Co-authored-by: Georgi Gerganov <redacted>
23 months agollama : add classifier-free guidance (#2135)
Bach Le [Tue, 11 Jul 2023 16:18:43 +0000 (00:18 +0800)]
llama : add classifier-free guidance (#2135)

* Initial implementation

* Remove debug print

* Restore signature of llama_init_from_gpt_params

* Free guidance context

* Make freeing of guidance_ctx conditional

* Make Classifier-Free Guidance a sampling function

* Correct typo. CFG already means context-free grammar.

* Record sampling time in llama_sample_classifier_free_guidance

* Shift all values by the max value before applying logsoftmax

* Fix styling based on review

23 months agodocker : add '--server' option (#2174)
Jinwoo Jeong [Tue, 11 Jul 2023 16:12:35 +0000 (01:12 +0900)]
docker : add '--server' option (#2174)

23 months agoreadme : fix zig build instructions (#2171)
Chad Brewbaker [Tue, 11 Jul 2023 16:03:06 +0000 (11:03 -0500)]
readme : fix zig build instructions (#2171)

23 months agoSupport using mmap when applying LoRA (#2095)
Howard Su [Tue, 11 Jul 2023 14:37:01 +0000 (22:37 +0800)]
Support using mmap when applying LoRA (#2095)

* Support using mmap when applying LoRA

* Fix Linux

* Update comment to reflect the support lora with mmap

23 months agoPossible solution to allow K-quants on models with n_vocab!=32000 (#2148)
LostRuins [Tue, 11 Jul 2023 14:01:08 +0000 (22:01 +0800)]
Possible solution to allow K-quants on models with n_vocab!=32000 (#2148)

* This allows LLAMA models that were previously incompatible with K quants to function mostly as normal. This happens when a model has a vocab != 32000, e.g 32001 which means it's not divisible by 256 or 64. Since the problematic dimensions only apply for `tok_embeddings.weight` and `output.weight` (dimentions 4096 x n_vocab), we can simply quantize these layers to Q8_0 whereas the majority of the hidden layers are still K-quanted since they have compatible dimensions.

* Fix indentation

Co-authored-by: Georgi Gerganov <redacted>
* As an alternative, to avoid failing on Metal due to lack of Q8_0 support, instead quantize tok_embeddings.weight to Q4_0 and retain output.weight as F16. This results in a net gain of about 55mb for a 7B model compared to previous approach, but should minimize adverse impact to model quality.

---------

Co-authored-by: Georgi Gerganov <redacted>
23 months agompi : add support for distributed inference via MPI (#2099)
Evan Miller [Mon, 10 Jul 2023 15:49:56 +0000 (11:49 -0400)]
mpi : add support for distributed inference via MPI (#2099)

* MPI support, first cut

* fix warnings, update README

* fixes

* wrap includes

* PR comments

* Update CMakeLists.txt

* Add GH workflow, fix test

* Add info to README

* mpi : trying to move more MPI stuff into ggml-mpi (WIP) (#2099)

* mpi : add names for layer inputs + prep ggml_mpi_graph_compute()

* mpi : move all MPI logic into ggml-mpi

Not tested yet

* mpi : various fixes - communication now works but results are wrong

* mpi : fix output tensor after MPI compute (still not working)

* mpi : fix inference

* mpi : minor

* Add OpenMPI to GH action

* [mpi] continue-on-error: true

* mpi : fix after master merge

* [mpi] Link MPI C++ libraries to fix OpenMPI

* tests : fix new llama_backend API

* [mpi] use MPI_INT32_T

* mpi : factor out recv / send in functions and reuse

* mpi : extend API to allow usage with outer backends (e.g. Metal)

---------

Co-authored-by: Georgi Gerganov <redacted>
23 months agollama : remove "first token must be BOS" restriction (#2153)
oobabooga [Sun, 9 Jul 2023 08:59:53 +0000 (05:59 -0300)]
llama : remove "first token must be BOS" restriction (#2153)

23 months agomain : escape prompt prefix/suffix (#2151)
Nigel Bosch [Sun, 9 Jul 2023 08:56:18 +0000 (03:56 -0500)]
main : escape prompt prefix/suffix (#2151)

23 months agoreadme : update Termux instructions (#2147)
JackJollimore [Sun, 9 Jul 2023 08:20:43 +0000 (05:20 -0300)]
readme : update Termux instructions (#2147)

The file pathing is significant when running models inside of Termux on Android devices. llama.cpp performance is improved with loading a .bin from the $HOME directory.

23 months agoggml : fix buidling with Intel MKL but ask for "cblas.h" issue (#2104) (#2115)
clyang [Sun, 9 Jul 2023 08:12:20 +0000 (16:12 +0800)]
ggml : fix buidling with Intel MKL but ask for "cblas.h" issue (#2104) (#2115)

* Fix buidling with Intel MKL but ask for "cblas.h" issue

* Use angle brackets to indicate the system library

23 months agoreadme : add more docs indexes (#2127)
rankaiyx [Sun, 9 Jul 2023 07:38:42 +0000 (15:38 +0800)]
readme : add more docs indexes (#2127)

* Update README.md to add more docs indexes

* Update README.md to add more docs indexes

23 months agoFixed OpenLLaMA 3b CUDA mul_mat_vec_q (#2144)
Johannes Gäßler [Sat, 8 Jul 2023 18:01:44 +0000 (20:01 +0200)]
Fixed OpenLLaMA 3b CUDA mul_mat_vec_q (#2144)

23 months agoCUDA: add __restrict__ to mul mat vec kernels (#2140)
Johannes Gäßler [Fri, 7 Jul 2023 22:25:15 +0000 (00:25 +0200)]
CUDA: add __restrict__ to mul mat vec kernels (#2140)

23 months agodocker : add support for CUDA in docker (#1461)
dylan [Fri, 7 Jul 2023 18:25:25 +0000 (11:25 -0700)]
docker : add support for CUDA in docker (#1461)

Co-authored-by: canardleteer <redacted>
Co-authored-by: Georgi Gerganov <redacted>
23 months agoci : switch threads to 1 (#2138)
Georgi Gerganov [Fri, 7 Jul 2023 18:23:57 +0000 (21:23 +0300)]
ci : switch threads to 1 (#2138)

23 months agoggml : change ggml_graph_compute() API to not require context (#1999)
Qingyou Meng [Fri, 7 Jul 2023 16:24:01 +0000 (00:24 +0800)]
ggml : change ggml_graph_compute() API to not require context (#1999)

* ggml_graph_compute: deprecate using ggml_context, try resolve issue #287

* rewrite: no longer consider backward compitability; plan and make_plan

* minor: rename ctx as plan; const

* remove ggml_graph_compute from tests/test-grad0.c, but current change breaks backward

* add static ggml_graph_compute_sugar()

* minor: update comments

* reusable buffers

* ggml : more consistent naming + metal fixes

* ggml : fix docs

* tests : disable grad / opt + minor naming changes

* ggml : add ggml_graph_compute_with_ctx()

- backwards compatible API
- deduplicates a lot of copy-paste

* ci : enable test-grad0

* examples : factor out plan allocation into a helper function

* llama : factor out plan stuff into a helper function

* ci : fix env

* llama : fix duplicate symbols + refactor example benchmark

* ggml : remove obsolete assert + refactor n_tasks section

* ggml : fix indentation in switch

* llama : avoid unnecessary bool

* ggml : remove comments from source file and match order in header

---------

Co-authored-by: Georgi Gerganov <redacted>
23 months agoggml : remove sched_yield() call in ggml_graph_compute_thread() (#2134)
Georgi Gerganov [Fri, 7 Jul 2023 15:36:37 +0000 (18:36 +0300)]
ggml : remove sched_yield() call in ggml_graph_compute_thread() (#2134)

23 months agoconvert.py: add mapping for safetensors bf16 (#1598)
Aarni Koskela [Fri, 7 Jul 2023 13:12:49 +0000 (16:12 +0300)]
convert.py: add mapping for safetensors bf16 (#1598)

Fixes #1473

23 months agoFix opencl by wrap #if-else-endif with \n (#2086)
Howard Su [Fri, 7 Jul 2023 03:34:18 +0000 (11:34 +0800)]
Fix opencl by wrap #if-else-endif with \n (#2086)

23 months agoggml : fix restrict usage
Georgi Gerganov [Thu, 6 Jul 2023 16:41:31 +0000 (19:41 +0300)]
ggml : fix restrict usage

23 months agoconvert : update for baichuan (#2081)
Judd [Thu, 6 Jul 2023 16:23:49 +0000 (00:23 +0800)]
convert : update for baichuan (#2081)

1. guess n_layers;
2. relax warnings on context size;
3. add a note that its derivations are also supported.

Co-authored-by: Judd <redacted>
23 months agoalpaca.sh : update model file name (#2074)
tslmy [Thu, 6 Jul 2023 16:17:50 +0000 (09:17 -0700)]
alpaca.sh : update model file name (#2074)

The original file name, `ggml-alpaca-7b-q4.bin`, implied the first-generation GGML. After the breaking changes (mentioned in https://github.com/ggerganov/llama.cpp/issues/382), `llama.cpp` requires GGML V3 now. Those model files are named `*ggmlv3*.bin`. We should change the example to an actually working model file, so that this thing is more likely to run out-of-the-box for more people, and less people would waste time downloading the old Alpaca model.

23 months agoExpose generation timings from server & update completions.js (#2116)
Tobias Lütke [Wed, 5 Jul 2023 20:51:13 +0000 (16:51 -0400)]
Expose generation timings from server & update completions.js (#2116)

* use javascript generators as much cleaner API

Also add ways to access completion as promise and EventSource

* export llama_timings as struct and expose them in server

* update readme, update baked includes

* llama : uniform variable names + struct init

---------

Co-authored-by: Georgi Gerganov <redacted>
23 months agoUpdate Server Instructions (#2113)
Jesse Jojo Johnson [Wed, 5 Jul 2023 18:03:19 +0000 (18:03 +0000)]
Update Server Instructions (#2113)

* Update server instructions for web front end
* Update server README
* Remove duplicate OAI instructions
* Fix duplicate text

---------

Co-authored-by: Jesse Johnson <redacted>
23 months agoggml : fix bug introduced in #1237
Georgi Gerganov [Wed, 5 Jul 2023 17:44:11 +0000 (20:44 +0300)]
ggml : fix bug introduced in #1237

23 months agotests : fix test-grad0
Georgi Gerganov [Wed, 5 Jul 2023 17:20:05 +0000 (20:20 +0300)]
tests : fix test-grad0

23 months agoggml : generalize `quantize_fns` for simpler FP16 handling (#1237)
Stephan Walter [Wed, 5 Jul 2023 16:13:06 +0000 (16:13 +0000)]
ggml : generalize `quantize_fns` for simpler FP16 handling (#1237)

* Generalize quantize_fns for simpler FP16 handling

* Remove call to ggml_cuda_mul_mat_get_wsize

* ci : disable FMA for mac os actions

---------

Co-authored-by: Georgi Gerganov <redacted>
23 months agoUpdate server instructions for web front end (#2103)
Jesse Jojo Johnson [Wed, 5 Jul 2023 15:13:35 +0000 (15:13 +0000)]
Update server instructions for web front end (#2103)

Co-authored-by: Jesse Johnson <redacted>
23 months agoQuantized dot products for CUDA mul mat vec (#2067)
Johannes Gäßler [Wed, 5 Jul 2023 12:19:42 +0000 (14:19 +0200)]
Quantized dot products for CUDA mul mat vec (#2067)

23 months agollama: Don't double count the sampling time (#2107)
Howard Su [Wed, 5 Jul 2023 10:31:23 +0000 (18:31 +0800)]
llama: Don't double count the sampling time (#2107)

23 months agoFixed OpenCL offloading prints (#2082)
Johannes Gäßler [Wed, 5 Jul 2023 06:58:05 +0000 (08:58 +0200)]
Fixed OpenCL offloading prints (#2082)

23 months agoembd-input: Fix input embedding example unsigned int seed (#2105)
Nigel Bosch [Tue, 4 Jul 2023 23:33:33 +0000 (18:33 -0500)]
embd-input: Fix input embedding example unsigned int seed (#2105)

23 months agoreadme : add link web chat PR
Georgi Gerganov [Tue, 4 Jul 2023 19:25:22 +0000 (22:25 +0300)]
readme : add link web chat PR

23 months agoggml : sync latest (new ops, macros, refactoring) (#2106)
Georgi Gerganov [Tue, 4 Jul 2023 18:54:11 +0000 (21:54 +0300)]
ggml : sync latest (new ops, macros, refactoring) (#2106)

- add ggml_argmax()
- add ggml_tanh()
- add ggml_elu()
- refactor ggml_conv_1d() and variants
- refactor ggml_conv_2d() and variants
- add helper macros to reduce code duplication in ggml.c

23 months agoAdd an API example using server.cpp similar to OAI. (#2009)
jwj7140 [Tue, 4 Jul 2023 18:06:12 +0000 (03:06 +0900)]
Add an API example using server.cpp similar to OAI. (#2009)

* add api_like_OAI.py
* add evaluated token count to server
* add /v1/ endpoints binding

23 months agoSimple webchat for server (#1998)
Tobias Lütke [Tue, 4 Jul 2023 14:05:27 +0000 (10:05 -0400)]
Simple webchat for server (#1998)

* expose simple web interface on root domain

* embed index and add --path for choosing static dir

* allow server to multithread

because web browsers send a lot of garbage requests we want the server
to multithread when serving 404s for favicon's etc. To avoid blowing up
llama we just take a mutex when it's invoked.

* let's try this with the xxd tool instead and see if msvc is happier with that

* enable server in Makefiles

* add /completion.js file to make it easy to use the server from js

* slightly nicer css

* rework state management into session, expose historyTemplate to settings

---------

Co-authored-by: Georgi Gerganov <redacted>
23 months agoAllow old Make to build server. (#2098)
Henri Vasserman [Tue, 4 Jul 2023 12:38:04 +0000 (15:38 +0300)]
Allow old Make to build server. (#2098)

Also make server build by default.

Tested with Make 3.82

23 months agoUpdate Makefile: clean simple (#2097)
ZhouYuChen [Tue, 4 Jul 2023 12:15:16 +0000 (20:15 +0800)]
Update Makefile: clean simple (#2097)

23 months agoCI: make the brew update temporarily optional. (#2092)
Erik Scholz [Mon, 3 Jul 2023 23:50:12 +0000 (01:50 +0200)]
CI: make the brew update temporarily optional. (#2092)

until they decide to fix the brew installation in the macos runners.
see the open issues. eg https://github.com/actions/runner-images/pull/7710

23 months ago[ggml] fix index for ne03 value in ggml_cl_mul_f32 (#2088)
Govlzkoy [Mon, 3 Jul 2023 23:50:00 +0000 (07:50 +0800)]
[ggml] fix index for ne03 value in ggml_cl_mul_f32 (#2088)

23 months agofix server crashes (#2076)
Henri Vasserman [Mon, 3 Jul 2023 21:05:23 +0000 (00:05 +0300)]
fix server crashes (#2076)

23 months agoFix crash of test-tokenizer-0 under Debug build (#2064)
Howard Su [Mon, 3 Jul 2023 18:43:55 +0000 (02:43 +0800)]
Fix crash of test-tokenizer-0 under Debug build (#2064)

* Fix crash of test-tokenizer-0 under Debug build

* Change per comment

23 months ago[llama] No need to check file version when loading vocab score (#2079)
Howard Su [Mon, 3 Jul 2023 11:58:58 +0000 (19:58 +0800)]
[llama] No need to check file version when loading vocab score (#2079)

23 months agoserver: add option to output probabilities for completion (#1962)
WangHaoranRobin [Sun, 2 Jul 2023 21:38:44 +0000 (05:38 +0800)]
server: add option to output probabilities for completion (#1962)

* server: add option to output probabilities for completion
* server: fix issue when handling probability output for incomplete tokens for multibyte character generation
* server: fix llama_sample_top_k order
* examples/common.h: put all bool variables in gpt_params together

23 months agoggml : fix build with OpenBLAS (close #2066)
Georgi Gerganov [Sun, 2 Jul 2023 06:46:46 +0000 (09:46 +0300)]
ggml : fix build with OpenBLAS (close #2066)

23 months agoBetter CUDA synchronization logic (#2057)
Johannes Gäßler [Sat, 1 Jul 2023 19:49:44 +0000 (21:49 +0200)]
Better CUDA synchronization logic (#2057)

23 months agoTest-based VRAM scratch size + context adjustment (#2056)
Johannes Gäßler [Sat, 1 Jul 2023 19:47:26 +0000 (21:47 +0200)]
Test-based VRAM scratch size + context adjustment (#2056)

23 months agocmake : don't force -mcpu=native on aarch64 (#2063)
Daniel Drake [Sat, 1 Jul 2023 18:31:44 +0000 (20:31 +0200)]
cmake : don't force -mcpu=native on aarch64 (#2063)

It's currently not possible to cross-compile llama.cpp for aarch64
because CMakeLists.txt forces -mcpu=native for that target.

-mcpu=native doesn't make sense if your build host is not the
target architecture, and clang rejects it for that reason, aborting the
build. This can be easily reproduced using the current Android NDK to build
for aarch64 on an x86_64 host.

If there is not a specific CPU-tuning target for aarch64 then -mcpu
should be omitted completely. I think that makes sense, there is not
enough variance in the aarch64 instruction set to warrant a fixed -mcpu
optimization at this point. And if someone is building natively and wishes
to enable any possible optimizations for the host device, then there is
already the LLAMA_NATIVE option available.

Fixes #495.

23 months agometal : release buffers when freeing metal context (#2062)
Aaron Miller [Sat, 1 Jul 2023 18:14:59 +0000 (11:14 -0700)]
metal : release buffers when freeing metal context (#2062)

23 months agoconvert : add support of baichuan-7b (#2055)
Judd [Sat, 1 Jul 2023 17:00:25 +0000 (01:00 +0800)]
convert : add support of baichuan-7b (#2055)

Co-authored-by: Judd <redacted>
23 months agollama : fix return value of llama_load_session_file_internal (#2022)
Georgi Gerganov [Sat, 1 Jul 2023 16:05:09 +0000 (19:05 +0300)]
llama : fix return value of llama_load_session_file_internal (#2022)

23 months agollama : catch llama_load_session_file_internal exceptions (#2022)
Rand Xie [Sat, 1 Jul 2023 16:02:58 +0000 (00:02 +0800)]
llama : catch llama_load_session_file_internal exceptions (#2022)

* convert checks in llama_load_session_file to throw and handle them

* make llama_load_session_file_internal static

* address feedbacks to avoid using exceptions

23 months agoembd-input : fix returning ptr to temporary
Georgi Gerganov [Sat, 1 Jul 2023 15:46:00 +0000 (18:46 +0300)]
embd-input : fix returning ptr to temporary

23 months agotrain : fix compile warning
Georgi Gerganov [Sat, 1 Jul 2023 15:45:44 +0000 (18:45 +0300)]
train : fix compile warning

23 months agoggml : disable GGML_TASK_INIT and GGML_TASK_FINALIZE by default (#1995)
Qingyou Meng [Sat, 1 Jul 2023 15:42:43 +0000 (23:42 +0800)]
ggml : disable GGML_TASK_INIT and GGML_TASK_FINALIZE by default (#1995)

Will not be scheduled unless explicitly enabled.

2 years agoUse unsigned for random seed (#2006)
Howard Su [Thu, 29 Jun 2023 13:15:15 +0000 (21:15 +0800)]
Use unsigned for random seed (#2006)

* Use unsigned for random seed. Keep -1 as the value to use a time based seed.

Co-authored-by: Georgi Gerganov <redacted>
2 years agoPorting the improved K-Quant CUDA kernels to OpenCL (#1966)
LostRuins [Thu, 29 Jun 2023 03:56:43 +0000 (11:56 +0800)]
Porting the improved K-Quant CUDA kernels to OpenCL (#1966)

* Added broken new q4k quant

* xx + ib0

* Fix q2_k fast kernel

* Use preprocessor for QK_K

* Add q6_k fast matmul kernel

* ported q3k speedup successfully

* ported q2k and q5k speedups

* remove old dot kernels and template

* fixed global const struct types

* fixing address spaces

* fixed string too long CI issue

---------

Co-authored-by: 0cc4m <redacted>
2 years agollama : replacing auto &kv with const auto &kv (#2041)
m3ndax [Wed, 28 Jun 2023 18:39:08 +0000 (20:39 +0200)]
llama : replacing auto &kv with const auto &kv (#2041)

* Replacing auto &kv with const auto &kv

* Create codacy.yml

* Delete codacy.yml

2 years agocuda : remove nchannels_x argument from mul_mat_vec_nc_f16_f32 (#2028)
Salvador E. Tropea [Wed, 28 Jun 2023 17:27:31 +0000 (14:27 -0300)]
cuda : remove nchannels_x argument from mul_mat_vec_nc_f16_f32 (#2028)

- Not used

2 years agocuda : fix missing const qualifier in casts (#2027)
Salvador E. Tropea [Wed, 28 Jun 2023 17:26:26 +0000 (14:26 -0300)]
cuda : fix missing const qualifier in casts (#2027)

2 years agollama : remove shards weight file support (#2000)
Howard Su [Wed, 28 Jun 2023 17:13:02 +0000 (10:13 -0700)]
llama : remove shards weight file support (#2000)

* Remove multiple shards

* Remove multiple file loaders

* Remove llama_load_tensor_shard class

* Simplify load logic

* Remove dead code guess_n_parts function

* Remove vocab_only from constructor of llama_model_loader

* Remove alignment_prevents_mmap which is not more needed.

* Remove useless check

2 years agoCUDA GPU acceleration for LoRAs + f16 models (#1970)
Johannes Gäßler [Wed, 28 Jun 2023 16:35:54 +0000 (18:35 +0200)]
CUDA GPU acceleration for LoRAs + f16 models (#1970)

2 years agollama : support input embeddings directly (#1910)
ningshanwutuobang [Wed, 28 Jun 2023 15:53:37 +0000 (23:53 +0800)]
llama : support input embeddings directly  (#1910)

* add interface for float input

* fixed inpL shape and type

* add examples of input floats

* add test example for embd input

* fixed sampling

* add free for context

* fixed add end condition for generating

* add examples for llava.py

* add READMD for llava.py

* add READMD for llava.py

* add example of PandaGPT

* refactor the interface and fixed the styles

* add cmake build for embd-input

* add cmake build for embd-input

* Add MiniGPT-4 example

* change the order of the args of llama_eval_internal

* fix ci error

2 years agofix pthreads setaffinity usage on android (#2020)
Erik Scholz [Tue, 27 Jun 2023 17:06:33 +0000 (19:06 +0200)]
fix pthreads setaffinity usage on android (#2020)

2 years agobaby-llama : fix build after ggml_rope change (#2016)
Howard Su [Tue, 27 Jun 2023 05:07:13 +0000 (13:07 +0800)]
baby-llama : fix build after ggml_rope change (#2016)

2 years agollama : fix rope usage after ChatGLM change
Georgi Gerganov [Mon, 26 Jun 2023 21:37:13 +0000 (00:37 +0300)]
llama : fix rope usage after ChatGLM change

2 years agoggml : add support for ChatGLM RoPE
Georgi Gerganov [Mon, 26 Jun 2023 21:06:51 +0000 (00:06 +0300)]
ggml : add support for ChatGLM RoPE

2 years agoreadme : add Scala 3 bindings repo (#2010)
Roman Parykin [Mon, 26 Jun 2023 19:47:59 +0000 (22:47 +0300)]
readme : add Scala 3 bindings repo (#2010)

2 years agoggml : increase max tensor name + clean up compiler warnings in train-text (#1988)
David Yang [Mon, 26 Jun 2023 19:45:32 +0000 (03:45 +0800)]
ggml : increase max tensor name + clean up compiler warnings in train-text (#1988)

* Clean up compiler warnings in train-text

Some brackets to disambiguate order of operations

* Increase GGML_MAX_NAME

Avoiding strncpy danger in train-text-from-scratch and reducing potential future name length issues

2 years agoreadme : LD_LIBRARY_PATH complement for some Android devices when building with CLBla...
Gustavo Rocha Dias [Mon, 26 Jun 2023 19:34:45 +0000 (16:34 -0300)]
readme : LD_LIBRARY_PATH complement for some Android devices when building with CLBlast inside Termux (#2007)

* docs - Alternative way to build at Android, with CLBlast.

* doc - LD_LIBRARY_PATH complement for some Android devices when building with CLBlast inside Termux.

* doc- fix typo

2 years agoggml : avoid conv 2d kernel round up
Georgi Gerganov [Mon, 26 Jun 2023 18:03:59 +0000 (21:03 +0300)]
ggml : avoid conv 2d kernel round up

2 years agoggml : add NUMA support (#1556)
zrm [Mon, 26 Jun 2023 17:57:59 +0000 (13:57 -0400)]
ggml : add NUMA support (#1556)

* detect NUMA systems and pin work threads to nodes (linux)

* disable mmap prefetch/readahead for NUMA systems

* avoid sending finalize op to thread pool if it does nothing

* silence robot

* fix args

* make --numa a param

* recommendation that n_nodes evenly divide n_threads did not warrant such aggressive enforcement

* lower synchronization overhead

* statically allocate

* move numa state to g_state

* add description for --numa

* ggml : minor style changes

* ggml : minor style + try fix sanitizer build

* llama : allow to initialize backend with NUMA support

* llama : avoid ggml include in llama-util.h

* ggml : style / formatting

* ggml : fix handling of ops with n_threads > n_tasks > 1

* server : utilize numa parameter

---------

Co-authored-by: Georgi Gerganov <redacted>
2 years agok-quants : fix indentation
Georgi Gerganov [Mon, 26 Jun 2023 17:10:52 +0000 (20:10 +0300)]
k-quants : fix indentation

2 years agotests : fix quantize perf (#1990)
katsu560 [Mon, 26 Jun 2023 16:47:02 +0000 (01:47 +0900)]
tests : fix quantize perf (#1990)

* fix test quantize perf

* avoid the global state

2 years agok-quants : add AVX support to dot functions (#1916)
katsu560 [Mon, 26 Jun 2023 16:46:07 +0000 (01:46 +0900)]
k-quants : add AVX support to dot functions (#1916)

* k_quants : add AVX support

* k_quants : apply review comments

2 years agoreadme : add link to new k-quants for visibility
Georgi Gerganov [Mon, 26 Jun 2023 16:45:09 +0000 (19:45 +0300)]
readme : add link to new k-quants for visibility

2 years agok-quants : support for super-block size of 64 (#2001)
Kawrakow [Mon, 26 Jun 2023 16:43:07 +0000 (19:43 +0300)]
k-quants : support for super-block size of 64 (#2001)

* k_quants: WIP super-blocks with 64 weights

* k_quants: WIP super-blocks with 64 weights

Q6_K scalar and AVX2 works

* k_quants: WIP super-blocks with 64 weights

Q4_K scalar and AVX2 works

* k_quants: WIP super-blocks with 64 weights

Q2_K scalar and AVX2 works. Q2_K is way too slow (it is actually slower
than the scalar implementation)

* k_quants: WIP super-blocks with 64 weights

Q3_K scalar and AVX2 works.

* k_quants: WIP super-blocks with 64 weights

Q5_K scalar and AVX2 works, and with that all
k_quants are done on AVX2 and scalar

* k_quants: WIP super-blocks with 64 weights

Q6_K working on CUDA. Cannot make it run quite as gast as
with super-blocks with 256 weigths: 8% slower on 4080,
20% slower on the 1660 (but there we fit 1 less layer on the
GPU because pf the larger model size), so some fraction of
these 20% is due to that,

* k_quants: WIP super-blocks with 64 weights

Q4_K working on CUDA. ~10% slower on GTX-1660,
16% slower on 4080.

* k_quants: WIP super-blocks with 64 weights

Q2_K working on CUDA. ~3% slower on GTX-1660,
10% slower on 4080.

* k_quants: WIP super-blocks with 64 weights

Q3_K working on CUDA.

* k_quants: WIP super-blocks with 64 weights

Q5_K working on CUDA, and with this CUDA is done.

* k_quants: WIP super-blocks with 64 weights

Q6_K working on ARM_NEON

* k_quants: WIP super-blocks with 64 weights

Q4_K working on ARM_NEON, but quite a bit slower than 256 weights

* k_quants: WIP super-blocks with 64 weights

Q2_K working on ARM_NEON, but quite a bit slower than 256 weights

* k_quants: WIP super-blocks with 64 weights

Q3_K working on ARM_NEON, but quite a bit slower than 256 weights.

* k_quants: WIP super-blocks with 64 weights

Q5_K working on ARM_NEON, but quite a bit slower than 256 weights.

With that, we have full support for ARM_NEON, although
performance is not quite there.

* k_quants: WIP super-blocks with 64 weights

Slightly more efficient Q3_K and Q5_K

* k_quants: WIP super-blocks with 64 weights

Another small improvement for Q3_K and Q5_K on ARM_NEON

* k_quants: WIP super-blocks with 64 weights

Yet another speedup for Q5_K on ARM_NEON.
We are now within 10% of the QK_K = 256 version.

* k_quants: WIP super-blocks with 64 weights

* We are able to pass preprocessor macros to the Metal
  compiler
* Q6_K works and is actually slightly more efficient than
  the QK_K = 256 version (25.2 ms vs 25.8 ms)

* k_quants: WIP super-blocks with 64 weights

Q4_K works on Metal and is actually slightly faster
than QK_K = 256 (21.95 ms vs 24.0 ms).

* k_quants: WIP super-blocks with 64 weights

Q2_K works on Metal and is very slightly faster
than QK_K = 256 (23.8 ms vs 24.2 ms).

* k_quants: WIP super-blocks with 64 weights

Q3_K works on Metal and is slightly faster
than QK_K = 256 (26.6 ms vs 28.3 ms).

* k_quants: WIP super-blocks with 64 weights

Q5_K works on Metal and is slightly faster
than QK_K = 256 (23.7 ms vs 26.3 ms).

* k_quants: call them _K, not _k, also on Metal

* k_quants: correctly define QK_K in llama.cpp

* Fixed bug in q4_K quantization added with the 64-block addition

* Simplify via lambda

* k_quants: swicth Q3_K to 4-bit scales when QK_K = 64

Otherwise there isn't much benefit from this
quantization type. There is some very slight loss
in accuracy, but we reduce size by ~7%.
E.g., for OpenLLaMA-3B, Q3_K_S perplexity is
8.6131 with 8-bit scales and 8.6352 with 4-bit,
while file size decreases from 1.53G to 1.44G.

* k_quants: switch Q4_K to 4-bit scales when QK_K = 64

 Here the loss in accuracy is greater than for Q3_K,
 but the Q4_K points still move further to the left on
 the perplexity vs size curve.

* k_quants: forgot to add the Metal changes in last commit

* k_quants: change Q5_K to be type 0 when QK_K = 64

Still needs AVX2 implementation

* k_quants: AVX2 implementation for new 64-weight Q5_K

* k_quants: 10% faster ARM_NEON Q5_K dot product

* k_quants: fixed issue caused by merging with master

---------

Co-authored-by: Iwan Kawrakow <redacted>
2 years agoFix assert when free invalid cuda pointer (#2005)
Howard Su [Mon, 26 Jun 2023 15:15:47 +0000 (23:15 +0800)]
Fix assert when free invalid cuda pointer (#2005)

Fix assert via initializing extra structure always.
CUDA error 1 at C:\GPT\llama.cpp\ggml-cuda.cu:2536: invalid argument

2 years agoreadme : add new roadmap + manifesto
Georgi Gerganov [Sun, 25 Jun 2023 13:08:12 +0000 (16:08 +0300)]
readme : add new roadmap + manifesto

2 years agoggml : sync latest ggml (custom operators)
Georgi Gerganov [Sun, 25 Jun 2023 11:25:08 +0000 (14:25 +0300)]
ggml : sync latest ggml (custom operators)

2 years agofix server sampling: top k sampler first (#1977)
anon998 [Sun, 25 Jun 2023 08:48:36 +0000 (08:48 +0000)]
fix server sampling: top k sampler first (#1977)

Co-authored-by: anon <redacted>
2 years agoreadme : add Azure CI discussion link
Georgi Gerganov [Sun, 25 Jun 2023 06:07:03 +0000 (09:07 +0300)]
readme : add Azure CI discussion link

2 years agozig : upgrade build system support (#1981)
sjinzh [Sun, 25 Jun 2023 05:45:44 +0000 (13:45 +0800)]
zig : upgrade build system support (#1981)

* upgrade zig build system support

* zig : add new line at the end of the file

---------

Co-authored-by: Georgi Gerganov <redacted>
2 years ago#1869 Fix null reference errors when training from scratch with CUDA (#1907)
Robyn [Sat, 24 Jun 2023 18:10:29 +0000 (04:10 +1000)]
#1869 Fix null reference errors when training from scratch with CUDA (#1907)

* #1869 Fix null reference errors when training from scratch with CUDA build

Calling ggml_compute_forward when node->src0 was null was causing train-text-from-scratch.exe to terminate unexpectedly.

* ggml : do not dereference src0 if NULL

---------

Co-authored-by: Georgi Gerganov <redacted>
2 years agotests : sync test-grad0 from ggml
Georgi Gerganov [Sat, 24 Jun 2023 16:40:18 +0000 (19:40 +0300)]
tests : sync test-grad0 from ggml

2 years agoflake : fix ggml-metal.metal path and run nixfmt (#1974)
Rowan Hart [Sat, 24 Jun 2023 11:07:08 +0000 (04:07 -0700)]
flake : fix ggml-metal.metal path and run nixfmt (#1974)

2 years agoconvert : fix invalid params in write_vocab_only (#1975)
AN Long [Sat, 24 Jun 2023 11:02:06 +0000 (19:02 +0800)]
convert : fix invalid params in write_vocab_only (#1975)

2 years agoggml : improve ggml_graph_dump_dot, add ggml_format_name (#1978)
slaren [Sat, 24 Jun 2023 10:57:18 +0000 (12:57 +0200)]
ggml : improve ggml_graph_dump_dot, add ggml_format_name (#1978)

* Improve ggml_graph_dump_dot, add ggml_format_name

* add more automatic names to view ops

* fix name of copies

2 years agoreadme : fix whitespaces
Georgi Gerganov [Sat, 24 Jun 2023 10:38:18 +0000 (13:38 +0300)]
readme : fix whitespaces

2 years agoreadme : fixed termux instructions (#1973)
Alberto [Sat, 24 Jun 2023 10:32:13 +0000 (12:32 +0200)]
readme : fixed termux instructions (#1973)

2 years agollama : fix top-p sampling to match the canonical definition (#1953)
Alex Renda [Sat, 24 Jun 2023 10:15:01 +0000 (03:15 -0700)]
llama : fix top-p sampling to match the canonical definition (#1953)

* Fix top-p sampling to match the standard definition (smallest set that has probability mass at least p, not largest set with probability mass less than p)

* top-p: correct gt to gte

* add test for correct top-p behavior

2 years agollama : make model stateless and context stateful (llama_state) (#1797)
Didzis Gosko [Sat, 24 Jun 2023 08:47:58 +0000 (11:47 +0300)]
llama : make model stateless and context stateful (llama_state) (#1797)

* llama : make model stateless and context stateful

* llama : minor cleanup

* llama : update internal API declaration

* Apply suggestions from code review

fix style

Co-authored-by: Georgi Gerganov <redacted>
* Missing model memory release

* Fix style

* Add deprecated warning for public API function llama_init_from_file

* Update public API use cases: move away from deprecated llama_init_from_file

* Deprecate public API function llama_apply_lora_from_file

---------

Co-authored-by: Georgi Gerganov <redacted>
2 years agoAdd OpenLLaMA instructions to the README (#1954)
eiery [Fri, 23 Jun 2023 08:38:01 +0000 (04:38 -0400)]
Add OpenLLaMA instructions to the README (#1954)

* add openllama to readme

2 years agorework convert.py to read hyper-parameters from config.json (#1958)
Erik Scholz [Thu, 22 Jun 2023 12:20:47 +0000 (14:20 +0200)]
rework convert.py to read hyper-parameters from config.json (#1958)

* Read hyper-parameters from HuggingFace-transformer config.json, if they exist, and fall back to guessing, like before otherwise.
  This allows converting open_llama 3B and other non-standard model designs.

2 years agocmake: revert CUDA arch default to 52, 61 if f16 (#1959)
Johannes Gäßler [Wed, 21 Jun 2023 21:49:25 +0000 (23:49 +0200)]
cmake: revert CUDA arch default to 52, 61 if f16 (#1959)

2 years agoFix typo in README.md (#1961)
Rahul Vivek Nair [Wed, 21 Jun 2023 21:48:43 +0000 (03:18 +0530)]
Fix typo in README.md (#1961)

2 years agoreadme : add link to p1
Georgi Gerganov [Tue, 20 Jun 2023 16:05:54 +0000 (19:05 +0300)]
readme : add link to p1

2 years agoFix typo (#1949)
Xiake Sun [Tue, 20 Jun 2023 12:42:40 +0000 (05:42 -0700)]
Fix typo (#1949)

2 years agollama : fix params struct slignment (#1936)
Ettore Di Giacinto [Tue, 20 Jun 2023 01:24:39 +0000 (03:24 +0200)]
llama : fix params struct slignment (#1936)

* Workaround struct misalignment during value-copy

Signed-off-by: mudler <redacted>
* Move booleans at the bottom of the structure

Signed-off-by: mudler <redacted>
* Add comment

Signed-off-by: mudler <redacted>
---------

Signed-off-by: mudler <redacted>