]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/log
pkg/ggml/sources/llama.cpp
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)

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

2 years 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)

2 years 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.

2 years 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)

2 years 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>
2 years 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)

2 years 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

2 years 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

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

2 years 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>
2 years ago[Fix] Reenable server embedding endpoint (#1937)
Henri Vasserman [Mon, 19 Jun 2023 22:12:39 +0000 (01:12 +0300)]
[Fix] Reenable server embedding endpoint (#1937)

* Add back embedding feature

* Update README

2 years agoggml : fix bug in LBFGS optimizer (found by ggml tests)
Georgi Gerganov [Mon, 19 Jun 2023 17:43:30 +0000 (20:43 +0300)]
ggml : fix bug in LBFGS optimizer (found by ggml tests)

2 years agollama : use aligned memory during ggml_init call from loading saved sessions (#1934)
l3utterfly [Mon, 19 Jun 2023 15:20:06 +0000 (23:20 +0800)]
llama : use aligned memory during ggml_init call from loading saved sessions (#1934)

* fixed issue: memory is not guaranteed to be aligned properly during ggml_init call from loading saved sessions

* - removed commented out old code from fix
- updated another instance of same issue below original

2 years agocmake : fix trailing whitespaces
Georgi Gerganov [Mon, 19 Jun 2023 15:18:34 +0000 (18:18 +0300)]
cmake : fix trailing whitespaces

2 years agollama : only use Q6_K for output weights if tensor size is multiple of 256 (#1932)
Kawrakow [Mon, 19 Jun 2023 15:17:03 +0000 (18:17 +0300)]
llama : only use Q6_K for output weights if tensor size is multiple of 256 (#1932)

* Only use Q6_K for output weights if tensor size is multiple of 256

* Fixed copy/paste mistake

---------

Co-authored-by: Iwan Kawrakow <redacted>
2 years agocuda : faster k-quants on older GPUs (#1930)
Kawrakow [Mon, 19 Jun 2023 15:14:09 +0000 (18:14 +0300)]
cuda : faster k-quants on older GPUs (#1930)

* k_quants: hopefully much faster Q4_K on older GPUs

On the GTX-1660 that I have available to represent
"old GPUs", token prediction drops from 65.5 ms/tok
to 41.5 ms/tok!

* k_quants: hopefully much faster Q3_K on older GPUs

On the GTX-1660 that I have available to represent
"old GPUs", token prediction drops from 60.3 ms/tok
to 41.0 ms/tok!

* k_quants: faster Q2_K on older GPUs

It looks like I didn't need to change anything
compared to what we already had, so this is just
adding clarifying comments. But I now measure
36.3 ms/tok on the GTX-1660, instead fo the
47.2 ms/tok that I have written in the faster
k-quants PR.

* k_quants: faster Q5_K on older GPUs

68.5 ms/tok -> 62.0 ms/tok on GTX-1660.
For some reason the same access pattern that leads
to such resounding success for Q2_K to Q4_K did not
work at all for Q5_K.

It is also more difficult to measure because for Q5_K_S
we only have 32 layers on the GTX-1660, so output, tok embeddings
and kv cache are done on the CPU.

---------

Co-authored-by: Iwan Kawrakow <redacted>
2 years agoggml : sync latest ggml repo (#1924)
Georgi Gerganov [Mon, 19 Jun 2023 15:12:33 +0000 (18:12 +0300)]
ggml : sync latest ggml repo (#1924)

* ggml : sync latest ggml repo

* ggml : remove unused comments

* ggml : asserts

2 years agocmake : fix build shared ggml when CUDA is enabled (#1929)
Howard Su [Mon, 19 Jun 2023 15:10:37 +0000 (23:10 +0800)]
cmake : fix build shared ggml when CUDA is enabled (#1929)

Co-authored-by: Georgi Gerganov <redacted>
2 years agoConvert vector to f16 for dequantize mul mat vec (#1913)
Johannes Gäßler [Mon, 19 Jun 2023 08:23:56 +0000 (10:23 +0200)]
Convert vector to f16 for dequantize mul mat vec (#1913)

* Convert vector to f16 for dmmv

* compile option

* Added compilation option description to README

* Changed cmake CUDA_ARCHITECTURES from "OFF" to "native"

2 years agoAdded tokens per second to info prints (#1928)
Johannes Gäßler [Sun, 18 Jun 2023 15:41:26 +0000 (17:41 +0200)]
Added tokens per second to info prints (#1928)

2 years agoFixed incorrectly applying RMS norm twice (#1925)
Johannes Gäßler [Sun, 18 Jun 2023 14:07:09 +0000 (16:07 +0200)]
Fixed incorrectly applying RMS norm twice (#1925)

2 years agoggml : fix bug in ggml_compute_forward_add_q_f32 (#1918)
l3utterfly [Sun, 18 Jun 2023 11:19:16 +0000 (19:19 +0800)]
ggml : fix bug in ggml_compute_forward_add_q_f32 (#1918)

2 years agoreadme : update Android build instructions (#1922)
Mike [Sun, 18 Jun 2023 08:28:26 +0000 (16:28 +0800)]
readme : update Android build instructions (#1922)

Add steps for using termux on android devices to prevent common errors.

2 years agollama : prevent usage of k-quants when tensor size is not a multiple of 256 (#1921)
Kawrakow [Sun, 18 Jun 2023 08:13:43 +0000 (11:13 +0300)]
llama : prevent usage of k-quants when tensor size is not a multiple of 256 (#1921)

* Fix examples/metal

* k-quants: prevent usage when tensor size is not divisible by 256

---------

Co-authored-by: Iwan Kawrakow <redacted>
2 years agoexamples : fix examples/metal (#1920)
Kawrakow [Sun, 18 Jun 2023 07:52:10 +0000 (10:52 +0300)]
examples : fix examples/metal (#1920)

Co-authored-by: Iwan Kawrakow <redacted>
2 years agometal : handle buffers larger than device's maxBufferLength (#1826)
Georgi Gerganov [Sun, 18 Jun 2023 06:09:47 +0000 (09:09 +0300)]
metal : handle buffers larger than device's maxBufferLength (#1826)

* metal : handle buffers larger than device's maxBufferLength

* metal : print more verbose device info + handle errors

* metal : fix prints for overlapping views

* metal : minimize view overlap to try to utilize device memory better

2 years agocmake : add CUDA_ARCHITECTURES to new target ggml_static (#1917)
Howard Su [Sun, 18 Jun 2023 04:29:47 +0000 (12:29 +0800)]
cmake : add CUDA_ARCHITECTURES to new target ggml_static (#1917)

2 years agomake : do not print help for simple example
Georgi Gerganov [Sat, 17 Jun 2023 17:55:03 +0000 (20:55 +0300)]
make : do not print help for simple example

2 years agominor : warning fixes
Georgi Gerganov [Sat, 17 Jun 2023 17:24:11 +0000 (20:24 +0300)]
minor : warning fixes

2 years agoOnly one CUDA stream per device for async compute (#1898)
Johannes Gäßler [Sat, 17 Jun 2023 17:15:02 +0000 (19:15 +0200)]
Only one CUDA stream per device for async compute (#1898)

2 years agollama : fix kv_cache `n` init (close #1903)
Georgi Gerganov [Sat, 17 Jun 2023 16:30:22 +0000 (19:30 +0300)]
llama : fix kv_cache `n` init (close #1903)

2 years agomake : update for latest Arch (#1701)
DaniAndTheWeb [Sat, 17 Jun 2023 16:17:22 +0000 (18:17 +0200)]
make : update for latest Arch (#1701)

With the upcoming change to the openblas package in arch the Makefile workaround is no longer needed.

2 years agoggml : fix warnings under MSVC (#1908)
Howard Su [Sat, 17 Jun 2023 15:46:15 +0000 (23:46 +0800)]
ggml : fix warnings under MSVC (#1908)

2 years agometal : add norm, cpy f16->f16, alibi kernels (#1823)
Aaron Miller [Sat, 17 Jun 2023 14:37:49 +0000 (07:37 -0700)]
metal : add norm, cpy f16->f16, alibi kernels (#1823)

2 years agoexposed modules so that they can be invoked by nix run github:ggerganov/llama.cpp...
Faez Shakil [Sat, 17 Jun 2023 12:13:05 +0000 (17:13 +0500)]
exposed modules so that they can be invoked by nix run github:ggerganov/llama.cpp#server etc (#1863)

2 years agoServer Example Refactor and Improvements (#1570)
Randall Fitzgerald [Sat, 17 Jun 2023 11:53:04 +0000 (07:53 -0400)]
Server Example Refactor and Improvements (#1570)

A major rewrite for the server example.

Note that if you have built something on the previous server API, it will probably be incompatible.
Check out the examples for how a typical chat app could work.

This took a lot of effort, there are 24 PR's closed in the submitter's repo alone, over 160 commits and a lot of comments and testing.

Summary of the changes:

- adds missing generation parameters: tfs_z, typical_p, repeat_last_n, repeat_penalty, presence_penalty, frequency_penalty, mirostat, penalize_nl, seed, ignore_eos
- applies missing top k sampler
- removes interactive mode/terminal-like behavior, removes exclude parameter
- moves threads and batch size to server command-line parameters
- adds LoRA loading and matches command line parameters with main example
- fixes stopping on EOS token and with the specified token amount with n_predict
- adds server timeouts, host, and port settings
- adds expanded generation complete response; adds generation settings, stop reason, prompt truncated, model used, and final text
- sets defaults for unspecified parameters between requests
- removes /next-token endpoint and as_loop parameter, adds stream parameter and server-sent events for streaming
- adds CORS headers to responses
- adds request logging, exception printing and optional verbose logging
- adds better stopping words handling when matching multiple tokens and while streaming, or when it finishes on a partial stop string
- adds printing an error when it can't bind to the host/port specified
- fixes multi-byte character handling and replaces invalid UTF-8 characters on responses
- prints timing and build info on startup
- adds logit bias to request parameters
- removes embedding mode
- updates documentation; adds streaming Node.js and Bash examples
- fixes code formatting
- sets server threads to 1 since the current global state doesn't work well with simultaneous requests
- adds truncation of the input prompt and better context reset
- removes token limit from the input prompt
- significantly simplified the logic and removed a lot of variables

---------

Co-authored-by: anon998 <redacted>
Co-authored-by: Henri Vasserman <redacted>
Co-authored-by: Felix Hellmann <redacted>
Co-authored-by: Johannes Gäßler <redacted>
Co-authored-by: Lesaun Harvey <redacted>
2 years agohooks : setting up flake8 and pre-commit hooks (#1681)
Jiří Podivín [Sat, 17 Jun 2023 10:32:48 +0000 (12:32 +0200)]
hooks : setting up flake8 and pre-commit hooks (#1681)

Small, non-functional changes were made to non-compliant files.
These include breaking up long lines, whitespace sanitation and
unused import removal.

Maximum line length in python files was set to a generous 125 chars,
in order to minimize number of changes needed in scripts and general
annoyance. The "txt" prompts directory is excluded from the checks
as it may contain oddly formatted files and strings for a good reason.

Signed-off-by: Jiri Podivin <redacted>
2 years agoreadme : alternative way to build for Android with CLBlast. (#1828)
Gustavo Rocha Dias [Sat, 17 Jun 2023 09:01:06 +0000 (06:01 -0300)]
readme :  alternative way to build for Android with CLBlast. (#1828)

2 years agoAllow cmake to build ggml as a library (#1896)
Kerfuffle [Sat, 17 Jun 2023 07:49:42 +0000 (01:49 -0600)]
Allow cmake to build ggml as a library (#1896)

* Allow cmake to build ggml as a library

* A ggml_static library will be created

* When BUILD_SHARED_LIBS is enabled, ggml_shared will also be built

2 years agotrain : get raw text instead of page with html (#1905)
David Yang [Sat, 17 Jun 2023 06:51:54 +0000 (14:51 +0800)]
train : get raw text instead of page with html (#1905)

We probably want to train using just the text of Shakespeare instead of the html of the page displaying his work.

2 years agoopencl : support k-quants (#1836)
0cc4m [Fri, 16 Jun 2023 18:59:49 +0000 (20:59 +0200)]
opencl : support k-quants (#1836)

* Porting q2_k kernel to OpenCL

* Set global and local sizes for kernel calls for dequantizing k-quants

* Added q6_k kernel

* Fix q4_k opencl struct order

* Replace uchar with uint8_t

* Finish dequant kernels

* Added OpenCL DMMV kernels

* Fix q2_k, improve code

* Fix q3_k

* Shorten switch statements

* Improve code formatting

---------

Co-authored-by: Concedo <redacted>
2 years agoexamples : add "simple" (#1840)
SuperUserNameMan [Fri, 16 Jun 2023 18:58:09 +0000 (20:58 +0200)]
examples : add "simple" (#1840)

* Create `simple.cpp`

* minimalist example `CMakeLists.txt`

* Update Makefile for minimalist example

* remove 273: Trailing whitespace

* removed trailing white spaces simple.cpp

* typo and comments simple.cpp

---------

Co-authored-by: Georgi Gerganov <redacted>
2 years agocmake : add auto detection of BLAS_INCLUDE_DIRS (#1886)
Zenix [Fri, 16 Jun 2023 18:53:04 +0000 (03:53 +0900)]
cmake : add auto detection of BLAS_INCLUDE_DIRS (#1886)

2 years agollama : fix embd when offloading non-repeating layers (#1891)
Johannes Gäßler [Fri, 16 Jun 2023 18:25:51 +0000 (20:25 +0200)]
llama : fix embd when offloading non-repeating layers (#1891)

2 years agoFixed possible macro redefinition (#1892)
FrankHB [Fri, 16 Jun 2023 18:25:01 +0000 (02:25 +0800)]
Fixed possible macro redefinition (#1892)

MinGW libstdc++ may define `NOMINMAX` unconditionally. This fixes the case when it is already defined.

2 years agobuild : fix and ignore MSVC warnings (#1889)
Borislav Stanimirov [Fri, 16 Jun 2023 18:23:53 +0000 (21:23 +0300)]
build : fix and ignore MSVC warnings (#1889)

2 years agoCUDA : faster k-quant dot kernels (#1862)
Kawrakow [Fri, 16 Jun 2023 17:08:44 +0000 (20:08 +0300)]
CUDA : faster k-quant dot kernels (#1862)

* cuda : faster k-quant dot kernels

* Imrove Q2_K dot kernel on older GPUs

We now have a K_QUANTS_PER_ITERATION macro, which should be
set to 1 on older and to 2 on newer GPUs.
With this, we preserve the performance of the original
PR on RTX-4080, and are faster compared to master on
GTX-1660.

* Imrove Q6_K dot kernel on older GPUs

Using the same K_QUANTS_PER_ITERATION macro as last commit,
we preserve performance on RTX-4080 and speed up
Q6_K on a GTX-1660.

* Add LLAMA_CUDA_KQUANTS_ITER to CMakeLists.txt and Makefile

Allowed values are 1 or 2. 2 gives the best performance on
modern GPUs and is set as default. On older GPUs 1 may work
better.

* PR comments

---------

Co-authored-by: Iwan Kawrakow <redacted>
2 years agogitignore : add several entries specific to Visual Studio (#1888)
Borislav Stanimirov [Fri, 16 Jun 2023 06:58:11 +0000 (09:58 +0300)]
gitignore : add several entries specific to Visual Studio (#1888)

2 years agoFixed CUDA runtime version check (#1879)
Johannes Gäßler [Thu, 15 Jun 2023 19:49:08 +0000 (21:49 +0200)]
Fixed CUDA runtime version check (#1879)

2 years agocmake : remove whitespaces
Georgi Gerganov [Thu, 15 Jun 2023 18:56:50 +0000 (21:56 +0300)]
cmake : remove whitespaces

2 years agoexamples : add chat-vicuna.sh (#1854)
yangli2 [Thu, 15 Jun 2023 18:05:53 +0000 (11:05 -0700)]
examples : add chat-vicuna.sh (#1854)

Co-authored-by: Yang Li <redacted>
2 years agocmake : set include path for OpenBlas (#1830)
Igor Okulist [Thu, 15 Jun 2023 17:51:26 +0000 (12:51 -0500)]
cmake : set include path for OpenBlas (#1830)