]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/log
pkg/ggml/sources/llama.cpp
17 months agoimatrix : offload to GPU support (#4957)
Georgi Gerganov [Wed, 17 Jan 2024 16:46:30 +0000 (18:46 +0200)]
imatrix : offload to GPU support (#4957)

* backend : add eval callback

ggml-ci

* backend : group nodes in a single compute when user don't need them

* backend : clean-up the implementation

ggml-ci

* simple : do not perform tensor data copy if not needed

* simple : fix

* imatrix : offload to GPU support

* imatrix : fix ggml_mul_mat_id hanlding

ggml-ci

* ci : add imatrix test

ggml-ci

* ci : rearrange output

ggml-ci

17 months agobackend : add eval callback (#4935)
Georgi Gerganov [Wed, 17 Jan 2024 16:39:41 +0000 (18:39 +0200)]
backend : add eval callback (#4935)

* backend : add eval callback

ggml-ci

* backend : group nodes in a single compute when user don't need them

* backend : clean-up the implementation

ggml-ci

* simple : do not perform tensor data copy if not needed

* simple : fix

* simple : no need for ggml_is_contiguous + fix bool parse

* llama : fix callback placement in llama_context_params

* backend : avoid double-ask callback calls

* simple : restore examples, imatrix will serve as a demo

17 months agometal : create autorelease pool during library build (#4970)
Georgi Gerganov [Wed, 17 Jan 2024 16:38:39 +0000 (18:38 +0200)]
metal : create autorelease pool during library build (#4970)

* metal : create autorelease pool during library build

ggml-ci

* test : simplify

ggml-ci

17 months agopy : fix whitespace
Georgi Gerganov [Wed, 17 Jan 2024 16:37:36 +0000 (18:37 +0200)]
py : fix whitespace

17 months agopy : fix missing added_tokens_dict for SPM and BPE vocabs (#4971)
Georgi Gerganov [Wed, 17 Jan 2024 13:45:03 +0000 (15:45 +0200)]
py : fix missing added_tokens_dict for SPM and BPE vocabs (#4971)

* py : fix missing added_tokens_dict for SPM vocab

* py : pad with unknown tokens when data is missing

ggml-ci

* py : fix BPE vocab conversion

ggml-ci

* py : fix padded dummy tokens (I hope)

17 months agollama : use Q4_K for attn_v for Q2_K_S when n_gqa >= 4 (#4996)
Kawrakow [Wed, 17 Jan 2024 10:36:37 +0000 (12:36 +0200)]
llama : use Q4_K for attn_v for Q2_K_S when n_gqa >= 4 (#4996)

Co-authored-by: Iwan Kawrakow <redacted>
17 months agometal : remove unnecessary nil check (#4986)
Paul Tsochantaris [Wed, 17 Jan 2024 08:07:24 +0000 (08:07 +0000)]
metal : remove unnecessary nil check (#4986)

17 months agollama : fix copy/paste error in llama_sampling_params comment (#4994)
David Renshaw [Wed, 17 Jan 2024 07:17:50 +0000 (02:17 -0500)]
llama : fix copy/paste error in llama_sampling_params comment (#4994)

17 months agopy : remove unnecessary hasattr (#4903)
Georgi Gerganov [Tue, 16 Jan 2024 18:59:31 +0000 (20:59 +0200)]
py : remove unnecessary hasattr (#4903)

17 months agonix: remove nixConfig from flake.nix (#4984)
Philip Taron [Tue, 16 Jan 2024 17:56:21 +0000 (09:56 -0800)]
nix: remove nixConfig from flake.nix (#4984)

17 months agofinetune : add training data file to log message (#4979)
Daniel Bevenius [Tue, 16 Jan 2024 17:54:24 +0000 (18:54 +0100)]
finetune : add training data file to log message (#4979)

This commit adds the name of the training data file to the log message
printed when the training data is tokenized.

The motivation for this change is that it can be useful to show which
file is being tokenized when running the finetune example.

Signed-off-by: Daniel Bevenius <redacted>
17 months agoggml : importance matrix support for legacy quants (#4969)
Kawrakow [Tue, 16 Jan 2024 17:51:26 +0000 (19:51 +0200)]
ggml : importance matrix support for legacy quants (#4969)

* imatrix: adding support for legacy quants

* imatrix: guard Q4_0/Q5_0 against ffn_down craziness

---------

Co-authored-by: Iwan Kawrakow <redacted>
17 months agoexamples : add complete parallel function calling example (#4974)
Maximilian Winter [Tue, 16 Jan 2024 17:41:42 +0000 (18:41 +0100)]
examples : add complete parallel function calling example (#4974)

17 months agoperplexity : fix kv cache handling for hellaswag (#4981)
Georgi Gerganov [Tue, 16 Jan 2024 17:34:54 +0000 (19:34 +0200)]
perplexity : fix kv cache handling for hellaswag (#4981)

ggml-ci

17 months agoflake.lock: update flake-parts, flake-parts/nixpkgs-lib, and nixpkgs (#4920)
Georgi Gerganov [Tue, 16 Jan 2024 17:13:54 +0000 (19:13 +0200)]
flake.lock: update flake-parts, flake-parts/nixpkgs-lib, and nixpkgs (#4920)

Flake lock file updates:

• Updated input 'flake-parts':
    'github:hercules-ci/flake-parts/34fed993f1674c8d06d58b37ce1e0fe5eebcb9f5' (2023-12-01)
  → 'github:hercules-ci/flake-parts/07f6395285469419cf9d078f59b5b49993198c00' (2024-01-11)
• Updated input 'flake-parts/nixpkgs-lib':
    'github:NixOS/nixpkgs/e92039b55bcd58469325ded85d4f58dd5a4eaf58?dir=lib' (2023-11-29)
  → 'github:NixOS/nixpkgs/b0d36bd0a420ecee3bc916c91886caca87c894e9?dir=lib' (2023-12-30)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/cfc3698c31b1fb9cdcf10f36c9643460264d0ca8' (2023-12-27)
  → 'github:NixOS/nixpkgs/317484b1ead87b9c1b8ac5261a8d2dd748a0492d' (2024-01-08)

Co-authored-by: github-actions[bot] <redacted>
17 months agometal : localized logic in `ggml_metal_graph_compute` (#4924)
Paul Tsochantaris [Tue, 16 Jan 2024 17:05:19 +0000 (17:05 +0000)]
metal : localized logic in `ggml_metal_graph_compute` (#4924)

* Metal: Localized logic in `ggml_metal_graph_compute`, minor performance improvement

* Whitespace

* Collecting command buffer completions on single thread

* Whitespace

* Reduce diff noise

17 months agoandroid : introduce starter project example (#4926)
Neuman Vong [Tue, 16 Jan 2024 13:47:34 +0000 (00:47 +1100)]
android : introduce starter project example (#4926)

* Introduce starter project for Android

Based on examples/llama.swiftui.

* Add github workflow

* Set NDK version

* Only build arm64-v8a in CI

* Sync bench code

* Rename CI prop to skip-armeabi-v7a

* Remove unused tests

17 months agometal : replace loop of dispatch_async with dispatch_apply (#4934)
Alex Azarov [Tue, 16 Jan 2024 13:41:27 +0000 (14:41 +0100)]
metal : replace loop of dispatch_async with dispatch_apply (#4934)

* Replace loop of dispatch_async with dispatch_apply

* Update ggml-metal.m

---------

Co-authored-by: Georgi Gerganov <redacted>
17 months agometal : log `recommendedMaxWorkingSetSize` on iOS 16+ (#4936)
Alex Azarov [Tue, 16 Jan 2024 13:33:02 +0000 (14:33 +0100)]
metal : log `recommendedMaxWorkingSetSize` on iOS 16+ (#4936)

* metal: Log `recommendedMaxWorkingSetSize` on iOS 16+

* Only log on iOS and macOS, ignoring tvOS and other platforms

* Check for Xcode version before using recommendedMaxWorkingSetSize

---------

Co-authored-by: Georgi Gerganov <redacted>
17 months agoexamples : fix and improv docs for the grammar generator (#4909)
Maximilian Winter [Tue, 16 Jan 2024 12:10:48 +0000 (13:10 +0100)]
examples : fix and improv docs for the grammar generator (#4909)

* Create pydantic-models-to-grammar.py

* Added some comments for usage

* Refactored Grammar Generator

Added example and usage instruction.

* Update pydantic_models_to_grammar.py

* Update pydantic-models-to-grammar-examples.py

* Renamed module and imported it.

* Update pydantic-models-to-grammar.py

* Renamed file and fixed grammar generator issue.

* Fixed some issues and bugs of the grammar generator. Imporved Documentation

* Update pydantic_models_to_grammar.py

17 months agoggml : introduce GGML_CALL function annotation (#4850)
Justine Tunney [Tue, 16 Jan 2024 11:16:33 +0000 (03:16 -0800)]
ggml : introduce GGML_CALL function annotation (#4850)

This change makes it possible to build ggml-cuda.cu and ggml-metal.m as
independent dynamic shared objects, that may be conditionally linked at
runtime in a multiplatform binary. It introduces a GGML_CALL annotation
that documents which functions have a cyclic call relationship, between
the application code and GPU modules.

This change does nothing, unless the build defines -DGGML_MULTIPLATFORM
which causes back-references and function pointers to conform to MS ABI
which is supported by NVCC, ROCm, XCode, GCC and Clang across platforms

17 months agofinetune : use LLAMA_FILE_MAGIC_GGLA (#4961)
Daniel Bevenius [Tue, 16 Jan 2024 11:14:19 +0000 (12:14 +0100)]
finetune : use LLAMA_FILE_MAGIC_GGLA (#4961)

This commit replaces the magic number LLAMA_FILE_MAGIC_LORA used in
finetune.cpp with LLAMA_FILE_MAGIC_GGLA defined in llama.h.

Signed-off-by: Daniel Bevenius <redacted>
17 months agospeculative : threading options (#4959)
stduhpf [Tue, 16 Jan 2024 11:04:32 +0000 (12:04 +0100)]
speculative : threading options (#4959)

* speculative: expose draft threading

* fix usage format

* accept -td and -tbd args

* speculative: revert default behavior when -td is unspecified

* fix trailing whitespace

17 months agopass cpu-architecture arguments only to host code (C;C++) (#4943)
ngc92 [Mon, 15 Jan 2024 18:40:48 +0000 (20:40 +0200)]
pass cpu-architecture arguments only to host code (C;C++) (#4943)

17 months agollama : apply classifier-free guidance to logits directly (#4951)
David Friehs [Mon, 15 Jan 2024 13:06:52 +0000 (14:06 +0100)]
llama : apply classifier-free guidance to logits directly (#4951)

17 months agoawq-py : fix typo in awq-py/README.md (#4947)
Victor Z. Peng [Mon, 15 Jan 2024 12:41:46 +0000 (04:41 -0800)]
awq-py : fix typo in awq-py/README.md (#4947)

17 months agocuda : fix dequantize kernel names (#4938)
Georgi Gerganov [Mon, 15 Jan 2024 11:27:00 +0000 (13:27 +0200)]
cuda : fix dequantize kernel names (#4938)

17 months agollama : check for 256 divisibility for IQ2_XS, IQ2_XXS (#4950)
Kawrakow [Mon, 15 Jan 2024 08:09:38 +0000 (10:09 +0200)]
llama : check for 256 divisibility for IQ2_XS, IQ2_XXS (#4950)

Co-authored-by: Iwan Kawrakow <redacted>
17 months agoCUDA: faster dequantize kernels for Q4_0 and Q4_1 (#4938)
Kawrakow [Mon, 15 Jan 2024 05:48:06 +0000 (07:48 +0200)]
CUDA: faster dequantize kernels for Q4_0 and Q4_1 (#4938)

Co-authored-by: Iwan Kawrakow <redacted>
17 months agollama : fix missing quotes (#4937)
David Pflug [Sun, 14 Jan 2024 15:46:00 +0000 (10:46 -0500)]
llama : fix missing quotes (#4937)

17 months agoAdd ability to use importance matrix for all k-quants (#4930)
Kawrakow [Sun, 14 Jan 2024 14:21:12 +0000 (16:21 +0200)]
Add ability to use importance matrix for all k-quants (#4930)

Co-authored-by: Iwan Kawrakow <redacted>
17 months agollama : check LLAMA_TRACE env for extra logging (#4929)
Georgi Gerganov [Sun, 14 Jan 2024 11:26:53 +0000 (13:26 +0200)]
llama : check LLAMA_TRACE env for extra logging (#4929)

* llama : minor fix indent

* llama : check LLAMA_TRACE env for extra logging

ggml-ci

17 months agoscripts : sync-ggml-am.sh option to skip commits
Georgi Gerganov [Sun, 14 Jan 2024 09:08:09 +0000 (11:08 +0200)]
scripts : sync-ggml-am.sh option to skip commits

17 months agollama : use LLAMA_LOG_ macros for logging
Georgi Gerganov [Sun, 14 Jan 2024 09:03:19 +0000 (11:03 +0200)]
llama : use LLAMA_LOG_ macros for logging

17 months agoFix ffn_down quantization mix for MoE models (#4927)
Kawrakow [Sun, 14 Jan 2024 08:53:39 +0000 (10:53 +0200)]
Fix ffn_down quantization mix for MoE models (#4927)

* Fix ffn_down quantization mix for MoE models

In #4872 I did not consider the part where every third
tensor is quantized with more bits. Fir MoE this leads to tensors
of the same layer being quantized with different number of bits,
which is not considered as a possibility in the inference implementation
(it is assumed all experts use the same quantization).

* Fix the fix

* Review suggestion

---------

Co-authored-by: Iwan Kawrakow <redacted>
17 months agometal : correctly set SIMD support flags on iOS (#4923)
Alex Azarov [Sun, 14 Jan 2024 08:44:39 +0000 (09:44 +0100)]
metal : correctly set SIMD support flags on iOS (#4923)

* Correctly set support_simdgroup_reduction and support_simdgroup_mm on iPhone/iPad

* log a little bit more info on iOS

17 months agollama : support WinXP build with MinGW 8.1.0 (#3419)
Karthik Kumar Viswanathan [Sun, 14 Jan 2024 08:41:44 +0000 (00:41 -0800)]
llama : support WinXP build with MinGW 8.1.0 (#3419)

17 months ago2-bit quantizations (#4897)
Kawrakow [Sun, 14 Jan 2024 07:45:56 +0000 (09:45 +0200)]
2-bit quantizations (#4897)

* imatrix: load

* imatrix: WIP

* imatrix: Add Q2_K quantization

* imatrix: also guard against Q2_K_S quantization without importance matrix

* imatrix: guard even more against low-bit quantization misuse

---------

Co-authored-by: Iwan Kawrakow <redacted>
17 months agoMake Q3_K_S be the same as olf Q3_K_L for Mixtral-8x7B (#4906)
Kawrakow [Sun, 14 Jan 2024 07:44:30 +0000 (09:44 +0200)]
Make Q3_K_S be the same as olf Q3_K_L for Mixtral-8x7B (#4906)

Co-authored-by: Iwan Kawrakow <redacted>
17 months agosync : ggml
Georgi Gerganov [Sat, 13 Jan 2024 22:14:46 +0000 (00:14 +0200)]
sync : ggml

17 months agoggml: cache sin/cos for RoPE (#4908)
Johannes Gäßler [Sat, 13 Jan 2024 20:41:37 +0000 (21:41 +0100)]
ggml: cache sin/cos for RoPE (#4908)

17 months agometal : remove old API (#4919)
Georgi Gerganov [Sat, 13 Jan 2024 18:45:45 +0000 (20:45 +0200)]
metal : remove old API (#4919)

ggml-ci

17 months agoserver : fix prompt caching with system prompt (#4914)
Georgi Gerganov [Sat, 13 Jan 2024 17:31:26 +0000 (19:31 +0200)]
server : fix prompt caching with system prompt (#4914)

17 months agollama : fix detokenization of non-special added-tokens (#4916)
Georgi Gerganov [Sat, 13 Jan 2024 16:47:38 +0000 (18:47 +0200)]
llama : fix detokenization of non-special added-tokens (#4916)

Co-authored-by: goerch <redacted>
17 months agometal : disable log for loaded kernels (#4794)
Georgi Gerganov [Sat, 13 Jan 2024 16:46:37 +0000 (18:46 +0200)]
metal : disable log for loaded kernels (#4794)

17 months agollama : minimize size used for state save/load (#4820)
David Friehs [Sat, 13 Jan 2024 16:29:43 +0000 (17:29 +0100)]
llama : minimize size used for state save/load (#4820)

* examples : save-load-state: save only required state

* llama : only reserve n_vocab * n_batch at most for logits

llama_decode asserts that only n_batch tokens are passed each call, and
n_ctx is expected to be bigger than n_batch.

* llama : always reserve n_vocab * n_batch for logits

llama_context de-serialization breaks if the contexts have differing
capacity for logits and llama_decode will at maximum resize to
n_vocab * n_batch.

* llama : only save and restore used logits

for batch sizes of 512 this reduces save state in the best case by
around 62 MB, which can be a lot if planning to save on each message
to allow regenerating messages.

* llama : use ostringstream and istringstream for save and load

* llama : serialize rng into minimum amount of space required

* llama : break session version due to serialization changes

17 months agoworkflows: unbreak nix-build-aarch64, and split it out (#4915)
Someone [Sat, 13 Jan 2024 16:29:16 +0000 (16:29 +0000)]
workflows: unbreak nix-build-aarch64, and split it out (#4915)

The fix should be just the `sudo apt-get update`

17 months agomain : add parameter --no-display-prompt (#4541)
Yann Follet [Sat, 13 Jan 2024 16:09:08 +0000 (00:09 +0800)]
main : add parameter --no-display-prompt (#4541)

* add the parameter : --no-display-prompt , combine with --log-disable it will display only the generated tokens

* remove empty line

---------

Co-authored-by: Georgi Gerganov <redacted>
17 months agogguf : fix potential infinite for-loop (#4600)
texmex76 [Sat, 13 Jan 2024 16:06:20 +0000 (17:06 +0100)]
gguf : fix potential infinite for-loop (#4600)

Co-authored-by: Bernhard Gstrein <redacted>
17 months agometal : refactor kernel loading code (#4794)
Georgi Gerganov [Sat, 13 Jan 2024 16:03:45 +0000 (18:03 +0200)]
metal : refactor kernel loading code (#4794)

* metal : detect more GPU families

* metal : refactor kernel loading

* metal : set kernel family requirements

* metal : fix kernel init + fix compile options

* metal : take into account simdgroup reduction support

* metal : print only skipped kernels

* metal : fix check for simdgroup reduction support

* metal : check for Metal 3

* metal : free allocations

* metal : normalize encoder:setComputePipelineStatus calls

ggml-ci

* metal : fix Metal3 family check

ggml-ci

* metal : check for simdgroup matrix mul. feature

ggml-ci

17 months agocompare-llama-bench: tweak output format (#4910)
Johannes Gäßler [Sat, 13 Jan 2024 14:52:53 +0000 (15:52 +0100)]
compare-llama-bench: tweak output format (#4910)

17 months agoserver : fix deadlock that occurs in multi-prompt scenarios (#4905)
Ziad Ben Hadj-Alouane [Sat, 13 Jan 2024 14:20:46 +0000 (09:20 -0500)]
server : fix deadlock that occurs in multi-prompt scenarios (#4905)

* * fix deadlock

* * dont ruint all whitespace

17 months agoserver : fix crash with multimodal models without BOS token (#4904)
makomk [Sat, 13 Jan 2024 14:16:11 +0000 (14:16 +0000)]
server : fix crash with multimodal models without BOS token (#4904)

17 months agoconvert : update phi-2 to latest HF repo (#4903)
Georgi Gerganov [Sat, 13 Jan 2024 11:44:37 +0000 (13:44 +0200)]
convert : update phi-2 to latest HF repo (#4903)

* convert : update phi-2 to latest HF repo

ggml-ci

* py : try to fix flake stuff

17 months agosync : ggml
Georgi Gerganov [Fri, 12 Jan 2024 20:02:43 +0000 (22:02 +0200)]
sync : ggml

17 months agoggml : fix 32-bit ARM compat for IQ2_XS (whisper/1758)
Georgi Gerganov [Fri, 12 Jan 2024 12:02:30 +0000 (14:02 +0200)]
ggml : fix 32-bit ARM compat for IQ2_XS (whisper/1758)

* ggml : fix 32-bit ARM compat

* ggml : fix fix

* ggml : fix fix fix

17 months agobackend_sched : fix assignments
slaren [Fri, 12 Jan 2024 19:38:34 +0000 (20:38 +0100)]
backend_sched : fix assignments

ggml-ci

17 months agoexamples : add pydantic models to GBNF grammar generator (#4883)
Maximilian Winter [Fri, 12 Jan 2024 19:46:45 +0000 (20:46 +0100)]
examples : add pydantic models to GBNF grammar generator (#4883)

* Create pydantic-models-to-grammar.py

* Added some comments for usage

* Refactored Grammar Generator

Added example and usage instruction.

* Update pydantic_models_to_grammar.py

* Update pydantic-models-to-grammar-examples.py

* Renamed module and imported it.

* Update pydantic-models-to-grammar.py

* Renamed file and fixed grammar generator issue.

17 months agoCUDA: faster q8_0 -> f16 dequantization (#4895)
Johannes Gäßler [Fri, 12 Jan 2024 19:38:54 +0000 (20:38 +0100)]
CUDA: faster q8_0 -> f16 dequantization (#4895)

17 months agollama : ggml-backend integration (#4766)
slaren [Fri, 12 Jan 2024 19:07:38 +0000 (20:07 +0100)]
llama : ggml-backend integration (#4766)

* llama : ggml-backend integration

* ggml-backend : add names to buffers

* fix unmap after loading

* batched-bench : add tensor_split param

* llama : check for null tensor_split

* ggml-backend : increase GGML_MAX_BACKENDS

* improve graph splitting, partial fix for --no-kv-offload

* cuda : add ggml-backend split buffer support

* cuda : do not create buffer types for devices that don't exist (fixes usage without CUDA devices available)

* ggml : fix null backend dereference (#4807)

* ggml : fix null backend dereference

* ggml : also check ggml_backend_is_cpu

* test-backend-ops : check buffer allocation failures

* llama : add cparam (split_mode) and command line argument (--split-mode, -sm) to configure the split mode (none, layer or row)

* ggml : fix mul_mat_id work size

* llama : rewrite session kv load/set without graphs

* minor

* llama : only initialize used backends, free backends on context free

* llama : abort ctx if cuda backend init fails

* llama : rewrite lora with ggml-backend and compute on CPU

ggml-ci

* llama : only map to a backend buffer the region of the file mapping containing the tensors used in the buffer

* opencl : add ggml-backend buffer type

* cuda : only use batched_cublas with batched mat muls (fixes fp16 tg perf)

* llama : on Metal, by default offload the full model

ggml-ci

* metal : page align the data ptr (#4854)

* Apply suggestions from code review

Co-authored-by: Johannes Gäßler <redacted>
* cuda : fix split buffer free

* address review comments

* llama-bench : add split-mode parameter

* fix whitespace

* opencl : fix double initialization

* server : add --split-mode parameter

* use async copy and compute to improve multi-gpu performance

ggml-ci

* use async memcpys to copy the graph outputs to the CPU

* fix opencl

* use a host buffer for the cpu compute buffer for faster copies to the gpu

---------

Co-authored-by: Georgi Gerganov <redacted>
Co-authored-by: Johannes Gäßler <redacted>
17 months agollama : remove redundant assert for StableLM (#4901)
Georgi Gerganov [Fri, 12 Jan 2024 18:54:12 +0000 (20:54 +0200)]
llama : remove redundant assert for StableLM (#4901)

17 months agoexport-lora : use LLAMA_FILE_MAGIC_GGLA (#4894)
Daniel Bevenius [Fri, 12 Jan 2024 17:54:53 +0000 (18:54 +0100)]
export-lora : use LLAMA_FILE_MAGIC_GGLA (#4894)

This commit replaces the magic number used in export-lora.cpp with
the one defined in llama.h, which is indirectly included via common.h.

Signed-off-by: Daniel Bevenius <redacted>
17 months agollama.swiftui : update models layout (#4826)
Zay [Fri, 12 Jan 2024 12:48:00 +0000 (05:48 -0700)]
llama.swiftui : update models layout (#4826)

* Updated Models Layout

- Added a models drawer
- Added downloading directly from Hugging Face
- Load custom models from local folder
- Delete models by swiping left

* trimmed trailing white space

* Updated Models Layout

17 months agogitignore : imatrix
Georgi Gerganov [Fri, 12 Jan 2024 12:33:21 +0000 (14:33 +0200)]
gitignore : imatrix

17 months agoCUDA: fix softmax compile for old CUDA versions (#4862)
Johannes Gäßler [Fri, 12 Jan 2024 11:30:41 +0000 (12:30 +0100)]
CUDA: fix softmax compile for old CUDA versions (#4862)

17 months agollama : fix typo "imp_embd" -> "inp_embd"
Georgi Gerganov [Fri, 12 Jan 2024 11:10:19 +0000 (13:10 +0200)]
llama : fix typo "imp_embd" -> "inp_embd"

17 months agocommon : streamline the formatting of help (#4890)
howlger [Fri, 12 Jan 2024 11:05:32 +0000 (12:05 +0100)]
common : streamline the formatting of help (#4890)

* common : streamline the formatting of help

- Separate alternative parameters by a comma

- Do not indent `--version` differently

* Update common/common.cpp

---------

Co-authored-by: Georgi Gerganov <redacted>
17 months agopy : fix lint (#4889)
Georgi Gerganov [Fri, 12 Jan 2024 11:03:38 +0000 (13:03 +0200)]
py : fix lint (#4889)

17 months agollama : fix llm_build_k_shift to use correct n_rot (#4889)
Georgi Gerganov [Fri, 12 Jan 2024 11:01:56 +0000 (13:01 +0200)]
llama : fix llm_build_k_shift to use correct n_rot (#4889)

* llama : fix llm_build_k_shift to use correct n_rot

ggml-ci

* llama : always use hparams.n_rot for ggml_rope_custom

ggml-ci

* convert : fix persimmon conversion to write correct n_rot

17 months agoImportance Matrix calculation (#4861)
Kawrakow [Fri, 12 Jan 2024 05:59:57 +0000 (06:59 +0100)]
Importance Matrix calculation (#4861)

* imatrix: 1st version

* imatrix: WIP

* Cleanup

* Update examples/imatrix/imatrix.cpp

Co-authored-by: Georgi Gerganov <redacted>
---------

Co-authored-by: Iwan Kawrakow <redacted>
Co-authored-by: Georgi Gerganov <redacted>
17 months agoserver : fix infill when prompt is empty (#4833)
Georgi Gerganov [Thu, 11 Jan 2024 21:23:49 +0000 (23:23 +0200)]
server : fix infill when prompt is empty (#4833)

17 months agomain : better name for variable n_print (#4874)
Georgi Gerganov [Thu, 11 Jan 2024 20:46:26 +0000 (22:46 +0200)]
main : better name for variable n_print (#4874)

17 months agomain : disable token count by default (#4874)
Georgi Gerganov [Thu, 11 Jan 2024 20:43:05 +0000 (22:43 +0200)]
main : disable token count by default (#4874)

17 months agoswift : track ggml release branch (#4867)
Georgi Gerganov [Thu, 11 Jan 2024 19:58:28 +0000 (21:58 +0200)]
swift : track ggml release branch (#4867)

17 months agollama : restore intended k-quants mixes for MoE models (#4872)
Kawrakow [Thu, 11 Jan 2024 19:43:15 +0000 (20:43 +0100)]
llama : restore intended k-quants mixes for MoE models (#4872)

* Restore intended k-quants quantization mixes for MoE models

* Update Q2_K_S values in the quantize tool

Still using LLaMA-v1 PPL values in the quant description
today does not make much sense. But let's leave this update
for another PR.

---------

Co-authored-by: Iwan Kawrakow <redacted>
Co-authored-by: Georgi Gerganov <redacted>
17 months agoggml : SOTA 2-bit quants (add IQ2_XS) (#4856)
Kawrakow [Thu, 11 Jan 2024 19:39:39 +0000 (20:39 +0100)]
ggml : SOTA 2-bit quants (add IQ2_XS) (#4856)

* iq2_xs: basics

* iq2_xs: this should have been in the basics

* iq2_xs: CUDA and scalar CPU works

* iq2_xs: WIP Metal

* iq2_xs: Metal now works

* iq2_xs: working, but dog slow, ARM_NEON dot product

* iq2_xs: better ARM_NEON dot product

We are now at 19.5 t/s for TG-128 and 61 t/s for PP-512 when
running on the CPU.

* iq2_xs: AVX2 dot product - 19.5 t/s

* iq2_xs: faster AVX2 dit product

21.4 t/s for TG-128, 59.2 t/s for PP-512.
The latter is 2x compared to the previous version.

* iq2_xs: had forgotten to delete iq2-data.h

* Add llama enum for IQ2_XS

---------

Co-authored-by: Iwan Kawrakow <redacted>
17 months agoswift : pin ggml commit + remove ggml.h from spm-headers (#4878)
Georgi Gerganov [Thu, 11 Jan 2024 19:31:31 +0000 (21:31 +0200)]
swift : pin ggml commit + remove ggml.h from spm-headers (#4878)

ggml-ci

17 months agoserver : implement credentialed CORS (#4514)
Laura [Thu, 11 Jan 2024 18:02:48 +0000 (19:02 +0100)]
server : implement credentialed CORS (#4514)

* Implement credentialed CORS according to MDN

* Fix syntax error

* Move validate_api_key up so it is defined before its first usage

17 months agoserver : support for multiple api keys (#4864)
Michael Coppola [Thu, 11 Jan 2024 17:51:17 +0000 (12:51 -0500)]
server : support for multiple api keys (#4864)

* server: added support for multiple api keys, added loading api keys from file

* minor: fix whitespace

* added file error handling to --api-key-file, changed code to better
reflect current style

* server: update README.md for --api-key-file

---------

Co-authored-by: Michael Coppola <redacted>
17 months agoserver : add `LOG_INFO` when model is successfully loaded (#4881)
Behnam M [Thu, 11 Jan 2024 17:41:39 +0000 (12:41 -0500)]
server : add `LOG_INFO` when model is successfully loaded (#4881)

* added /health endpoint to the server

* added comments on the additional /health endpoint

* Better handling of server state

When the model is being loaded, the server state is `LOADING_MODEL`. If model-loading fails, the server state becomes `ERROR`, otherwise it becomes `READY`. The `/health` endpoint provides more granular messages now according to the server_state value.

* initialized server_state

* fixed a typo

* starting http server before initializing the model

* Update server.cpp

* Update server.cpp

* fixes

* fixes

* fixes

* made ServerState atomic and turned two-line spaces into one-line

* updated `server` readme to document the `/health` endpoint too

* used LOG_INFO after successful model loading

17 months agoci: nix-flake-update: new token with pr permissions (#4879)
Someone [Thu, 11 Jan 2024 17:22:34 +0000 (17:22 +0000)]
ci: nix-flake-update: new token with pr permissions (#4879)

* ci: nix-flake-update: new token with pr permissions

---------

Co-authored-by: Georgi Gerganov <redacted>
17 months agomain : print total token count and tokens consumed so far (#4874)
pudepiedj [Thu, 11 Jan 2024 16:14:52 +0000 (16:14 +0000)]
main : print total token count and tokens consumed so far (#4874)

* Token count changes

* Add show token count

* Updating before PR

* Two requested changes

* Move param def posn

17 months agoserver : fix typo in model name (#4876)
Isaac McFadyen [Thu, 11 Jan 2024 14:33:26 +0000 (09:33 -0500)]
server : fix typo in model name (#4876)

17 months agometal : put encoder debug group behind a define (#4873)
Paul Tsochantaris [Thu, 11 Jan 2024 14:31:52 +0000 (14:31 +0000)]
metal : put encoder debug group behind a define (#4873)

17 months agosync : ggml
Georgi Gerganov [Thu, 11 Jan 2024 07:39:08 +0000 (09:39 +0200)]
sync : ggml

17 months agometal : fix deprecation warning (ggml/690)
Georgi Gerganov [Thu, 11 Jan 2024 07:34:59 +0000 (09:34 +0200)]
metal : fix deprecation warning (ggml/690)

17 months agoggml : remove ggml_cpy_inplace and ggml_cont_inplace (ggml/693)
Timothy Cronin [Thu, 11 Jan 2024 07:27:48 +0000 (02:27 -0500)]
ggml : remove ggml_cpy_inplace and ggml_cont_inplace (ggml/693)

17 months agometal : wrap each operation in debug group (ggml/690)
Jack Mousseau [Wed, 10 Jan 2024 14:19:19 +0000 (06:19 -0800)]
metal : wrap each operation in debug group (ggml/690)

17 months agoggml : change GGML_MAX_NAME at compile time (ggml/682)
leejet [Wed, 10 Jan 2024 13:13:42 +0000 (21:13 +0800)]
ggml : change GGML_MAX_NAME at compile time (ggml/682)

* change GGML_MAX_NAME to 128

* allow controlling the value of GGML_MAX_NAME through external macro definitions

17 months agoFix execlp call (ggml/689)
Halalaluyafail3 [Tue, 9 Jan 2024 16:16:37 +0000 (11:16 -0500)]
Fix execlp call (ggml/689)

NULL can be an integer constant expression with the value zero, in this case the behavior would be undefined because of an incorrect type being passed to the variable arguments.

17 months agofix : cuda order of synchronization when setting a buffer (ggml/679)
Erik Scholz [Fri, 5 Jan 2024 15:00:00 +0000 (16:00 +0100)]
fix : cuda order of synchronization when setting a buffer (ggml/679)

* fix : cuda order of synchronization when setting a buffer

* also sync before memcpy

---------

Co-authored-by: slaren <redacted>
17 months agoserver : update readme to document the new `/health` endpoint (#4866)
Behnam M [Thu, 11 Jan 2024 07:12:05 +0000 (02:12 -0500)]
server : update readme to document the new `/health` endpoint (#4866)

* added /health endpoint to the server

* added comments on the additional /health endpoint

* Better handling of server state

When the model is being loaded, the server state is `LOADING_MODEL`. If model-loading fails, the server state becomes `ERROR`, otherwise it becomes `READY`. The `/health` endpoint provides more granular messages now according to the server_state value.

* initialized server_state

* fixed a typo

* starting http server before initializing the model

* Update server.cpp

* Update server.cpp

* fixes

* fixes

* fixes

* made ServerState atomic and turned two-line spaces into one-line

* updated `server` readme to document the `/health` endpoint too

17 months agoserver : fix build + rename enums (#4870)
Georgi Gerganov [Thu, 11 Jan 2024 07:10:34 +0000 (09:10 +0200)]
server : fix build + rename enums (#4870)

17 months agoserver : add a `/health` endpoint (#4860)
Behnam M [Wed, 10 Jan 2024 19:56:05 +0000 (14:56 -0500)]
server : add a `/health` endpoint (#4860)

* added /health endpoint to the server

* added comments on the additional /health endpoint

* Better handling of server state

When the model is being loaded, the server state is `LOADING_MODEL`. If model-loading fails, the server state becomes `ERROR`, otherwise it becomes `READY`. The `/health` endpoint provides more granular messages now according to the server_state value.

* initialized server_state

* fixed a typo

* starting http server before initializing the model

* Update server.cpp

* Update server.cpp

* fixes

* fixes

* fixes

* made ServerState atomic and turned two-line spaces into one-line

17 months agollama : add additional suffixes for model params (#4834)
Brian [Wed, 10 Jan 2024 14:09:53 +0000 (01:09 +1100)]
llama : add additional suffixes for model params (#4834)

* llm_load_print_meta: Add additional suffixs for model params

* Update llama.cpp model param log

remove unneeded comments and convert from > to >=

17 months agollama : recognize 1B phi models (#4847)
Austin [Wed, 10 Jan 2024 13:39:09 +0000 (08:39 -0500)]
llama : recognize 1B phi models (#4847)

This update categorizes models with 24 layers as MODEL_1B, ensuring compatibility with different Phi model variants without impacting existing Phi-2 model functionality.

17 months agoclip : support more quantization types (#4846)
John [Wed, 10 Jan 2024 13:37:09 +0000 (14:37 +0100)]
clip : support more quantization types (#4846)

Uses ggml functions instead of hardcoded names and adds support to quantize into the modern Q-K variants.
This is just the bare minimum to get k-types working - a more refined choice of types would be needed to get best quality on low quantizations.

I ran a few tests, it doesn't break anything I could notice and a Q6_K ViT works almost as well as Q8_0 but 3 times the inference speed.

17 months agoPython script to compare commits with llama-bench (#4844)
Johannes Gäßler [Wed, 10 Jan 2024 00:04:33 +0000 (01:04 +0100)]
Python script to compare commits with llama-bench (#4844)

17 months agoconvert.py : fix vanilla LLaMA model conversion (#4818)
Austin [Tue, 9 Jan 2024 18:46:46 +0000 (13:46 -0500)]
convert.py : fix vanilla LLaMA model conversion (#4818)

* Update Imports and Add Notes for Future Reference

- Updated import statements in `convert.py`.
- Added import for `AutoTokenizer` from `transformers` module.
- Added conditional import for `gguf` from the local directory.
- Added comments and notes for future reference.

Additional Notes:

- Noted removal of a redundant `TypeAlias` import.
- Noted the removal of a `gguf` debug statement.
- Commented on the presence of `ARCH` and `NDArray` definitions.
- Commented on cleaning up and refactoring data type definitions.

* Refine Model Hyperparameters and Params Class

- Updated type annotations to use `Optional` for clarity.
- Improved method names and attribute consistency.
- Removed unnecessary variables for better code readability.

Additional Notes:

- Highlighted the use of `Optional` for clearer intent.
- Ensured backward and forward compatibility.

* Restore BpeVocab and SentencePieceVocab classes

- Restored the BpeVocab class for handling BPE tokenization.
- Restored the SentencePieceVocab class for SentencePiece tokenization.

These classes are essential for maintaining the original behavior of the codebase.

* refactor: Standardize vocabulary handling with HfVocab

- Replaced VocabLoader with HfVocab, aligning vocabulary handling across classes.
- Updated initialization of HfVocab with local_files_only=True for AutoTokenizer.
- Introduced optional parameter fname_added_tokens for flexible added token management.
- Streamlined added token handling for clarity and conciseness.
- Maintained special tokens and IDs, enhancing token management.
- Simplified token processing methods for improved readability.
- Added a placeholder for score computation with a default value of -1000.0.
- Optimized newline token check for efficiency.
- Updated __repr__ function for clarity in representation.
- Adjusted type alias Vocab to include BpeVocab, SentencePieceVocab, and HfVocab.
- Removed redundant code related to special token handling, reverse vocabulary mapping, and vocabulary file detection.

This refactoring promotes a standardized and modular approach to vocabulary management, facilitating future integration with a VocabFactory and improving code maintainability and scalability.

* refactor: Enhance readability, functionality, and code quality

- Improved code formatting and readability for better maintainability.
- Refactored LazyUnpickler's CLASSES dictionary for clarity.
- Added print statements and warnings in check_vocab_size for user feedback.
- Removed find_vocab_file_path, as it's superseded by VocabFactory.
- Preparatory changes for upcoming classes: OutputFile and VocabFactory.
- Overall focus on code quality, error handling, and consistency.

These changes reflect a continuous effort to refine the codebase, ensuring it meets best practices and prepares for future enhancements, such as the VocabFactory.

* refactor: Update OutputFile class for enhanced model vocabulary management

- Restructured the constructor for improved readability.
- Updated `add_meta_arch` method for flexible model name determination.
- Introduced `handle_tokenizer_model` for mapping vocab types to supported tokenizer models.
- Streamlined vocabulary extraction with `extract_vocabulary_from_model`.
- Simplified vocabulary metadata addition using `add_meta_vocab`.
- Refactored `add_tensor_info` for clarity and consistency.
- Improved error handling for better user feedback.

These changes signify the development of a versatile and comprehensive `OutputFile` class, enabling efficient management of model conversion output, metadata, vocabulary, and tensor information.

* feat: Introduce VocabFactory for flexible vocabulary management in model conversion

- The VocabFactory class is added to facilitate modular vocabulary handling.
- The constructor initializes a directory path and detects vocabulary-related files.
- The _select_file method provides file paths based on vocabulary type (e.g., BPE, SentencePiece).
- _create_special_vocab generates special vocabularies, accommodating different types.
- The load_vocab method loads vocabularies, handling BPE, SentencePiece, and Hugging Face Fast Tokenizer.
- Error handling and logging enhance debugging and user feedback.
- The modular and flexible design simplifies vocabulary management and supports future extensions.

The VocabFactory class enhances code modularity and maintainability, allowing versatile vocabulary handling in the model conversion process.

* refactor: Improve code organization, argument parsing, and user interface

- Renamed 'default_outfile' to 'default_output_file' for clarity.
- Refactored argument parser setup into 'get_argument_parser' function.
- Introduced descriptive comments for each argument in the parser.
- Added '--vocab-type' argument with choices ["spm", "bpe", "hfft"] for vocabulary processing.
- Improved flag naming consistency: '--outfile' to '--out-file' and '--bigendian' to '--big-endian'.
- Enhanced error handling to prevent overwriting input data in 'default_output_file'.
- Made 'argv' in 'main' an optional parameter for flexibility.
- Introduced dynamic import for 'awq.apply_awq' based on 'args.awq_path' for conditional dependency.

These changes enhance code clarity, organization, and the user interface of the script, aligning it with Python best practices and improving maintainability.

* refactor: Further refine functionality, improve user interaction, and streamline vocabulary handling

- Renamed command-line arguments for clarity and consistency.
- Improved path resolution and import adjustments for robustness.
- Thoughtfully handled 'awq-path' and conditional logic for the weighted model.
- Enhanced model and vocabulary loading with the 'VocabFactory' class for structured and adaptable loading.
- Strengthened error handling and user feedback for a more user-friendly experience.
- Structured output file handling with clear conditions and defaults.
- Streamlined and organized the 'main' function for better logic flow.
- Passed 'sys.argv[1:]' to 'main' for adaptability and testability.

These changes solidify the script's functionality, making it more robust, user-friendly, and adaptable. The use of the 'VocabFactory' class is a notable enhancement in efficient vocabulary handling, reflecting a thoughtful and iterative approach to script development.

* chore: Apply ruff formatting to convert.py

Signed-off-by: teleprint-me <redacted>
* Revert to commit 0614c33

* chore: Apply flake8 formatting rules

Signed-off-by: teleprint-me <redacted>
* refactor: Revise `check_vocab_size` for Enhanced Clarity and Correctness

- Resolved an unreachable branch issue by reorganizing the conditional structure.
- Moved the special case check for `params.n_vocab == -1` to the top for immediate assertion.
- Flattened the conditional logic for improved clarity and predictability of the function's behavior.

These changes enhance the readability and functional correctness of the `check_vocab_size` function without altering its intended functionality.

* py : fix outfile and outtype

* py : suggest hint for missing vocab size

---------

Signed-off-by: teleprint-me <redacted>
Co-authored-by: Georgi Gerganov <redacted>
17 months agollava-cli : don't crash if --image flag is invalid (#4835)
Justine Tunney [Tue, 9 Jan 2024 17:59:14 +0000 (09:59 -0800)]
llava-cli : don't crash if --image flag is invalid (#4835)

This change fixes an issue where supplying `--image missing-file` would
result in a segfault due to a null pointer being dereferenced. This can
result in distracting info being printed if robust crash analysis tools
are being used.