]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/log
pkg/ggml/sources/llama.cpp
9 months agoreadme : add LLMUnity to UI projects (#9381)
Antonis Makropoulos [Mon, 9 Sep 2024 11:21:38 +0000 (14:21 +0300)]
readme : add LLMUnity to UI projects (#9381)

* add LLMUnity to UI projects

* add newline to examples/rpc/README.md to fix editorconfig-checker unit test

9 months agorpc : update README [no ci] (#9320)
Radoslav Gerganov [Mon, 9 Sep 2024 08:04:39 +0000 (11:04 +0300)]
rpc : update README [no ci] (#9320)

Update README with instructions how to offload model layers to both
local and remote devices

9 months agoArm AArch64: Documentation updates (#9321)
Dan Johansson [Mon, 9 Sep 2024 07:02:45 +0000 (09:02 +0200)]
Arm AArch64: Documentation updates (#9321)

* Arm AArch64: Documentation updates

* Update docs/build.md to include information on how to enable the Arm optimized gemm/gemv kernels

* Update examples/quantize/README.md with information on the Q4_0_4_4, Q4_0_4_8 and Q4_0_8_8 formats

* Add newline to the end of docs/build.md

9 months agoOverlap cmdbuffer creation and cmdbuffer execution in Vulkan backend by submitting...
Markus Tavenrath [Sun, 8 Sep 2024 19:43:48 +0000 (21:43 +0200)]
Overlap cmdbuffer creation and cmdbuffer execution in Vulkan backend by submitting smaller cmdbuffers early. (#9118)

* Overlap cmdbuffer creation and cmdbuffer execution in Vulkan backend by submitting smaller cmdbuffers early.

* fix compile issues

* Fix issues where the last submit wasn't executed or handled properly.

* remove trailing whitespace

* Repair GGML_VULKAN_CHECK_RESULTS

* Increase submit counter only if actual work has been submitted and increase submit count to 100.

* Fix some nodes are not checked with GGML_VULKAN_CHECK_RESULTS enabled.

9 months agocuda : fix FA Q src index (1 -> 0) (#9374)
Georgi Gerganov [Sun, 8 Sep 2024 19:01:02 +0000 (22:01 +0300)]
cuda : fix FA Q src index (1 -> 0) (#9374)

9 months agocommon : bring back missing args, add env var duplication check (#9375)
Xuan Son Nguyen [Sun, 8 Sep 2024 16:08:55 +0000 (18:08 +0200)]
common : bring back missing args, add env var duplication check (#9375)

* common : bring back missing args

* move duplication check to test-arg-parser

* add check for duplicated env var

* correct default values

9 months agocommon : restore --n-gpu-layers (#9371)
slaren [Sun, 8 Sep 2024 14:44:42 +0000 (16:44 +0200)]
common : restore --n-gpu-layers (#9371)

9 months agollama : refactor samplers internal implementation (#9370)
slaren [Sun, 8 Sep 2024 13:52:07 +0000 (15:52 +0200)]
llama : refactor samplers internal implementation (#9370)

9 months ago[SYCL] add check malloc result on device (#9346)
Neo Zhang Jianyu [Sun, 8 Sep 2024 11:05:29 +0000 (19:05 +0800)]
[SYCL] add check malloc result on device (#9346)

* add check malloc result on device

* update for review comments, check all malloc_device() result

---------

Co-authored-by: arthw <redacted>
9 months agollama : sanitize tokens in the upper bound (#9359)
slaren [Sun, 8 Sep 2024 10:41:51 +0000 (12:41 +0200)]
llama : sanitize tokens in the upper bound (#9359)

9 months agoimatrix : fix arg parser for imatrix (#9366)
Xuan Son Nguyen [Sun, 8 Sep 2024 10:12:17 +0000 (12:12 +0200)]
imatrix : fix arg parser for imatrix (#9366)

* imatrix : fix arg parser

* beautify printing first arg

9 months agometal : update support condition for im2col + fix warning (#0)
Georgi Gerganov [Sun, 8 Sep 2024 06:57:57 +0000 (09:57 +0300)]
metal : update support condition for im2col + fix warning (#0)

9 months agosync : ggml
Georgi Gerganov [Sun, 8 Sep 2024 06:38:56 +0000 (09:38 +0300)]
sync : ggml

9 months agoscripts : option to increase git patch context
Georgi Gerganov [Sun, 8 Sep 2024 06:38:42 +0000 (09:38 +0300)]
scripts : option to increase git patch context

9 months agovulkan: add dryrun support to sin and cos ops (ggml/947)
Salvatore Mesoraca [Fri, 6 Sep 2024 12:34:25 +0000 (14:34 +0200)]
vulkan: add dryrun support to sin and cos ops (ggml/947)

sin and cos failed test-backend-ops because they
tried to dereference a context pointer that is null
on dry runs.

This commit prevents that segfault.

Signed-off-by: Salvatore Mesoraca <redacted>
9 months agovulkan: correctly report support for OP_CONT (ggml/946)
Salvatore Mesoraca [Fri, 6 Sep 2024 12:34:07 +0000 (14:34 +0200)]
vulkan: correctly report support for OP_CONT (ggml/946)

test-backend-ops fails because ggml_cont aborts
when invoked passing an unsupported type.

This commit makes ggml_cont tests pass

Signed-off-by: Salvatore Mesoraca <redacted>
9 months agotests: add gradient tests for all backends (ggml/932)
Johannes Gäßler [Tue, 3 Sep 2024 15:21:46 +0000 (17:21 +0200)]
tests: add gradient tests for all backends (ggml/932)

* tests: add gradient checking to test-backend-ops

* remove old comment

* reorder includes

* adjust SIN/COS parameters

* add documentation, use supports_op if possible

9 months agoggml: fix ggml_graph_cpy undefined behavior (ggml/943)
Johannes Gäßler [Sat, 31 Aug 2024 12:35:42 +0000 (14:35 +0200)]
ggml: fix ggml_graph_cpy undefined behavior (ggml/943)

9 months agocann : fix doxy (ggml/0)
Georgi Gerganov [Wed, 28 Aug 2024 15:45:01 +0000 (18:45 +0300)]
cann : fix doxy (ggml/0)

9 months agocann : add Ascend NPU support (whisper/2336)
Mengqing Cao [Fri, 9 Aug 2024 12:21:56 +0000 (20:21 +0800)]
cann : add Ascend NPU support (whisper/2336)

* enable Ascend NPU in src/whisper.cpp
  * sync test-backend-ops with llama.cpp

9 months agocuda : mark BF16 CONT as unsupported
Georgi Gerganov [Wed, 28 Aug 2024 14:08:03 +0000 (17:08 +0300)]
cuda : mark BF16 CONT as unsupported

9 months agoggml : fix cont with transposed tensors when one dimension is 1 (ggml/934)
Salvatore Mesoraca [Wed, 28 Aug 2024 08:23:02 +0000 (10:23 +0200)]
ggml : fix cont with transposed tensors when one dimension is 1 (ggml/934)

* ggml_cont: fix issue with transposed tensors when one dimension is 1

when using multiple threads, it is not enough
to check for the tensors to be contiguous for
ggml_compute_forward_dup_same_cont to work correctly.
The tensors strides also need to match.

Signed-off-by: Salvatore Mesoraca <redacted>
* Add ggml_cont tests

Signed-off-by: Salvatore Mesoraca <redacted>
* Remove dead code

it isn't possible to reach this code because
all these functions are invoked by ggml_compute_forward_dup
if and only if src0->type != dst->type

Signed-off-by: Salvatore Mesoraca <redacted>
* Make ggml_compute_forward_dup_same_cont work with contiguous tensors

Co-authored-by: Georgi Gerganov <redacted>
Signed-off-by: Salvatore Mesoraca <redacted>
---------

Signed-off-by: Salvatore Mesoraca <redacted>
Co-authored-by: Georgi Gerganov <redacted>
9 months agollama : set attrs of mislabelled EOT/EOM tokens (#9348)
Kevin Gibbons [Sun, 8 Sep 2024 05:51:00 +0000 (22:51 -0700)]
llama : set attrs of mislabelled EOT/EOM tokens (#9348)

9 months agollama.android : fix build (#9350)
Georgi Gerganov [Sat, 7 Sep 2024 21:33:50 +0000 (00:33 +0300)]
llama.android : fix build (#9350)

9 months agollama : fix empty ring buffer push (#9358)
Georgi Gerganov [Sat, 7 Sep 2024 21:33:33 +0000 (00:33 +0300)]
llama : fix empty ring buffer push (#9358)

9 months agollama : sanitize invalid tokens (#9357)
Georgi Gerganov [Sat, 7 Sep 2024 21:33:13 +0000 (00:33 +0300)]
llama : sanitize invalid tokens (#9357)

* common : do not add null tokens during warmup

ggml-ci

* llama : check that the input tokens are valid

ggml-ci

* tests : fix batch size of bert model

ggml-ci

9 months agollamafile : disable sgemm for batch-size 1 (#9330)
Eve [Sat, 7 Sep 2024 19:02:26 +0000 (19:02 +0000)]
llamafile : disable sgemm for batch-size 1 (#9330)

9 months agocommon : refactor arg parser (#9308)
Xuan Son Nguyen [Sat, 7 Sep 2024 18:43:51 +0000 (20:43 +0200)]
common : refactor arg parser (#9308)

* (wip) argparser v3

* migrated

* add test

* handle env

* fix linux build

* add export-docs example

* fix build (2)

* skip build test-arg-parser on windows

* update server docs

* bring back missing --alias

* bring back --n-predict

* clarify test-arg-parser

* small correction

* add comments

* fix args with 2 values

* refine example-specific args

* no more lamba capture

Co-authored-by: slaren@users.noreply.github.com
* params.sparams

* optimize more

* export-docs --> gen-docs

9 months agoggml : always check bounds on get_rows operations (#9354)
slaren [Sat, 7 Sep 2024 18:23:07 +0000 (20:23 +0200)]
ggml : always check bounds on get_rows operations (#9354)

9 months agollama : refactor sampling v2 (#9294)
Georgi Gerganov [Sat, 7 Sep 2024 12:16:19 +0000 (15:16 +0300)]
llama : refactor sampling v2 (#9294)

- Add `struct llama_sampler` and `struct llama_sampler_i`
- Add `llama_sampler_` API
- Add `llama_sampler_chain_` API for chaining multiple samplers
- Remove `LLAMA_API_INTERNAL`
- Add `llama_perf_` API and remove old `llama_print_timings` and `llama_reset_timings`

9 months agoggml : fix missing `cpu_set_t` on emscripten (#9336)
Xuan Son Nguyen [Sat, 7 Sep 2024 10:01:34 +0000 (12:01 +0200)]
ggml : fix missing `cpu_set_t` on emscripten (#9336)

* ggml : fix missing cpu_set_t on emscripten

* better version

* bring back android part

9 months agoci : disable rocm image creation (#9340)
slaren [Sat, 7 Sep 2024 07:48:54 +0000 (09:48 +0200)]
ci : disable rocm image creation (#9340)

9 months agoserver : simplify state machine for slot (#9283)
Xuan Son Nguyen [Fri, 6 Sep 2024 21:21:29 +0000 (23:21 +0200)]
server : simplify state machine for slot (#9283)

* server : simplify state machine for slot

* add SLOT_STATE_DONE_PROMPT

* pop_deferred_task

* add missing notify_one

* fix passkey test

* metrics : add n_busy_slots_per_decode

* fix test step

* add test

* maybe fix AddressSanitizer?

* fix deque ?

* missing lock

* pop_deferred_task: also notify

* Update examples/server/server.cpp

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

Co-authored-by: Georgi Gerganov <redacted>
9 months agollama-bench : log benchmark progress (#9287)
Aarni Koskela [Fri, 6 Sep 2024 21:03:01 +0000 (00:03 +0300)]
llama-bench : log benchmark progress (#9287)

* llama-bench : add optional progress messages

9 months agobatched-bench : add `--output-format jsonl` option (#9293)
Aarni Koskela [Fri, 6 Sep 2024 15:59:58 +0000 (18:59 +0300)]
batched-bench : add `--output-format jsonl` option (#9293)

`--output-format` is modeled after `llama-bench`'s options

9 months agoggml : fix build break for the vulkan-debug (#9265)
Changyeon Kim [Fri, 6 Sep 2024 12:54:50 +0000 (21:54 +0900)]
ggml : fix build break for the vulkan-debug (#9265)

- windows build : Ok.
- linux build : Ok.

Signed-off-by: Changyeon Kim <redacted>
9 months agoserver : fix missing lock (#9334)
Xuan Son Nguyen [Fri, 6 Sep 2024 12:06:04 +0000 (14:06 +0200)]
server : fix missing lock (#9334)

9 months agoImprove Vulkan shader build system (#9239)
Markus Tavenrath [Fri, 6 Sep 2024 06:56:17 +0000 (08:56 +0200)]
Improve Vulkan shader build system (#9239)

* Improve Vulkan shader builds system

- Add dependency to vulkan-shaders-gen to rebuild shaders when changing the shader compilation utility.
- Add option to generate debug info for Vulkan shaders to provide shader source to Vulkan shader profiling tools

* remove not required self dependency

9 months agoggml-quants : ternary packing for TriLMs and BitNet b1.58 (#8151)
compilade [Fri, 6 Sep 2024 01:48:47 +0000 (21:48 -0400)]
ggml-quants : ternary packing for TriLMs and BitNet b1.58 (#8151)

* ggml-quants : 1.625 bpw ternary packing for BitNet 1.58b

* ggml-quants : faster 1.625 bpw AVX2 vec_dot

Not using a lookup table anymore makes it match q4_0 speed.

* gguf-py : fix formatting

* llama : remove spaces on empty line

* ggml-quants : subtract 1 when back in epi8

This makes the 1.625 bpw type go faster than q4_0. Still not the fastest.

* ggml-quants : Q2_2 now faster than Q4_K on with AVX2

* ggml-quants : cleanup Q1_3 code formatting

* ggml-quants : ARM NEON vec_dot for q2_2 and q1_3

* ggml-quants : use ceiling division when quantizing q1_3

* convert-hf : simplify BitNet pre-quantization

This still results in the exact same tensor weights and scales,
but it reveals some weirdness in the current algorithm.

* convert-hf : allow converting the weird BitNet 1.3B

Its FFN size is 5460 which is not convenient.
The offending tensors are kept in F16,
which makes the final model 5.01 bpw.

* bitnet : replace 1.58b with b1.58, as in the paper

* ggml-quants : fix build failure on Windows

* ggml-quants : attempt to fix Arm 32-bit support

* ggml : add some informative comments in q1_3 vec_dot

* ggml : add TQ1_0 and TQ2_0 ternary quantization types

* ggml : even faster TQ2_0

* ggml : also faster TQ1_0

Same optimization as for TQ2_0 by offsetting the sum instead of the weights.
This makes TQ1_0 almost as fast as Q8_0 on AVX2.

* ggml : fix build issues in certain environments

* ggml : add NEON vec_dot implementation for TQ1_0 and TQ2_0

* ggml : avoid directly using vmlal_high_s8, for 32-bit ARM compat

The compiler seems smart enough to use the same instruction
even when using vget_high_s8 instead.

* ggml : remove q1_3 and q2_2

No more 1.625 bpw and 2.000 bpw,
now instead using 1.6875 bpw and 2.0625 bpw
with TQ1_0 and TQ2_0, respectively.

* llama : remove the separate scale tensors of BitNet b1.58

They won't be needed, since the remaining ternary quant types have
built-in scales.

* ggml-quants : rename fields of TQ1_0 and TQ2_0 structs for consistency

* ggml-quants : allow using vdotq_s32 in TQ2_0 vec_dot

Not yet tested on hardware which supports it,
might not work or might not even compile. But also it might.
It should make the performance better on recent ARM CPUs.

* ggml-quants : remove comment about possible format change of TQ2_0

Making it slightly more convenient for AVX512
but less convenient for everything else is not worth the trouble.

* gguf-py : Numpy (de)quantization for TQ1_0 and TQ2_0

* ggml-quants : use roundf instead of nearest_int for TQ1_0 and TQ2_0

This does not change anything for ternary models,
since their values should never end up being in halfway cases anyway.

* convert : allow direct conversion to TQ1_0 and TQ2_0

The token embeddings and output tensors are kept in F16
to allow quantizing them to Q4_K and Q6_K with llama-quantize.

* llama : handle fallback for TQ1_0 and TQ2_0 with Q4_0

Q4_0 is not completely symmetric (so not lossless for ternary models),
but it should be good enough.

* ggml-quants : allow using ARM dot product instructions for TQ1_0

* ggml-quants : deduplicate TQ1_0 and TQ2_0 __ARM_FEATURE_DOTPROD support

* ggml : remove unused ggml_mul special case

It would otherwise conflict with the more general
optimization coming with Mamba-2.

* ggml : handle TQ1_0 and TQ2_0 in dequantization-based operators

* test-backend-ops : add TQ1_0 and TQ2_0 comments for later

Not yet adding uncommented, because some backends like SYCL and Metal
do not properly handle unknown types in supports_op for GGML_OP_MUL_MAT.
(and Metal also doesn't handle it with GGML_OP_GET_ROWS)
Support for TQ1_0 and TQ2_0 for other backends than CPU
will be added in follow-up pull requests.

9 months agoUpdate build.yml (#9184)
awatuna [Thu, 5 Sep 2024 22:34:36 +0000 (06:34 +0800)]
Update build.yml (#9184)

build rpc-server for windows cuda

9 months agoCMake fix: host for msvc compiler can only be x86 or x64 (#8624)
Michael Podvitskiy [Thu, 5 Sep 2024 22:14:12 +0000 (00:14 +0200)]
CMake fix: host for msvc compiler can only be x86 or x64 (#8624)

9 months agocuda : fix defrag with quantized KV (#9319)
slaren [Thu, 5 Sep 2024 09:13:11 +0000 (11:13 +0200)]
cuda : fix defrag with quantized KV (#9319)

9 months agollama-bench : fix NUL terminators in CPU name (#9313)
slaren [Thu, 5 Sep 2024 00:19:39 +0000 (02:19 +0200)]
llama-bench : fix NUL terminators in CPU name (#9313)

9 months agoggml : AVX2 support for Q4_0_8_8 (#8713)
Srihari-mcw [Wed, 4 Sep 2024 16:51:22 +0000 (22:21 +0530)]
ggml : AVX2 support for Q4_0_8_8 (#8713)

* Add AVX2 based implementations for quantize_q8_0_4x8, ggml_gemv_q4_0_8x8_q8_0 and ggml_gemm_q4_0_8x8_q8_0 functions

* Update code to fix issues occuring due to non alignment of elements to be processed as multiple of 16 in MSVC

* Update comments and indentation

* Make updates to reduce number of load instructions

9 months ago[SYCL] Fix DMMV dequantization (#9279)
Ouadie EL FAROUKI [Wed, 4 Sep 2024 15:26:33 +0000 (16:26 +0100)]
[SYCL] Fix DMMV dequantization (#9279)

Fixed dmmv dequant for ncols== GGML_SYCL_DMMV_X

9 months agoFix broken links in docker.md (#9306)
杨朱 · Kiki [Wed, 4 Sep 2024 11:45:28 +0000 (19:45 +0800)]
Fix broken links in docker.md (#9306)

9 months agorpc : make RPC servers come first in the device list (#9296)
Radoslav Gerganov [Wed, 4 Sep 2024 08:08:32 +0000 (11:08 +0300)]
rpc : make RPC servers come first in the device list (#9296)

* rpc : make RPC servers come first in the device list

* rpc : disable options for non-RPC builds

* rpc : rpc_count always zero for non-RPC builds

9 months agoreadme : rename result_format to response_format (#9300)
Pascal Patry [Wed, 4 Sep 2024 06:45:40 +0000 (02:45 -0400)]
readme : rename result_format to response_format (#9300)

9 months agoflake.lock: Update (#9261)
Georgi Gerganov [Tue, 3 Sep 2024 23:36:43 +0000 (02:36 +0300)]
flake.lock: Update (#9261)

Flake lock file updates:

• Updated input 'flake-parts':
    'github:hercules-ci/flake-parts/8471fe90ad337a8074e957b69ca4d0089218391d?narHash=sha256-XOQkdLafnb/p9ij77byFQjDf5m5QYl9b2REiVClC%2Bx4%3D' (2024-08-01)
  → 'github:hercules-ci/flake-parts/af510d4a62d071ea13925ce41c95e3dec816c01d?narHash=sha256-ODYRm8zHfLTH3soTFWE452ydPYz2iTvr9T8ftDMUQ3E%3D' (2024-08-30)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/c374d94f1536013ca8e92341b540eba4c22f9c62?narHash=sha256-Z/ELQhrSd7bMzTO8r7NZgi9g5emh%2BaRKoCdaAv5fiO0%3D' (2024-08-21)
  → 'github:NixOS/nixpkgs/71e91c409d1e654808b2621f28a327acfdad8dc2?narHash=sha256-GnR7/ibgIH1vhoy8cYdmXE6iyZqKqFxQSVkFgosBh6w%3D' (2024-08-28)

Co-authored-by: github-actions[bot] <redacted>
9 months agollama-bench : add JSONL (NDJSON) output mode (#9288)
Aarni Koskela [Tue, 3 Sep 2024 17:58:54 +0000 (20:58 +0300)]
llama-bench : add JSONL (NDJSON) output mode (#9288)

* llama-bench : add JSONL (NDJSON) output mode

* llama-bench : update usage docs

9 months agoreadme : refactor API section + remove old hot topics
Georgi Gerganov [Tue, 3 Sep 2024 07:00:36 +0000 (10:00 +0300)]
readme : refactor API section + remove old hot topics

9 months agoserver : test script : add timeout for all requests (#9282)
Xuan Son Nguyen [Mon, 2 Sep 2024 20:08:38 +0000 (22:08 +0200)]
server : test script : add timeout for all requests (#9282)

9 months agosrc: make tail invalid when kv cell is intersection for mamba (#9249)
Zhenwei Jin [Mon, 2 Sep 2024 17:53:23 +0000 (01:53 +0800)]
src: make tail invalid when kv cell is intersection for mamba (#9249)

9 months agodocker : fix missing binaries in full-cuda image (#9278)
slaren [Mon, 2 Sep 2024 16:11:13 +0000 (18:11 +0200)]
docker : fix missing binaries in full-cuda image (#9278)

9 months agoggml : add pthread includes on FreeBSD (#9258)
yuri@FreeBSD [Mon, 2 Sep 2024 15:25:30 +0000 (08:25 -0700)]
ggml : add pthread includes on FreeBSD (#9258)

9 months agoserver : refactor multitask handling (#9274)
Xuan Son Nguyen [Mon, 2 Sep 2024 15:11:51 +0000 (17:11 +0200)]
server : refactor multitask handling (#9274)

* server : remove multitask from server_task

* refactor completions handler

* fix embeddings

* use res_ok everywhere

* small change for handle_slots_action

* use unordered_set everywhere

* (try) fix test

* no more "mutable" lambda

* Apply suggestions from code review

Co-authored-by: Georgi Gerganov <redacted>
* use deque

---------

Co-authored-by: Georgi Gerganov <redacted>
9 months agollama-cli : remove duplicated log message (#9275)
Guoliang Hua [Mon, 2 Sep 2024 12:36:43 +0000 (20:36 +0800)]
llama-cli : remove duplicated log message (#9275)

9 months agobuild(nix): Package gguf-py (#5664)
Tushar [Mon, 2 Sep 2024 11:21:01 +0000 (16:51 +0530)]
build(nix): Package gguf-py (#5664)

* style: format with nixfmt/rfc101-style

* build(nix): Package gguf-py

* build(nix): Refactor to new scope for gguf-py

* build(nix): Exclude gguf-py from devShells

* build(nix): Refactor gguf-py derivation to take in exact deps

* build(nix): Enable pytestCheckHook and pythonImportsCheck for gguf-py

* build(python): Package python scripts with pyproject.toml

* chore: Cleanup

* dev(nix): Break up python/C devShells

* build(python): Relax pytorch version constraint

Nix has an older version

* chore: Move cmake to nativeBuildInputs for devShell

* fmt: Reconcile formatting with rebase

* style: nix fmt

* cleanup: Remove unncessary __init__.py

* chore: Suggestions from review

- Filter out non-source files from llama-scripts flake derivation
- Clean up unused closure
- Remove scripts devShell

* revert: Bad changes

* dev: Simplify devShells, restore the -extra devShell

* build(nix): Add pyyaml for gguf-py

* chore: Remove some unused bindings

* dev: Add tiktoken to -extra devShells

9 months agollama : minor style
Georgi Gerganov [Mon, 2 Sep 2024 08:52:04 +0000 (11:52 +0300)]
llama : minor style

9 months agollama : support RWKV v6 models (#8980)
Molly Sophia [Sun, 1 Sep 2024 14:38:17 +0000 (22:38 +0800)]
llama : support RWKV v6 models (#8980)

* convert_hf_to_gguf: Add support for RWKV v6

Signed-off-by: Molly Sophia <redacted>
* Add RWKV tokenization

* Fix build

Signed-off-by: Molly Sophia <redacted>
* Do not use special tokens when matching in RWKV tokenizer

* Fix model loading

* Add (broken) placeholder graph builder for RWKV

* Add workaround for kv cache

* Add logits conversion to rwkv5

* Add rwkv5 layer norms

* Add time mix KVRG & correct merge mistake

* Add remaining time mix parameters

* Add time mix output loading

* Add placeholder llm_build_time_mix

* Fix build

Signed-off-by: Molly Sophia <redacted>
* Load more tensors for rwkv v6

Signed-off-by: Molly Sophia <redacted>
* Fix rwkv tokenizer

Signed-off-by: Molly Sophia <redacted>
* ggml: Add unary operator Exp

Signed-off-by: Molly Sophia <redacted>
* RWKV v6 graph building

Signed-off-by: Molly Sophia <redacted>
* Add ``rescale_every_n_layers`` parameter

Signed-off-by: Molly Sophia <redacted>
* Add ``wkv.head_size`` key for RWKV

so it doesn't reuse Mamba ssm parameters

Signed-off-by: Molly Sophia <redacted>
* Fix offloading layers to CUDA

Signed-off-by: Molly Sophia <redacted>
* Fix parallel inferencing for RWKV

Signed-off-by: Molly Sophia <redacted>
* Remove trailing whitespaces

Signed-off-by: Molly Sophia <redacted>
* build_rwkv: Avoid using inplace operations

Signed-off-by: Molly Sophia <redacted>
* convert_hf_to_gguf: rwkv: Avoid using ``eval``

Signed-off-by: Molly Sophia <redacted>
* convert_hf_to_gguf: rwkv tokenizer: Don't escape sequences manually

Signed-off-by: Molly Sophia <redacted>
* Update convert_hf_to_gguf.py

Co-authored-by: compilade <redacted>
* ggml: Add backward computation for unary op ``exp``

Signed-off-by: Molly Sophia <redacted>
* Update convert_hf_to_gguf.py

Co-authored-by: compilade <redacted>
* Update convert_hf_to_gguf.py

Co-authored-by: compilade <redacted>
* Use MODEL_ARCH.RWKV6 instead of MODEL_ARCH.RWKV

Signed-off-by: Molly Sophia <redacted>
* build_rwkv6: Simplify graph

Signed-off-by: Molly Sophia <redacted>
* llama: rwkv6: Detect model.type

Signed-off-by: Molly Sophia <redacted>
* llama: rwkv6: Fix tensor loading for 7B/14B models

Signed-off-by: Molly Sophia <redacted>
* llama: rwkv6: Fix group_norm assertion failure with Metal

Signed-off-by: Molly Sophia <redacted>
* llama: rwkv6: Clean up

Signed-off-by: Molly Sophia <redacted>
* llama: rwkv6: Add quantization tensor exclusion

Signed-off-by: Molly Sophia <redacted>
* llama: rwkv6: Use the new advanced batch splits

Signed-off-by: Molly Sophia <redacted>
* Update src/llama.cpp

Co-authored-by: compilade <redacted>
* llama: rwkv6: Use ``ggml_norm`` instead of ``ggml_group_norm``

Co-authored-by: compilade <redacted>
* llama: rwkv6: Apply code style and misc changes

Signed-off-by: Molly Sophia <redacted>
* converter: Use class name ``Rwkv6Model``

Signed-off-by: Molly Sophia <redacted>
* llama: rwkv6: Make use of key ``feed_forward_length``

Signed-off-by: Molly Sophia <redacted>
* llama: rwkv6: Add kv ``time_mix_extra_dim`` and ``time_decay_extra_dim``

Signed-off-by: Molly Sophia <redacted>
* converter: Match ``new_name`` instead of ``name`` for float32 explicit tensors

Signed-off-by: Molly Sophia <redacted>
* llama: rwkv6: Keep ``time_mix_w1/w2`` as F32

Signed-off-by: Molly Sophia <redacted>
* llama: rwkv6: Remove unused nodes

Signed-off-by: Molly Sophia <redacted>
* llama: rwkv6: Apply code format changes

Signed-off-by: Molly Sophia <redacted>
* llama: rwkv6: Add lora for some supported tensors

Currently att.key/receptance/value/gate/output, ffn.receptance/key/value, as well as head.weight

Signed-off-by: Molly Sophia <redacted>
* rwkv : speed-up tokenization using trie

* minor : style + indentation

* llama: rwkv6: Avoid division by zero

Co-authored-by: compilade <redacted>
* ggml: rwkv_wkv: Avoid copying the state

Signed-off-by: Molly Sophia <redacted>
---------

Signed-off-by: Molly Sophia <redacted>
Co-authored-by: Layl Bongers <redacted>
Co-authored-by: compilade <redacted>
Co-authored-by: Georgi Gerganov <redacted>
9 months agonix: fix CUDA build - replace deprecated autoAddOpenGLRunpathHook
Echo Nolan [Thu, 22 Aug 2024 21:19:14 +0000 (17:19 -0400)]
nix: fix CUDA build - replace deprecated autoAddOpenGLRunpathHook

The CUDA nix build broke when we updated nixpkgs in
8cd1bcfd3fc9f2b5cbafd7fb7581b3278acec25f. As far as I can tell all
that happened is cudaPackages.autoAddOpenGLRunpathHook got moved to
pkgs.autoAddDriverRunpath. This commit fixes it.

9 months agosgemm : improved Q4_0 and Q8_0 performance via 4xN and Mx4 gemm (#8908)
Srihari-mcw [Sat, 31 Aug 2024 08:20:35 +0000 (13:50 +0530)]
sgemm : improved Q4_0 and Q8_0 performance via 4xN and Mx4 gemm (#8908)

9 months agollama : fix typo in xcda_array_view comment [no ci] (#9132)
Daniel Bevenius [Sat, 31 Aug 2024 07:50:22 +0000 (09:50 +0200)]
llama : fix typo in xcda_array_view comment [no ci] (#9132)

9 months agollama : fix llama_split_mode enum values in main_gpu document (#9057)
Sutou Kouhei [Fri, 30 Aug 2024 18:08:10 +0000 (03:08 +0900)]
llama : fix llama_split_mode enum values in main_gpu document (#9057)

LLAMA_SPLIT_* were renamed to LLAMA_SPLIT_MODE_* in #5697.

9 months agoCorrect typo run_llama2.sh > run-llama2.sh (#9149)
蕭澧邦 [Fri, 30 Aug 2024 12:10:01 +0000 (20:10 +0800)]
Correct typo run_llama2.sh > run-llama2.sh (#9149)

10 months agollava : the function "clip" should be int (#9237)
tc-mb [Fri, 30 Aug 2024 05:21:57 +0000 (13:21 +0800)]
llava : the function "clip" should be int (#9237)

10 months agoThreadpool: take 2 (#8672)
Faisal Zaghloul [Thu, 29 Aug 2024 23:20:53 +0000 (19:20 -0400)]
Threadpool: take 2 (#8672)

* Introduce ggml_compute_threadpool

- OpenMP functional: check
- Vanilla ggml functional: Check
- ggml w/threadpool functional: Check
- OpenMP no regression: No glaring problems
- Vanilla ggml no regression: No glaring problems
- ggml w/threadpool no regression: No glaring problems

* Minor fixes

* fixed use after release bug

* fixed a harmless race condition

* Fix Android bulid issue

* fix more race conditions

* fix deadlock for cases where cgraph.n_nodes == 1

and fix --poll case

* threadpool: use cpu_get_num_math to set the default number of threadpool threads

This way we avoid using E-Cores and Hyperthreaded siblings.

* bench: create fresh threadpool for each test

For benchmarking it's better to start a fresh pool for each test with the exact number of threads
needed for that test. Having larger pools is suboptimal (causes more load, etc).

* atomics: always use stdatomics with clang and use relaxed memory order when polling in ggml_barrier

This also removes sched_yield() calls from ggml_barrier() to match OpenMP behavior.

* threadpool: make polling the default to match openmp behavior

All command line args now allow for setting poll to 0 (false).

* threadpool: do not wakeup threads in already paused threadpool

* fix potential race condition in check_for_work

* threadpool: do not create two threadpools if their params are identical

* threadpool: reduce pause/resume/wakeup overhead in common cases

We now start threadpool in paused state only if we have two.
The resume is now implicit (ie new work) which allows for reduced locking and context-switch overhead.

* threadpool: add support for hybrid polling

poll params (--poll, ...) now specify "polling level", i.e. how aggresively we poll before waiting on cond.var.
poll=0 means no polling, 1 means poll for 128K rounds then wait, 2 for 256K rounds, ...

The default value of 50 (ie 50x128K rounds) seems like a decent default across modern platforms.
We can tune this further as things evolve.

* threadpool: reduce the number of barrier required

New work is now indicated with an atomic counter that is incremented for
each new graph that needs to be computed.
This removes the need for extra barrier for clearing the "new_work" and
removes the special case for trivial graphs.

* threadpool: remove special-casing for disposable threadpools

With the efficient hybrid polling there is no need to make disposable pools any different.
This simplifies the overall logic and reduces branching.

Include n_threads in debug print for disposable threadpool.

Declare pause and stop flags as atomic_bool
This doesn't actually generate any memory barriers and simply informs
the thread sanitizer that these flags can be written & read by different
threads without locking.

* threadpool: do not clear barrier counters between graphs computes (fixes race with small graphs)

This fixes the race condition with very small graphs where the main thread happens to
start a new graph while the workers are just about to exit from barriers.

* threadpool: use relaxed order for chunk sync

Full memory barrier is an overkill for this since each thread works on different chunk

* threadpool: remove abort_callback from threadpool state

* threadpool: better naming for thread/cpumask releated functions

* threadpool: consistent use of int type for n_threads params

* threadpool: add support for ggml_threadpool_params_default/init

Also removes the need for explicit mask_specified param.
all-zero cpumask means use default (usually inherited) cpu affinity mask.

* threadpool: move typedef into ggml.h

* threadpool: fix apply_priority() function name

* threadpool: fix swift wrapper errors due to n_threads int type cleanup

* threadpool: enable --cpu-mask and other threadpool related options only if threadpool is enabled

* threadpool: replace checks for compute_thread ret code with proper status check

* threadpool: simplify threadpool init logic and fix main thread affinity application

Most of the init code is now exactly the same between threadpool and openmp.

* threadpool: update threadpool resume/pause function names

* threadpool: enable openmp by default for now

* threadpool: don't forget to free workers state when omp is enabled

* threadpool: avoid updating process priority on the platforms that do not require it

On Windows we need to change overall process priority class in order to set thread priorities,
but on Linux, Mac, etc we do not need to touch the overall process settings.

* threadpool: update calling thread prio and affinity only at start/resume

This avoids extra syscalls for each graph_compute()

* llama-bench: turn threadpool params into vectors, add output headers, etc

* llama-bench: add support for cool off between tests --delay

This helps for long running tests on platforms that are thermally limited (phones, laptops, etc).
--delay (disabled by default) introduces the sleep for N seconds before starting each test.

* threadpool: move process priority setting into the apps (bench and cli)

This avoids changing the overall process priority on Windows for the apps
that use ggml/llama.cpp directy.

* threadpool: move all pause/resume logic into ggml

* threadpool: futher api cleanup and prep for future refactoring

All threadpool related functions and structs use ggml_threadpool prefix.

* threadpool: minor indent fixes

* threadpool: improve setprioty error message

* Update examples/llama-bench/llama-bench.cpp

Co-authored-by: slaren <redacted>
* threadpool: fix indent in set_threadpool call

* use int32_t for n_thread type in public llama.cpp API

* threadpool: use _new and _free instead of _create and _release

* fix two more public APIs to use int32_t for n_threads

* build: set _GNU_SOURCE for Adroid

---------

Co-authored-by: Max Krasnyansky <redacted>
Co-authored-by: fmz <redacted>
Co-authored-by: Max Krasnyansky <redacted>
Co-authored-by: slaren <redacted>
10 months agoserver : fix crash when error handler dumps invalid utf-8 json (#9195)
Jan Boon [Tue, 27 Aug 2024 10:28:06 +0000 (18:28 +0800)]
server : fix crash when error handler dumps invalid utf-8 json (#9195)

10 months agoflake.lock: Update (#9162)
Georgi Gerganov [Thu, 29 Aug 2024 04:28:14 +0000 (07:28 +0300)]
flake.lock: Update (#9162)

Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/c3aa7b8938b17aebd2deecf7be0636000d62a2b9?narHash=sha256-med8%2B5DSWa2UnOqtdICndjDAEjxr5D7zaIiK4pn0Q7c%3D' (2024-08-14)
  → 'github:NixOS/nixpkgs/c374d94f1536013ca8e92341b540eba4c22f9c62?narHash=sha256-Z/ELQhrSd7bMzTO8r7NZgi9g5emh%2BaRKoCdaAv5fiO0%3D' (2024-08-21)

Co-authored-by: github-actions[bot] <redacted>
10 months agodocker : build images only once (#9225)
slaren [Wed, 28 Aug 2024 15:28:00 +0000 (17:28 +0200)]
docker : build images only once (#9225)

10 months agodocker : update CUDA images (#9213)
slaren [Wed, 28 Aug 2024 11:20:36 +0000 (13:20 +0200)]
docker : update CUDA images (#9213)

10 months agovulkan : fix build (#0)
Georgi Gerganov [Tue, 27 Aug 2024 19:10:58 +0000 (22:10 +0300)]
vulkan : fix build (#0)

ggml-ci

10 months agosync : ggml
Georgi Gerganov [Tue, 27 Aug 2024 19:01:45 +0000 (22:01 +0300)]
sync : ggml

10 months agoFix minicpm example directory (#9111)
Xie Yanbo [Tue, 27 Aug 2024 12:33:08 +0000 (20:33 +0800)]
Fix minicpm example directory (#9111)

10 months agollama : fix qs.n_attention_wv for DeepSeek-V2 (#9156)
compilade [Tue, 27 Aug 2024 10:09:23 +0000 (06:09 -0400)]
llama : fix qs.n_attention_wv for DeepSeek-V2 (#9156)

10 months agoserver : add some missing env variables (#9116)
Xuan Son Nguyen [Tue, 27 Aug 2024 09:07:01 +0000 (11:07 +0200)]
server : add some missing env variables (#9116)

* server : add some missing env variables

* add LLAMA_ARG_HOST to server dockerfile

* also add LLAMA_ARG_CONT_BATCHING

10 months agollama : fix ChatGLM4 wrong shape (#9194)
CausalLM [Tue, 27 Aug 2024 06:58:22 +0000 (14:58 +0800)]
llama : fix ChatGLM4 wrong shape (#9194)

This should fix THUDM/glm-4-9b-chat-1m and CausalLM/miniG

10 months agollama : fix llama3.1 rope_freqs not respecting custom head_dim (#9141)
Carsten Kragelund Jørgensen [Tue, 27 Aug 2024 06:53:40 +0000 (08:53 +0200)]
llama : fix llama3.1 rope_freqs not respecting custom head_dim (#9141)

* fix: llama3.1 rope_freqs not respecting custom head_dim

* fix: use potential head_dim for Exaone

10 months agocommon : Update stb_image.h to latest version (#9161)
arch-btw [Tue, 27 Aug 2024 05:58:50 +0000 (22:58 -0700)]
common : Update stb_image.h to latest version (#9161)

* Update stb_image.h to latest version

Fixes https://github.com/ggerganov/llama.cpp/issues/7431

* Update .ecrc

10 months agoggml : do not crash when quantizing q4_x_x with an imatrix (#9192)
slaren [Mon, 26 Aug 2024 17:44:43 +0000 (19:44 +0200)]
ggml : do not crash when quantizing q4_x_x with an imatrix (#9192)

10 months agometal : separate scale and mask from QKT in FA kernel (#9189)
Georgi Gerganov [Mon, 26 Aug 2024 15:31:02 +0000 (18:31 +0300)]
metal : separate scale and mask from QKT in FA kernel (#9189)

* metal : separate scale and mask from QKT in FA kernel

* metal : ne01 check no longer necessary

* metal : keep data in local memory

10 months agoggml : add SSM Metal kernels (#8546)
Georgi Gerganov [Mon, 26 Aug 2024 14:55:36 +0000 (17:55 +0300)]
ggml : add SSM Metal kernels (#8546)

* ggml : add ggml_ssm_conv metal impl

* ggml : add ssm_scan metal impl

ggml-ci

10 months agotests : fix compile warnings for unreachable code (#9185)
Georgi Gerganov [Mon, 26 Aug 2024 13:30:25 +0000 (16:30 +0300)]
tests : fix compile warnings for unreachable code (#9185)

ggml-ci

10 months agoci : add VULKAN support to ggml-ci (#9055)
Georgi Gerganov [Mon, 26 Aug 2024 09:19:39 +0000 (12:19 +0300)]
ci : add VULKAN support to ggml-ci (#9055)

10 months agoserver : update deps (#9183)
Georgi Gerganov [Mon, 26 Aug 2024 09:16:57 +0000 (12:16 +0300)]
server : update deps (#9183)

10 months agometal : gemma2 flash attention support (#9159)
slaren [Mon, 26 Aug 2024 09:08:59 +0000 (11:08 +0200)]
metal : gemma2 flash attention support (#9159)

10 months agoggml-ci : try to improve build time (#9160)
slaren [Mon, 26 Aug 2024 09:03:30 +0000 (11:03 +0200)]
ggml-ci : try to improve build time (#9160)

10 months agollama : fix time complexity of string replacement (#9163)
Justine Tunney [Mon, 26 Aug 2024 06:09:53 +0000 (23:09 -0700)]
llama : fix time complexity of string replacement (#9163)

This change fixes a bug where replacing text in a very long string could
cause llama.cpp to hang indefinitely. This is because the algorithm used
was quadratic, due to memmove() when s.replace() is called in a loop. It
seems most search results and LLM responses actually provide the O(n**2)
algorithm, which is a great tragedy. Using a builder string fixes things

10 months agocommon: fixed not working find argument --n-gpu-layers-draft (#9175)
Herman Semenov [Sun, 25 Aug 2024 22:54:37 +0000 (22:54 +0000)]
common: fixed not working find argument --n-gpu-layers-draft (#9175)

10 months agoCUDA: fix Gemma 2 numerical issues for FA (#9166)
Johannes Gäßler [Sun, 25 Aug 2024 20:11:48 +0000 (22:11 +0200)]
CUDA: fix Gemma 2 numerical issues for FA (#9166)

10 months agoCPU/CUDA: Gemma 2 FlashAttention support (#8542)
Johannes Gäßler [Sat, 24 Aug 2024 19:34:59 +0000 (21:34 +0200)]
CPU/CUDA: Gemma 2 FlashAttention support (#8542)

* CPU/CUDA: Gemma 2 FlashAttention support

* apply logit_softcap to scale in kernel

* disable logit softcapping tests on Metal

* remove metal check

10 months agoquantize : fix typo in usage help of `quantize.cpp` (#9145)
João Dinis Ferreira [Sat, 24 Aug 2024 06:22:45 +0000 (07:22 +0100)]
quantize : fix typo in usage help of `quantize.cpp` (#9145)

10 months agolora : fix llama conversion script with ROPE_FREQS (#9117)
Xuan Son Nguyen [Fri, 23 Aug 2024 10:58:53 +0000 (12:58 +0200)]
lora : fix llama conversion script with ROPE_FREQS (#9117)

10 months agollama : use F32 precision in GLM4 attention and no FA (#9130)
piDack [Fri, 23 Aug 2024 07:27:17 +0000 (15:27 +0800)]
llama : use F32 precision in GLM4 attention and no FA (#9130)

10 months ago[SYCL] Add a space to supress a cmake warning (#9133)
Akarshan Biswas [Thu, 22 Aug 2024 14:09:47 +0000 (19:39 +0530)]
[SYCL] Add a space to supress a cmake warning (#9133)

10 months ago[SYCL] Add oneDNN primitive support (#9091)
luoyu-intel [Thu, 22 Aug 2024 04:50:10 +0000 (12:50 +0800)]
[SYCL] Add oneDNN primitive support (#9091)

* add onednn

* add sycl_f16

* add dnnl stream

* add engine map

* use dnnl for intel only

* use fp16fp16fp16

* update doc

10 months agollama : simplify Mamba with advanced batch splits (#8526)
compilade [Wed, 21 Aug 2024 21:58:11 +0000 (17:58 -0400)]
llama : simplify Mamba with advanced batch splits (#8526)

* llama : advanced batch splits

This includes equal-sequence-length batch splits which are useful
to simplify recurrent model operators.

* llama : always make recurrent state slots contiguous

* ggml : simplify mamba operators

* llama : fix integer signedness mixing

* llama : logits_all has priority over batch->logits

Otherwise, the server embeddings tests failed.
This was likely an existing problem but was only detected here
because of an additional assertion.

* llama : apply suggestions

Co-authored-by: Georgi Gerganov <redacted>
* llama : fix t5 segfault

* llama : fix Mamba session save and restore

* llama : minor cosmetic changes

* llama : rename llama_reorder_outputs to llama_output_reorder

Also move it closer to llama_output_reserve.

* llama : fix pooled embeddings when using batches with equal_seqs

* minor : add struct members for clarity

ggml-ci

* llama : fix T5 segfault again

* llama : fix Mamba pooled embeddings with multiple sequences

Until the pooled embeddings are refactored to allow splitting
across ubatches for causal embeddings,
recurrent models can only process a single sequence per ubatch
when calculating pooled embeddings.

* llama : add llama_model_is_recurrent to simplify figuring that out

This will make it easier to more cleanly support RWKV-v6 and Mamba-2.

* llama : fix simple splits when the batch contains embeddings

---------

Co-authored-by: Georgi Gerganov <redacted>
10 months agoserver : support reading arguments from environment variables (#9105)
Xuan Son Nguyen [Wed, 21 Aug 2024 09:04:34 +0000 (11:04 +0200)]
server : support reading arguments from environment variables (#9105)

* server : support reading arguments from environment variables

* add -fa and -dt

* readme : specify non-arg env var

10 months agollama : support for `falcon-mamba` architecture (#9074)
Younes Belkada [Wed, 21 Aug 2024 08:06:36 +0000 (12:06 +0400)]
llama : support for `falcon-mamba` architecture (#9074)

* feat: initial support for llama.cpp

* fix: lint

* refactor: better refactor

* Update src/llama.cpp

Co-authored-by: compilade <redacted>
* Update src/llama.cpp

Co-authored-by: compilade <redacted>
* fix: address comments

* Update convert_hf_to_gguf.py

Co-authored-by: compilade <redacted>
* fix: add more cleanup and harmonization

* fix: lint

* Update gguf-py/gguf/gguf_writer.py

Co-authored-by: compilade <redacted>
* fix: change name

* Apply suggestions from code review

Co-authored-by: compilade <redacted>
* add in operator

* fix: add `dt_b_c_rms` in `llm_load_print_meta`

* fix: correct printf format for bool

* fix: correct print format

* Update src/llama.cpp

Co-authored-by: compilade <redacted>
* llama : quantize more Mamba tensors

* llama : use f16 as the fallback of fallback quant types

---------

Co-authored-by: compilade <redacted>
10 months agollava : zero-initialize clip_ctx structure fields with aggregate initialization 908)
fairydreaming [Wed, 21 Aug 2024 07:45:49 +0000 (09:45 +0200)]
llava : zero-initialize clip_ctx structure fields with aggregate initialization 908)

Co-authored-by: Stanisław Szymczyk <redacted>