]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/log
pkg/ggml/sources/whisper.cpp
15 months agoggml, ci : Windows ARM runner and build fixes (llama/5979)
Michael Podvitskiy [Mon, 11 Mar 2024 09:28:51 +0000 (10:28 +0100)]
ggml, ci : Windows ARM runner and build fixes (llama/5979)

* windows arm ci

* fix `error C2078: too many initializers` with ggml_vld1q_u32 macro for MSVC ARM64

* fix `warning C4146: unary minus operator applied to unsigned type, result still unsigned`

* fix `error C2065: '__fp16': undeclared identifier`

15 months agoBetter 1.5 bit quantization (llama/5971)
Kawrakow [Mon, 11 Mar 2024 06:51:49 +0000 (07:51 +0100)]
Better 1.5 bit quantization (llama/5971)

* Trying blocvks of 16 for IQ1_S - seems slightly better

* iq1s_blocks16: Adjust scale fudge factor to 1.125

* iq1s_blocks16: going to blocks of 32

with 2048 lattice points, so same bpw.
This is even better than blocks of 16.
Should I try blocks of 64? But to keep the same
bpw, when I go to 4096 lattice points, I need to
remove blocks alltogether and just have superblocks of
256 weights.

* iq1s_blocks16: Use 2*<x^2> as sigma2 in weight adjustment

* iq1s_blocks16: scalar and AVX2 dot products

* iq1s_blocks16: CUDA dot product

* iq1s_blocks16: Metal works, Neon does not

Metal works but TG is dog slow (35 t/s). PP is OKish (493 t/s).
Not seeing the bug in the Neon implementation for now.

* iq1s_blocks16: fixed Neon

* iq1s_blocks16: very slightly faster TG on Metal

Still pathetic at 37 t/s

* iq1s_blocks16: speedup Metal by packing codebook into uint32_t's

* Formatting

* iq1s_blocks16: uint32_t codebook is also better in CUDA

TG-128 is now 204 t/s up from 194 t/s.
PP-512 is 5890 t/s, so significantly better than other quants

* iq1s_blocks16: slightly faster Neon dot product

* iq1s_blocks16: faster AVX2 dot product

* iq1s_blocks16: adjust to ggml-common.h

---------

Co-authored-by: Iwan Kawrakow <redacted>
15 months agoAdd q3_s and q1_s (llama/5886)
Abhilash Majumder [Mon, 11 Mar 2024 04:57:56 +0000 (10:27 +0530)]
Add q3_s and q1_s (llama/5886)

* Add q3_s and q1_s

* fix compilation

* fix build

* fix build

* fix build

* enable ops

* rm macro

* increase grid space

15 months agometal : move mm_id indices to shared mem (llama/5982)
Georgi Gerganov [Sun, 10 Mar 2024 21:12:48 +0000 (23:12 +0200)]
metal : move mm_id indices to shared mem (llama/5982)

15 months agoggml : fix unnecessary f32 -> f16 -> f32 casts (mmla) (llama/5951)
Georgi Gerganov [Sat, 9 Mar 2024 15:36:20 +0000 (17:36 +0200)]
ggml : fix unnecessary f32 -> f16 -> f32 casts (mmla) (llama/5951)

15 months agoggml : remove old quantization functions (llama/5942)
Georgi Gerganov [Sat, 9 Mar 2024 13:53:59 +0000 (15:53 +0200)]
ggml : remove old quantization functions (llama/5942)

* ggml : remove old quantization functions

ggml-ci

* ggml : simplify ggml_quantize_chunk

ggml-ci

* ggml : restrict correctness

ggml-ci

* ggml : remove hist data from the quantization API

ggml-ci

* tests : remove hist usage in test-backend-ops

ggml-ci

* vulkan : remove hist and fix typo

15 months agoggml : add ggml-common.h to deduplicate shared code (llama/5940)
Georgi Gerganov [Sat, 9 Mar 2024 10:47:57 +0000 (12:47 +0200)]
ggml : add ggml-common.h to deduplicate shared code (llama/5940)

* ggml : add ggml-common.h to shared code

ggml-ci

* scripts : update sync scripts

* sycl : reuse quantum tables

ggml-ci

* ggml : minor

* ggml : minor

* sycl : try to fix build

15 months agollama : support Mamba Selective State Space Models (llama/5328)
compilade [Fri, 8 Mar 2024 22:31:00 +0000 (17:31 -0500)]
llama : support Mamba Selective State Space Models (llama/5328)

* mamba : begin working on support for Mamba SSM

* mamba : begin figuring out how to (ab)use the kv cache for Mamba

* mamba : recurrent inference almost works, but incoherent

* mamba : recurrent inference WORKS!!!

* convert : optionally use d_conv and d_state from config.json for Mamba

* mamba : refactor recurrent conv, resulting in 20% perf increase

It's still slower than I'd like, but I did not really optimize `ggml_exp` yet.

I also refactored `ggml_exp` to work with tensors with more than 2 dimensions.

* ggml : parallelize ggml_exp

This results in 8% faster token generation for Mamba-130M.

* mamba : simplify the conv step with a self-overlapping view

Turns out the conv_state can be made smaller by one column.
Note that this breaks existing GGUFs of Mamba,
because the key_value_length field is tied to the conv_state size.

Convolution with a self-overlapping view is cool!
And it's much simpler than what I initially thought would be necessary
to make the convolution step work with more than 1 token at a time.

Next step is to make the SSM step work on batches of tokens too,
and thus I need to figure out a way to make a parallel selective scan
which will keep the ssm_state small and won't make it bigger
by a factor of (n_layer * batch_size).

* llama : fix Mamba KV self size wrongly displaying as f16 instead of f32

Relatedly, I also tried to see if other types than f32 worked for the states,
but they don't, because of the operators used.
It's probably better anyway to keep lots of precision there,
since the states are small anyway.

* mamba : fix self-overlapping view depth stride

* mamba : handle batches of more than 1 token

This means running Mamba no longer crashes when using the default settings!
And probably also slightly faster prompt processing.
Both batched and non-batched processing yield the same output.

Previously, the state was not cleared when starting a sequence.
Next step is to make the KV cache API work as expected for Mamba models.

* ggml: add ggml_ssm_scan to help with parallel selective scan

If the selective scan was implemented without a custom operator,
there would be waaay too many nodes in the graph. For example,
for Mamba-130M, with a batch size of 512 (the default),
a naive selective scan could add at least 24*512=12288 nodes,
which is more than LLAMA_MAX_NODES (8192),
and that's only for the smallest Mamba model.
So it's much cleaner with a custom operator.
Not sure about the name, though.

* ggml : in ggml_ssm_scan, merge multiple rows in the same vec operation

This will help with performance on CPU if ggml_vec_mul_f32
and ggml_vec_add_f32 are ever optimized with SIMD.

* mamba : very basic quantization support

Mostly works, but there is currently no difference
between the variants of a k-quant (e.g. Q4_K_S and Q4_K_M are the same).
Most of the SSM-specific weights can be kept in f32 without affecting
the size that much, since they are relatively small.
(the linear projection weights are responsible for most of Mamba's size)

Too much quantization seems to make the state degrade quite fast, and
the model begins to output gibberish.
It seems to affect bigger models to a lesser extent than small models,
but I'm not sure by how much.

Experimentation will be needed to figure out which weights are more important
for the _M (and _L?) variants of k-quants for Mamba.

* convert : fix wrong name for layer norm weight of offical Mamba models

I was using Q-bert/Mamba-* models before, which have a slighlty different
naming scheme for the weights.
(they start with "model.layers" instead of "backbone.layers")

* mamba : fuse more steps of the SSM scan in the ggml_ssm_scan operator

This increases performance on CPU by around 30% for prompt processing,
and by around 20% for text generation.

However, it also makes the ggml_exp and ggml_soft_plus operators unused.
Whether or not they should be kept will be decided later.

* convert : for Mamba, also consider the "MambaLMHeadModel" arch name

It's the name of the class of the official implementation,
though they don't use it (yet) in the "architectures" field of config.json

* mamba : fix vocab size problems with official models

The perplexity was waaaay to high for models with a non-round vocab size.
Not sure why, but it needed to be fixed in the metadata.

Note that this breaks existing GGUF-converted Mamba models,
but **only if** the vocab size was not already rounded.

* ggml : remove ggml_exp and ggml_soft_plus

They did not exist anyway outside of this branch,
and since ggml_ssm_scan fused operations together, they are unused.
It's always possible to bring them back if needed.

* mamba : remove some useless comments

No code change.

* convert : fix flake8 linter errors

* mamba : apply suggestions from code review

* mamba : remove unecessary branch for row-wise ssm_state and C multiplication

It was previously done to avoid permuting when only one token is processed
at a time (like when generating text), but permuting is cheap,
and dynamically changing the compute graph is not future-proof.

* ggml : in ggml_ssm_scan, use more appropriate asserts

* ggml : rename the destination pointer in ggml_compute_forward_ssm_scan_f32

* mamba : multiple sequences, but one at a time

This is a step towards making this Mamba implementation usable
with the server example (the way the system prompt is kept when clearing
the client slots will need to be changed before this can work, though).

The KV cache size for this kind of model is tied to the maximum number
of sequences kept at any single time.
For now, this number is obtained from n_parallel (plus one,
to have an extra sequence to dedicate to the system prompt),
but there might be a better way to do this which won't also
make the main example use 2 cells even if only 1 is really used.
(for this specific case, --parallel 0 helps)

Simultaneous sequence processing will probably require changes to
ggml_ssm_scan, and possibly a new operator for the conv step.

* mamba : support llama_kv_cache_seq_cp

This (mis)uses the logic around K shifts, because tokens in a state
can't be shifted anyway, and because inp_K_shift has the right shape and type.
Using ggml_get_rows is a nice way to do copies, but copy chains can't work.
Fortunately, copy chains don't really seem to be used in the examples.

Each KV cell is dedicated to the sequence ID corresponding to its own index.

* mamba : use a state mask

It's cleaner than the previous heuristic of
checking for the pos of the first token in the batch.

inp_KQ_mask could not be re-used for this, because it has the wrong shape
and because it seems more suited to the next step of
simultaneous sequence processing (helping with the problem of
remembering which token belongs to which sequence(s)/state(s)).

* llama : replace the usage of n_ctx with kv_self.size in many places

* mamba : use n_tokens directly instead of n_tok

* mamba : in comments, properly refer to KV cells instead of slots

* mamba : reduce memory usage of ggml_ssm_scan

From 290.37 MiB to 140.68 MiB of CPU compute buffer size
with Mamba 3B with a batch size of 512.

The result tensor of ggml_ssm_scan was previously a big part
of the CPU compute buffer size. To make it smaller,
it does not contain the intermediate ssm states anymore.
Both y and the last ssm state are combined in the result tensor,
because it seems only a single tensor can be returned by an operator
with the way the graph is built.

* mamba : simultaneous sequence processing

A batch can now contain tokens from multiple sequences.

This is necessary for at least the parallel example, the server example,
and the HellaSwag test in the perplexity example.

However, for this to be useful, uses of llama_kv_cache_seq_rm/cp
will need to be changed to work on whole sequences.

* ggml : add ggml_ssm_conv as a new operator for the conv step of Mamba

This operator makes it possible to use and update the correct states
for each token of the batch in the same way as ggml_ssm_scan.
Other solutions which use existing operators would need loops which would
add too many nodes to the graph (at least the ones I thought of).

Using this operator further reduces the size of the CPU compute buffer
from 140.68 MiB to 103.20 MiB with Mamba 3B with a batch size of 512.
And (at least on CPU), it's a bit faster than before.

Note that "ggml_ssm_conv" is probably not the most appropriate name,
and it could be changed if a better one is found.

* llama : add inp_s_seq as a new input tensor

The most convenient implementation to select the correct state (for Mamba)
for each token is to directly get the correct index from a tensor.
This is why inp_s_seq is storing int32_t and not floats.

The other, less convenient way to select the correct state would be
to have inp_KQ_mask contain 1.0f for each state used by a token
and 0.0f otherwise. This complicates quickly fetching the first used
state of a token, and is also less efficient because a whole row
of the mask would always need to be read for each token.

Using indexes makes it easy to stop searching when there are
no more sequences for a token, and the first sequence assigned
is always very quickly available (it's the first element of each row).

* mamba : support llama_kv_cache_seq_cp copy chains

* mamba : support shifting and dividing the kv cache pos

* mamba : make the server and parallel examples work with whole sequences

A seq_id is dedicated to the system prompt in both cases.

* llama : make llama_kv_cache_seq_rm return whether it succeeded or not

* mamba : dedicate an input tensor for state copy indices

This is cleaner and makes it easier to adapt when/if token positions
(and by extension, inp_K_shift) are no longer integers.

* mamba : adapt perplexity, batched, and batched-bench examples

* perplexity : limit the max number of sequences

This adapts to what the loaded model can provide.

* llama : add llama_n_max_seq to get the upper limit for seq_ids

Used by the perplexity example.

* batched : pass n_parallel to the model's context params

This should have been there already, but it wasn't.

* batched-bench : reserve sequences to support Mamba

* batched-bench : fix tokens being put in wrong sequences

Generation quality isn't what's measured in there anyway,
but at least using the correct sequences avoids using non-consecutive
token positions.

* mamba : stop abusing attention metadata

This breaks existing converted-to-GGUF Mamba models,
but will allow supporting mixed architectures like MambaFormer
without needing to break Mamba models.

This will also allow changing the size of Mamba's states
without having to reconvert models in the future.
(e.g. using something else than d_conv - 1 columns for the conv_states
 will not require breaking existing converted Mamba models again)

* gguf-py : add new KV metadata key-value pairs for Mamba

* llama : add new metadata key-value pairs for Mamba

* llama : guard against divisions by zero when n_head is 0

* mamba : rename "unlimited" KV cache property to "recurrent"

* mamba : more correctly update the "used" field of the KV cache

* ggml : in ggml_ssm_scan, use a threshold for soft_plus

This is how the official Mamba implementation does it,
and it's also what torch.nn.Softplus does.

* convert : for Mamba, fallback to internal NeoX tokenizer

The resulting models are exactly the same
as if the tokenizer.json and tokenizer_config.json of GPT-NeoX were there.

* mamba : support state saving and restoring

* ggml : implicitly pass src tensors through dst for Mamba-related ops

* mamba : clarify some comments

* server : fix cache_tokens not getting correctly resized

Otherwise, when the "we have to evaluate at least 1 token" special case
was triggered, an extra token was kept in cache_tokens even if it was
removed from the KV cache.

For Mamba, this caused useless prompt reprocessing when the previous
request triggered the above case.

* convert-hf : support new metadata keys for Mamba

For the models available at
https://huggingface.co/collections/state-spaces/transformers-compatible-mamba-65e7b40ab87e5297e45ae406

* mamba : rename metadata to be more similar to transformers library

This breaks existing converted-to-GGUF models,
but the metadata names are more "standard".

* mamba : support mamba-*-hf models

These models share their token_embd.weight with their output.weight

* mamba : add missing spaces

This is purely a formatting change.

* convert-hf : omit output.weight when identical with token_embd.weight

Only for Mamba for now, but it might be relevant for other models eventually.
Most Mamba models actually share these two tensors, albeit implicitly.

* readme : add Mamba to supported models, and add recent API changes

* mamba : move state_seq and state_mask views outside layer loop

A few tensors were also missing `struct` in front of `ggml_tensor`.

15 months agoextra : update sync scripts after ggml-common.h
Georgi Gerganov [Fri, 15 Mar 2024 12:00:53 +0000 (14:00 +0200)]
extra : update sync scripts after ggml-common.h

15 months agowhisper : document whisper_batch.n_seq_id (#1942)
Josh Bleecher Snyder [Sun, 10 Mar 2024 14:55:22 +0000 (07:55 -0700)]
whisper : document whisper_batch.n_seq_id (#1942)

To prevent other people from attempting to remove it, as I did.

15 months agowhisper : improve beam search candidate diversity (#1947)
Josh Bleecher Snyder [Sun, 10 Mar 2024 14:54:43 +0000 (07:54 -0700)]
whisper : improve beam search candidate diversity (#1947)

As of #1486, whisper.cpp uses a unified KV cache with KQ masking.
As a result, depending on their location in the batch,
identical sequences in a batch can have slightly different outputs
due to floating point rounding errors during reduction.
See the discussion in #1941 for more details.

The beam search code used "has identical sum of log probabilities"
as a shorthand for "is an identical token sequence". However, per above,
identical tokens do not necessarily result in identical probabilities.

Instead, explicitly compare on sequences.
This is linear in cost when they are identical,
but the lengths are always small and the comparisons are cheap.

This increases diversity during beam search.

This improves output quality for some short samples I've been working
with, at no detectable performance cost.
I haven't checked against larger corpuses.

Fixes #1941

15 months agobindings/go : add linker flags to make metal work (#1944)
Josh Bleecher Snyder [Sat, 9 Mar 2024 16:50:44 +0000 (08:50 -0800)]
bindings/go : add linker flags to make metal work (#1944)

The first two are required to build.
The last one is to make it actually detect the GPU.

Fixes #1899, at least for me

15 months agowhisper : make beam candidate sort more stable (#1943)
Josh Bleecher Snyder [Sat, 9 Mar 2024 16:50:03 +0000 (08:50 -0800)]
whisper : make beam candidate sort more stable (#1943)

All else being otherwise equal, this encourages the beam candidate
selection to re-use the same decoder, which slightly
reduces the cache size.

I wouldn't expect it to make much of a performance difference,
but it helps when debug printing the cache and beam.

Added as part of understanding #1941.

15 months agoggml : try fix 32-bit arm compat (#1938)
Georgi Gerganov [Fri, 8 Mar 2024 21:45:07 +0000 (23:45 +0200)]
ggml : try fix 32-bit arm compat (#1938)

* ggml : try fix 32-bit arm compat

* ggml : fix cont

15 months agotalk-llama : use llama_decode instead of llama_eval
Georgi Gerganov [Fri, 8 Mar 2024 10:04:43 +0000 (12:04 +0200)]
talk-llama : use llama_decode instead of llama_eval

15 months agotalk-llama : sync llama.cpp
Georgi Gerganov [Fri, 8 Mar 2024 09:55:50 +0000 (11:55 +0200)]
talk-llama : sync llama.cpp

15 months agotalk-llama : sync llama.cpp
Georgi Gerganov [Fri, 8 Mar 2024 09:52:47 +0000 (11:52 +0200)]
talk-llama : sync llama.cpp

15 months agosync : ggml
Georgi Gerganov [Fri, 8 Mar 2024 09:39:34 +0000 (11:39 +0200)]
sync : ggml

15 months agoRevert "[SYCL] fix error when set main gpu to non-zero (llama/5901)" (llama/5918)
Neo Zhang Jianyu [Thu, 7 Mar 2024 11:14:49 +0000 (19:14 +0800)]
Revert "[SYCL] fix error when set main gpu to non-zero (llama/5901)" (llama/5918)

This reverts commit ceca1aef0738b57951cd12c603c3477e75312dec.

15 months agofix error when set main gpu to non-zero (llama/5901)
Neo Zhang Jianyu [Thu, 7 Mar 2024 08:34:31 +0000 (16:34 +0800)]
fix error when set main gpu to non-zero (llama/5901)

* fix error when set main gpu to non-zero

* fix delete condition

15 months agoggml : use SYS_get_cpu if SYS_getcpu is not defined (llama/5906)
Jared Van Bortel [Wed, 6 Mar 2024 20:42:23 +0000 (15:42 -0500)]
ggml : use SYS_get_cpu if SYS_getcpu is not defined (llama/5906)

Fixes #5694
Fixes ggerganov/whisper.cpp#1894

15 months agoggml : use `uint8x16_t` return type for `ggml_vqtbl1q_u8` (llama/5894)
bobqianic [Wed, 6 Mar 2024 07:35:07 +0000 (07:35 +0000)]
ggml : use `uint8x16_t` return type for `ggml_vqtbl1q_u8` (llama/5894)

* use uint8x16_t

* Update ggml-quants.c

15 months agoadd wait() to make code stable (llama/5895)
Neo Zhang Jianyu [Wed, 6 Mar 2024 04:08:32 +0000 (12:08 +0800)]
add wait() to make code stable (llama/5895)

15 months agoquants : use MM256_SET_M128I consistently to fix gcc 7 build (llama/5889)
Jared Van Bortel [Tue, 5 Mar 2024 16:56:37 +0000 (11:56 -0500)]
quants : use MM256_SET_M128I consistently to fix gcc 7 build (llama/5889)

15 months agoVulkan Improvements (llama/5835)
0cc4m [Tue, 5 Mar 2024 12:33:42 +0000 (13:33 +0100)]
Vulkan Improvements (llama/5835)

* Improve dequant shaders, add fast q4_0 dequant

* Optimize dmmv non-kquants for GCN

Remove unnecessary SPIR-V shader duplication

* Fix q4_0 dequant dispatch sizes

Fix backend free bug

* Optimize dequant shaders for q4_1, q5_0, q5_1 and q8_0

* Add unary and binary op shader templates

* Fix Vulkan check results

* Enable non-contiguous support for simple ops

* Add argsort

Basic q4_0 mmq shader and unit test

* Speed up q4_0 dequant code, enable mmq for q4_0

* Rework matmul pipeline selection

* Add soft_max alibi support

* Add q4_1, q5_0, q5_1 and q8_0 dequant mat mat mul shaders

* Add environment variable GGML_VK_FORCE_MAX_ALLOCATION_SIZE to limit max buffer size

Rename GGML_VULKAN_DISABLE_F16 to GGML_VK_DISABLE_F16 for consistency

15 months agofix mul_mat fault in CI/unit-test (llama/5862)
Neo Zhang Jianyu [Tue, 5 Mar 2024 08:08:35 +0000 (16:08 +0800)]
fix mul_mat fault in CI/unit-test (llama/5862)

* fix mul_mat fault in cpy_f32_f16

* rm unused function

* add wait() for memcpy

* restore ci/run.sh, rename struct defination, fix bug in ggml_sycl_op_mul_mat_sycl

* fix format issue

* llama : fix segfault from unknown model arch name (llama/5820)

* llama : fix segfault from unknown model arch name

* llama : make all LLM maps const

This also requires using `std::map::at` instead of its `operator[]`
which does not exist for const maps.

* llama : name LLM_ARCH_UNKNOWN to "(unknown)"

This avoids errors from `std::map::at` when
getting the general name of the model architecture.
Using "(unknown)" instead of an empty string as per suggestion
https://github.com/ggerganov/llama.cpp/pull/5820#issuecomment-1973735284

* llama : remove redundant inner const for LLM_TENSOR_NAMES

The extra const won't do anything here as const maps
return const references to values.

Co-authored-by: Jared Van Bortel <redacted>
* llama : remove redundant nullptr check in llm_arch_from_string

Since LLM_ARCH_NAMES is a const map, no spurious elements
with a NULL name are inserted anymore, so this check is dead code.

---------

Co-authored-by: Jared Van Bortel <redacted>
* llama : refactor internal quantization functions (llama/5830)

* scripts : add pod-llama.sh

* ggml : IQ3_S improvements (llama/5829)

* iq3_s: somewhat faster AVX2 dot product

On Ryzen a 7950X TG-128 increases to 16 t/s from 15.5 t/s using
16 threads. For 8 threads it is 13.85 t/s vs 11.75 t/s.
PP-512 increases to 28.5 t/s from 23.8 t/s.

* iq3_s: somewhat faster ARM_NEON dot product

Still dog slow - 10.7 t/s up from 9.9 t/s.

* iq3_s: another small ARM_NEON improvement

10.7 -> 11.0 t/s. Using vmulq_s8 is faster than the xor - sub trick
that works best on AVX2.

* iq3_s: minor improvement on Metal

49.4 t/s -> 50.3 t/s

* iq3_s: PPL improvement

E.g., for a context of 4096 LLaMA-v2-7B goes to 5.1340 from 5.1653.

* iq3_s: use new grid everywhere

* Fix ARM_NEON

---------

Co-authored-by: Iwan Kawrakow <redacted>
* convert-hf : make model class definitions self-contained (llama/5825)

* convert : automatically fall back to HfVocab if tokenizer.model doesn't exist (llama/5821)

* ggml : fix IQ3_S AVX implementation (llama/5834)

ggml-ci

* llama : add abort_callback to interrupt computation (llama/5409)

* using abort_callback from ggml to stop llama computation

* format fix

* a brief explaining comment

---------

Co-authored-by: Georgi Gerganov <redacted>
* server: tests: passkey challenge /  self-extend with context shift demo (llama/5832)

* server: tests: add models endpoint scenario

* server: /v1/models add some metadata

* server: tests: add debug field in context before scenario

* server: tests: download model from HF, add batch size

* server: tests: add passkey test

* server: tests: add group attention params

* server: do not truncate prompt tokens if self-extend through group attention is enabled

* server: logs: do not truncate log values

* server: tests - passkey - first good working value of nga

* server: tests: fix server timeout

* server: tests: fix passkey, add doc, fix regex content matching, fix timeout

* server: tests: fix regex content matching

* server: tests: schedule slow tests on master

* server: metrics: fix when no prompt processed

* server: tests: self-extend add llama-2-7B and Mixtral-8x7B-v0.1

* server: tests: increase timeout for completion

* server: tests: keep only the PHI-2 test

* server: tests: passkey add a negative test

* flake.lock: Update (llama/5842)

Flake lock file updates:

• Updated input 'flake-parts':
    'github:hercules-ci/flake-parts/b253292d9c0a5ead9bc98c4e9a26c6312e27d69f' (2024-02-01)
  → 'github:hercules-ci/flake-parts/f7b3c975cf067e56e7cda6cb098ebe3fb4d74ca2' (2024-03-01)
• Updated input 'flake-parts/nixpkgs-lib':
    'github:NixOS/nixpkgs/97b17f32362e475016f942bbdfda4a4a72a8a652?dir=lib' (2024-01-29)
  → 'github:NixOS/nixpkgs/1536926ef5621b09bba54035ae2bb6d806d72ac8?dir=lib' (2024-02-29)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/cbc4211f0afffe6dfd2478a62615dd5175a13f9a' (2024-02-23)
  → 'github:NixOS/nixpkgs/1536926ef5621b09bba54035ae2bb6d806d72ac8' (2024-02-29)

Co-authored-by: github-actions[bot] <redacted>
* server : init http requests thread pool with --parallel if set (llama/5836)

* ci : schedule slow server tests only on Release or on demand (llama/5839)

* llama : fix llama_copy_state_data with fragmented KV cache (llama/5840)

The row size of the saved states was based on kv_self.head while
it should be based on llama_kv_cache_cell_max.

Existing session files should still work.

* llama : fix llama_kv_cache_cell_max inability to return 1

I've also changed its return type to uint32_t,
because this function is always used to set the value of uint32_t variables,
and because the index already has this type.

* llama : fix state size calculation

Some bytes in the state were unaccounted for in llama_get_state_size.
Since the logits reserve so much space, it did not cause problems.

* gguf-dump : support i-quants (llama/5841)

Co-authored-by: Black_Fox <redacted>
* llama : allow for user specified embedding pooling type (llama/5849)

* allow for user specified pooling type

* llama : use enum types over int

---------

Co-authored-by: Georgi Gerganov <redacted>
* readme : add API changes section

* cuda : fix data race in soft max (llama/5853)

* main : support special tokens as reverse/anti prompt (llama/5847)

* Support special tokens as reverse/anti prompt.

* Tokenize antiprompts only once.

* main : minor

---------

Co-authored-by: Georgi Gerganov <redacted>
* common : use LLAMA_DEFAULT_SEED (llama/5855)

* add some new ops, fix some operators and add batch operations to certain operators. (ggml/747)

* cuda: fix group_norm

* cuda: add batch inference support for ggml_pad/ggml_upscale

* add ggml_arrange

* add ggml_timestep_embedding

* update ggml_arange/ggml_timestep_embedding tests

* cuda: fix im2col

* add ggml_arange/ggml_timestep_embbeding support for metal backend

* fix some bugs

* fix some bugs

* Update ggml.h

Co-authored-by: Georgi Gerganov <redacted>
* Update ggml-cuda.cu

Co-authored-by: Georgi Gerganov <redacted>
* Update ggml-metal.m

Co-authored-by: Georgi Gerganov <redacted>
* Update ggml-metal.m

Co-authored-by: Georgi Gerganov <redacted>
* Update ggml-metal.metal

Co-authored-by: Georgi Gerganov <redacted>
* modify according to the review comments

* ggml : fix compile warnings + code style

* ggml : normalize compute_forward calls + fix seg fault in debug

* minor

---------

Co-authored-by: Georgi Gerganov <redacted>
Co-authored-by: slaren <redacted>
* sync : ggml

* add alias for chat template (llama/5858)

* speculative : implement stochastic speculative sampling (llama/5625)

* (WIP) Implement stochastic speculative decoding

* sample from residual distribution on draft accept failure

* fix #5657: force greedy sampling with probs when temp is 0

* remove p_accept parameter

* fix style

* remove unused variables

* add srand() in speculative.cpp

* replace use of rand() with mt19937 sampling

* fixes based on review (@JohannesGaessler)

* fix r random generation

* randomly select next sequence to verify + fix bug in memory freeing

* fix bug in active_seqs sync

* fix uniform int distribution initialization

* remove warnings from comparison between int and size_t

* check grammar in `llama_sample_probability_distribution_impl`

* remove malloc code by utilizing vectors

* add PR link to README

* cmake : handle cases where git index is not found in .git (llama/5844)

* Update CMakeLists.txt

* Update CMakeLists.txt

* ggml : introduce ggml_status (ggml/750)

* using enum as an exit code instead of macros

* update return type from enum to unsigned int

* indentation fix

* compound update
ggml_compute_exit_code -> ggml_status
changed ggml_status from a bit-field type to simple codes
ggml_status to string cast

* ggml_status to string cast

* GGML_CALL was removed

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

Co-authored-by: slaren <redacted>
Co-authored-by: Georgi Gerganov <redacted>
* sync : ggml

ggml-ci

* ggml : fix unknown status (llama/0)

* flake : fix

* llama : fix embeddings (llama/5796)

* llama : fix embeddings

ggml-ci

* llama : do not use KV cache for non-causal models

ggml-ci

* embeddings : fix llama_batch_init arg

* llama : add pooling switch

* llama : distinguish token vs sequence embeddings

ggml-ci

* llama : assert pooling tensor

* llama : simplify causal mask condition

ggml-ci

* llama : assert input batch with pooling enabled

* readme : update API changes list

* nix: static build (llama/5814)

* fix speculative decoding build on windows (llama/5874)

* rebase and rm tailing space

---------

Co-authored-by: LiangtaoJin <redacted>
Co-authored-by: compilade <redacted>
Co-authored-by: Jared Van Bortel <redacted>
Co-authored-by: Xuan Son Nguyen <redacted>
Co-authored-by: Georgi Gerganov <redacted>
Co-authored-by: Kawrakow <redacted>
Co-authored-by: Iwan Kawrakow <redacted>
Co-authored-by: Jared Van Bortel <redacted>
Co-authored-by: Michael Podvitskiy <redacted>
Co-authored-by: Pierrick Hymbert <redacted>
Co-authored-by: github-actions[bot] <redacted>
Co-authored-by: Nindaleth <redacted>
Co-authored-by: Black_Fox <redacted>
Co-authored-by: Douglas Hanley <redacted>
Co-authored-by: slaren <redacted>
Co-authored-by: DAN™ <redacted>
Co-authored-by: leejet <redacted>
Co-authored-by: Minsoo Cheong <redacted>
Co-authored-by: Dane Madsen <redacted>
Co-authored-by: hutli <redacted>
Co-authored-by: Jeffrey Quesnelle <redacted>
15 months agoggml : fix unknown status (llama/0)
Georgi Gerganov [Mon, 4 Mar 2024 18:53:27 +0000 (20:53 +0200)]
ggml : fix unknown status (llama/0)

15 months agowhisper : fix compute helper return (ggml/750)
Georgi Gerganov [Tue, 5 Mar 2024 14:05:23 +0000 (16:05 +0200)]
whisper : fix compute helper return (ggml/750)

15 months agoggml : introduce ggml_status (ggml/750)
Michael Podvitskiy [Mon, 4 Mar 2024 09:05:42 +0000 (10:05 +0100)]
ggml : introduce ggml_status (ggml/750)

* using enum as an exit code instead of macros

* update return type from enum to unsigned int

* indentation fix

* compound update
ggml_compute_exit_code -> ggml_status
changed ggml_status from a bit-field type to simple codes
ggml_status to string cast

* ggml_status to string cast

* GGML_CALL was removed

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

Co-authored-by: slaren <redacted>
Co-authored-by: Georgi Gerganov <redacted>
15 months agocuda : fix data race in soft max (llama/5853)
slaren [Sun, 3 Mar 2024 13:26:18 +0000 (14:26 +0100)]
cuda : fix data race in soft max (llama/5853)

15 months agoggml : fix IQ3_S AVX implementation (llama/5834)
Georgi Gerganov [Sat, 2 Mar 2024 18:00:49 +0000 (20:00 +0200)]
ggml : fix IQ3_S AVX implementation (llama/5834)

ggml-ci

15 months agoggml : IQ3_S improvements (llama/5829)
Kawrakow [Sat, 2 Mar 2024 15:00:51 +0000 (17:00 +0200)]
ggml : IQ3_S improvements (llama/5829)

* iq3_s: somewhat faster AVX2 dot product

On Ryzen a 7950X TG-128 increases to 16 t/s from 15.5 t/s using
16 threads. For 8 threads it is 13.85 t/s vs 11.75 t/s.
PP-512 increases to 28.5 t/s from 23.8 t/s.

* iq3_s: somewhat faster ARM_NEON dot product

Still dog slow - 10.7 t/s up from 9.9 t/s.

* iq3_s: another small ARM_NEON improvement

10.7 -> 11.0 t/s. Using vmulq_s8 is faster than the xor - sub trick
that works best on AVX2.

* iq3_s: minor improvement on Metal

49.4 t/s -> 50.3 t/s

* iq3_s: PPL improvement

E.g., for a context of 4096 LLaMA-v2-7B goes to 5.1340 from 5.1653.

* iq3_s: use new grid everywhere

* Fix ARM_NEON

---------

Co-authored-by: Iwan Kawrakow <redacted>
15 months agoSupport multiple GPUs (split mode) on SYCL backend (llama/5806)
Neo Zhang Jianyu [Sat, 2 Mar 2024 11:49:30 +0000 (19:49 +0800)]
Support multiple GPUs (split mode) on SYCL backend (llama/5806)

* suport multiple cards: split-mode - layer|row

* rm warning

* rebase with master, support tow new OPs, close feature for -sm=row, fix for unit test

* update news

* fix merge error

* update according to review comments

15 months agoggml-vulkan: fix VULKAN_CHECK_RESULTS flag, which was previously broken (llama/5813)
ddpasa [Fri, 1 Mar 2024 17:00:00 +0000 (18:00 +0100)]
ggml-vulkan: fix VULKAN_CHECK_RESULTS flag, which was previously broken (llama/5813)

15 months agoUse batched mul_mat pathway (llama/5591)
AidanBeltonS [Fri, 1 Mar 2024 07:36:47 +0000 (07:36 +0000)]
Use batched mul_mat pathway (llama/5591)

* Use batched mul_mat pathway

* rm extra line

* Explicitly state scaled data type

---------

Co-authored-by: Abhilash Majumder <redacted>
15 months agomake portability_enumeration_ext apple only (llama/5757)
Eve [Wed, 28 Feb 2024 19:33:37 +0000 (19:33 +0000)]
make portability_enumeration_ext apple only (llama/5757)

15 months agoadd some new ops, fix some operators and add batch operations to certain operators...
leejet [Sun, 3 Mar 2024 12:23:52 +0000 (20:23 +0800)]
add some new ops, fix some operators and add batch operations to certain operators. (ggml/747)

* cuda: fix group_norm

* cuda: add batch inference support for ggml_pad/ggml_upscale

* add ggml_arrange

* add ggml_timestep_embedding

* update ggml_arange/ggml_timestep_embedding tests

* cuda: fix im2col

* add ggml_arange/ggml_timestep_embbeding support for metal backend

* fix some bugs

* fix some bugs

* Update ggml.h

Co-authored-by: Georgi Gerganov <redacted>
* Update ggml-cuda.cu

Co-authored-by: Georgi Gerganov <redacted>
* Update ggml-metal.m

Co-authored-by: Georgi Gerganov <redacted>
* Update ggml-metal.m

Co-authored-by: Georgi Gerganov <redacted>
* Update ggml-metal.metal

Co-authored-by: Georgi Gerganov <redacted>
* modify according to the review comments

* ggml : fix compile warnings + code style

* ggml : normalize compute_forward calls + fix seg fault in debug

* minor

---------

Co-authored-by: Georgi Gerganov <redacted>
Co-authored-by: slaren <redacted>
15 months agoexamples : Auto lowercase language parameter in main.cpp (#1928)
F1L1P [Wed, 6 Mar 2024 22:25:10 +0000 (23:25 +0100)]
examples : Auto lowercase language parameter in main.cpp (#1928)

* Auto lowercase language parameter

* Update examples/main/main.cpp

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

Co-authored-by: bobqianic <redacted>
15 months agoexamples : fix typo in bench.cpp (#1933)
zhouwg [Wed, 6 Mar 2024 22:21:44 +0000 (06:21 +0800)]
examples : fix typo in bench.cpp (#1933)

15 months agowhisper : fix typo (#1925)
zhouwg [Tue, 5 Mar 2024 15:06:31 +0000 (23:06 +0800)]
whisper : fix typo (#1925)

15 months agowhisper.android.java : fix returns in JNI (#1929)
zhouwg [Tue, 5 Mar 2024 13:59:26 +0000 (21:59 +0800)]
whisper.android.java : fix returns in JNI (#1929)

15 months agocmake : add library versioning (#1352)
kennethge [Mon, 4 Mar 2024 19:17:48 +0000 (14:17 -0500)]
cmake : add library versioning (#1352)

Co-authored-by: Georgi Gerganov <redacted>
15 months agoreadme : recommend MacOS Sonoma for Core ML (#1917)
Gavin Cai [Mon, 4 Mar 2024 19:16:13 +0000 (11:16 -0800)]
readme : recommend MacOS Sonoma for Core ML (#1917)

16 months agotalk-llama : sync llama.cpp
Georgi Gerganov [Wed, 28 Feb 2024 11:04:05 +0000 (13:04 +0200)]
talk-llama : sync llama.cpp

16 months agosync : ggml
Georgi Gerganov [Wed, 28 Feb 2024 11:01:33 +0000 (13:01 +0200)]
sync : ggml

16 months agosync : llama.cpp (ggml/0)
Georgi Gerganov [Wed, 28 Feb 2024 10:59:11 +0000 (12:59 +0200)]
sync : llama.cpp (ggml/0)

16 months agoggml : make i-quants work with super-blocks of 64 (CPU,Metal) (llama/5760)
Kawrakow [Wed, 28 Feb 2024 08:37:02 +0000 (10:37 +0200)]
ggml : make i-quants work with super-blocks of 64 (CPU,Metal) (llama/5760)

* WIP: make i-quants work for QK_K = 64

* iq2_xs: attempt to fix AVX dot product for QK_K = 64

Tests pass, but I get gibberish.

* QK_K = 64 tests pass on ARM_NEON and Metal

Sadly, that does not mean it actually works.

* Make CUDA compile with QK_K = 64

Tests don't pass, plus we get misaligned access

* Q2_K: fixed bug in imatrix quantization for QK_K = 64

* iq1_s: turn off SIMD implementation for QK_K = 64 (it does not work)

---------

Co-authored-by: Iwan Kawrakow <redacted>
16 months agoAttempt to fix android build (llama/5752)
Kawrakow [Tue, 27 Feb 2024 17:16:49 +0000 (19:16 +0200)]
Attempt to fix android build (llama/5752)

Co-authored-by: Iwan Kawrakow <redacted>
16 months agoIQ4_XS: a 4.25 bpw quantization (llama/5747)
Kawrakow [Tue, 27 Feb 2024 14:34:24 +0000 (16:34 +0200)]
IQ4_XS: a 4.25 bpw quantization (llama/5747)

* Try IQ4_NL with blocks of 64 - does not look good

* iq4_xs: go to super-blocks of 256 and 6-bit scales for blocks of 32

* iq4_xs: CUDA works - 133.2 t/s

* iq4_xs: AVX2 dot product

* iq4_xs: ARM_NEON dot product

* iq4_nl: Metal implementation

As usual, Metal / Apple Silicon don't like my quants.

* iq3_xs: minor fix

* iq4_xs: shrink by using IQ3_S for attn_k and attn_q

* iq4_xs: revert using IQ3_S for attn_k and attn_v

PPL vs size is good, but CPU performance suffers: on M2 Max
TG-128 drops to 21.7 t/s from 28.8, and on a Ryzen-7950X
to 14.5 t/s from 15.8 t/s. On CUDA we have 135 t/s when
using IQ3_S vs 133 t/s with pure IQ4_XS.

* Fix CI

* iq4_xs: Added forgotten check for 256 divisibility

---------

Co-authored-by: Iwan Kawrakow <redacted>
16 months agocuda : replace remaining shfl_xor with calls to warp_reduce functions (llama/5744)
Engininja2 [Tue, 27 Feb 2024 13:22:45 +0000 (07:22 -0600)]
cuda : replace remaining shfl_xor with calls to warp_reduce functions (llama/5744)

16 months agoggml-quants : fix avx2 iq1_s vec_dot when compiled with gcc (llama/5742)
Engininja2 [Tue, 27 Feb 2024 12:50:18 +0000 (06:50 -0600)]
ggml-quants : fix avx2 iq1_s vec_dot when compiled with gcc (llama/5742)

16 months agoAdding IQ2_S and IQ2_M to complete coverage of the 2-3 bit quantization range (llama...
Kawrakow [Mon, 26 Feb 2024 16:28:38 +0000 (18:28 +0200)]
Adding IQ2_S and IQ2_M to complete coverage of the 2-3 bit quantization range (llama/5721)

* Adding IQ2_S and IQ2_M as a single cumulative commit

* Update examples/quantize/quantize.cpp

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

Co-authored-by: Iwan Kawrakow <redacted>
Co-authored-by: Georgi Gerganov <redacted>
16 months agoCUDA: fix DEBUG_CUDA_MALLOC (llama/5729)
Johannes Gäßler [Mon, 26 Feb 2024 14:36:38 +0000 (15:36 +0100)]
CUDA: fix DEBUG_CUDA_MALLOC (llama/5729)

16 months agoAdd support for soft_max ALiBi (llama/5639)
AidanBeltonS [Mon, 26 Feb 2024 14:02:11 +0000 (14:02 +0000)]
Add support for soft_max ALiBi (llama/5639)

* Add support for bias

* Update pre-processor

* rm commented code

* fix format

* fix CI

---------

Co-authored-by: Abhilash Majumder <redacted>
16 months agoggml-quants : provide ggml_vqtbl1q_u8 for 64bit compatibility (llama/5711)
Radosław Gryta [Sun, 25 Feb 2024 18:43:00 +0000 (19:43 +0100)]
ggml-quants : provide ggml_vqtbl1q_u8 for 64bit compatibility (llama/5711)

* [ggml-quants] Provide ggml_vqtbl1q_u8 for 64bit compatibility

vqtbl1q_u8 is not part of arm v7 neon library

* [android-example] Remove abi filter after arm v7a fix

* [github-workflows] Do not skip Android armeabi-v7a build

16 months agoadd google magika inference example (ggml/748)
slaren [Sun, 25 Feb 2024 19:41:35 +0000 (20:41 +0100)]
add google magika inference example (ggml/748)

* add magika inference example

* ggml : fix unaligned accesses in custom ops

* ggml : fix FP32 GELU for values that exceed the FP16 range

* use ggml_pool_1d

* add README

* Update README.md

* pad inputs if the files are too small

* cleanup

ggml-ci

16 months agostream.wasm : fix invalid memory access when no segments (#1902)
Andrew S [Mon, 26 Feb 2024 08:12:35 +0000 (02:12 -0600)]
stream.wasm : fix invalid memory access when no segments (#1902)

No segments may be returned when a smaller sample buffer (EG 2048 samples) is sent to the worker.

16 months agotalk-llama : sync llama.cpp
Georgi Gerganov [Sun, 25 Feb 2024 18:00:10 +0000 (20:00 +0200)]
talk-llama : sync llama.cpp

16 months agosync : ggml
Georgi Gerganov [Sun, 25 Feb 2024 17:59:34 +0000 (19:59 +0200)]
sync : ggml

16 months agosync : llama.cpp (ggml/0)
Georgi Gerganov [Sun, 25 Feb 2024 17:58:06 +0000 (19:58 +0200)]
sync : llama.cpp (ggml/0)

16 months agocode : normalize enum names (llama/5697)
Georgi Gerganov [Sun, 25 Feb 2024 10:09:09 +0000 (12:09 +0200)]
code : normalize enum names (llama/5697)

* coda : normalize enum names

ggml-ci

* code : cont

* code : cont

16 months agoIQ3_S: a much better alternative to Q3_K (llama/5676)
Kawrakow [Sat, 24 Feb 2024 14:23:52 +0000 (16:23 +0200)]
IQ3_S: a much better alternative to Q3_K (llama/5676)

* iq4_nl: squash commits for easier rebase

* Basics (quantize, dequantize)
* CUDA dequantize and dot product
* Slightly faster CUDA dot product (120 t/s)
* Switch to 6-bit scales
* Scalar dot product
* AVX2 dot product
* ARM_NEON dot product
* Works on metal, but still slow
* Slightly better Metal dot product
* Another small Metal improvement
* Metal dot product is getting there
* Faster CUDA dot product
* Add 1/8 ffn_down layers as Q5_K when no imatrix has been provided
* Report the actual bpw
* Add _xs mix that is 4.05 bpw for non-MoE models
* Remove IQ4_XS for now, slightly adjust kvalues_iq4nl
* AVX2 dot product uses Q8_0 instead of Q8_K
* Add to test-backend-ops
* Minor fix
* Also use use Q5_K for attn_output in MoE models
* Fixes after merging latest master
* Switching to blocks of 32
* AVX2 for blocks of 32
* Scaler dot product for blocks of 32
* ARM_NEON dot product for blocks of 32
* Metal kernels for blocks of 32
* Slightly faster Metal kernels

* Resurrecting iq3_xs

After all the experimentation, nothing was better than this.

* Minor PPL improvement via a block scale fudge factor

* Minor improvement via 3 neighbours

* iq3_xs: working scalar and AVX2 dot products

* iq3_xs: ARM_NEON dot product - works but extremely slow (10 t/s)

* iq3_xs: working Metal implementation

* Adding IQ3_M - IQ3_XS mix with mostly Q4_K

* iiq3_xs: a 3.4375 bpw variant

* iq3_xs: make CUDA work for new version

* iq3_xs: make scalar and AVX2 work for new version

* iq3_s: make ARM_NEON work with new version

* iq3_xs: make new version work on metal

Performance is very similar to Q3_K_S

* iq3_xs: tiny Metal speed improvement

* iq3_xs: tiny Metal speed improvement

* Fix stupid warning

* Q3_K_XS now uses a mix of IQ3_XS and IQ3_XXS

* iq3_xs: rename to iq3_s

* iq3_s: make tests pass

* Move Q3_K_XS mix to 3.25 bpw

* Attempt to fix failing tests

* Another attempt to fix the Windows builds

* Attempt to fix ROCm

* ROCm again

* iq3_s: partial fix for QK_K = 64

* iq3_s: make it work on metal for QK_K = 64

Pleasent surprise: the coding was super-block size independent,
so all it took was to delete some QK_K == 256 guards.

* Will this fix ROCm?

---------

Co-authored-by: Iwan Kawrakow <redacted>
16 months agoIntroduce backend GUIDs (ggml/743)
UEXTM.com [Sat, 24 Feb 2024 16:27:36 +0000 (11:27 -0500)]
Introduce backend GUIDs (ggml/743)

* Introduce backend GUIDs

Initial proposed implementation of backend GUIDs
(Discussed in https://github.com/ggerganov/ggml/pull/741)

Hardcoded CPU backend GUID (for now)
Change ggml_backend_is_cpu logic to use GUID

* Remove redundant functions

Remove redundant functions `ggml_backend_i::get_name` and `ggml_backend_guid` which are not desired for future expansion

* Add spaces to match style

Co-authored-by: slaren <redacted>
* Fix brace style to match

Co-authored-by: slaren <redacted>
* Add void to () in function signature

Co-authored-by: slaren <redacted>
* Add back ggml_backend_guid and make CPU_GUID a local static in ggml_backend_cpu_guid

* add guids to all backends

ggml-ci

---------

Co-authored-by: slaren <redacted>
16 months agotalk, talk-llama : pass text_to_speak as a file (#1865)
Tamotsu Takahashi [Sat, 24 Feb 2024 07:24:47 +0000 (16:24 +0900)]
talk, talk-llama : pass text_to_speak as a file (#1865)

* talk-llama: pass file instead of arg

it is too hard to quote text in a portable way

* talk-llama: pass heard_ok as a file

* talk-llama: let eleven-labs.py accept options

Options: -v voice, -s savefile, -p (--play)

* talk-llama: check installed commands in "speak"

Pass "-q" to eleven-labs.py to skip checking whether elevenlabs is installed

* talk-llama: pass voice_id again

in order to sync talk with talk-llama

* talk: sync with talk-llama

Passing text_to_speak as a file is safer and more portable
cf. https://stackoverflow.com/a/59036879/45375

* talk and talk-llama: get all installed voices in speak.ps1

* talk and talk-llama: get voices from api

* talk and talk-llama: add more options to eleven-labs.py

and remove DEFAULT_VOICE because it is deprecated (https://www.reddit.com/r/ElevenLabs/comments/1830abt/what_happened_to_bella/)

```
usage: eleven-labs.py [-q] [-l] [-h] [-n NAME | -v NUMBER] [-f KEY=VAL] [-s FILE | -p] [TEXTFILE]

options:
  -q, --quick           skip checking the required library

action:
  TEXTFILE              read the text file (default: stdin)
  -l, --list            show the list of voices and exit
  -h, --help            show this help and exit

voice selection:
  -n NAME, --name NAME  get a voice object by name (default: Arnold)
  -v NUMBER, --voice NUMBER
                        get a voice object by number (see --list)
  -f KEY=VAL, --filter KEY=VAL
                        filter voices by labels (default: "use case=narration")
                        this option can be used multiple times
                        filtering will be disabled if the first -f has no "=" (e.g. -f "any")

output:
  -s FILE, --save FILE  save the TTS to a file (default: audio.mp3)
  -p, --play            play the TTS with ffplay
```

* examples: add speak_with_file()

as suggested in the review

* talk and talk-llama: ignore to_speak.txt

16 months agowhisper : add SYCL support (#1863)
Abhilash Majumder [Fri, 23 Feb 2024 07:22:24 +0000 (12:52 +0530)]
whisper : add SYCL support (#1863)

* add changes from llama upstream

* add sycl abstraction

* add sycl build

* update cmake

* add sycl build config

* fix bug

* fix bug

* refactor build

* fix bug

* update build

* call build

* use sycl header

* add examples

* add target

* fix typecast in quant.c

* readd fp16 and readme

* fix quant typecast

* add sample

* add readme

* remove cxx file check

16 months agotalk-llama : sync llama.cpp
Georgi Gerganov [Thu, 22 Feb 2024 21:30:53 +0000 (23:30 +0200)]
talk-llama : sync llama.cpp

16 months agosync : ggml
Georgi Gerganov [Thu, 22 Feb 2024 21:25:38 +0000 (23:25 +0200)]
sync : ggml

16 months agoggml : always define ggml_fp16_t as uint16_t (llama/5666)
Georgi Gerganov [Thu, 22 Feb 2024 21:21:39 +0000 (23:21 +0200)]
ggml : always define ggml_fp16_t as uint16_t (llama/5666)

* ggml : always define ggml_fp16_t as uint16_t

ggml-ci

* ggml : cont

ggml-ci

* ggml : cont

* ggml : cont

ggml-ci

* ggml : cont

ggml-ci

* cuda : no longer ggml headers last

ggml-ci

* ggml : fix q6_K FP16 -> FP32 conversion

ggml-ci

* ggml : more FP16 -> FP32 conversion fixes

ggml-ci

16 months agoci : fix whitespace
Georgi Gerganov [Thu, 22 Feb 2024 18:20:34 +0000 (20:20 +0200)]
ci : fix whitespace

16 months agoggml : 32-bit arm compat (#1891)
Georgi Gerganov [Thu, 22 Feb 2024 16:31:40 +0000 (18:31 +0200)]
ggml : 32-bit arm compat (#1891)

* ggml : 32-bit arm compat

* ggml : add ggml_vqtbl1q_s8 impl

* ggml : cont

16 months agosync : ggml
Georgi Gerganov [Thu, 22 Feb 2024 13:15:38 +0000 (15:15 +0200)]
sync : ggml

16 months agosync : llama.cpp (ggml/0)
Georgi Gerganov [Wed, 21 Feb 2024 14:19:39 +0000 (16:19 +0200)]
sync : llama.cpp (ggml/0)

ggml-ci

16 months agoconext add name (llama/5624)
Meng, Hengyu [Wed, 21 Feb 2024 09:52:06 +0000 (17:52 +0800)]
conext add name (llama/5624)

* [SYCL] conext add name

* name should start with SYCL*

16 months agoUpdate ggml_sycl_op_mul_mat_vec_q (llama/5502)
AidanBeltonS [Tue, 20 Feb 2024 07:01:25 +0000 (07:01 +0000)]
Update ggml_sycl_op_mul_mat_vec_q (llama/5502)

* Update ggml_sycl_op_mul_mat_vec_q

* Apply suggestions from code review

Co-authored-by: Abhilash Majumder <redacted>
* revert suggestion on macro

* fix bug

* Add quant type GGML_TYPE_IQ1_S to unsupported

* fix format

---------

Co-authored-by: Abhilash Majumder <redacted>
16 months agoRefactor validation and enumeration platform checks into functions to clean up ggml_v...
0cc4m [Wed, 14 Feb 2024 19:57:17 +0000 (20:57 +0100)]
Refactor validation and enumeration platform checks into functions to clean up ggml_vk_instance_init()

16 months agoAdd check for VK_KHR_portability_enumeration for MoltenVK support
0cc4m [Sat, 10 Feb 2024 21:14:52 +0000 (22:14 +0100)]
Add check for VK_KHR_portability_enumeration for MoltenVK support

16 months agoAdd preprocessor checks for Apple devices.
Mathijs de Bruin [Tue, 6 Feb 2024 14:39:22 +0000 (14:39 +0000)]
Add preprocessor checks for Apple devices.

Based on work by @rbourgeat in https://github.com/ggerganov/llama.cpp/pull/5322/files

16 months agoResolve ErrorIncompatibleDriver with Vulkan on MacOS.
Mathijs de Bruin [Sat, 3 Feb 2024 18:00:11 +0000 (18:00 +0000)]
Resolve ErrorIncompatibleDriver with Vulkan on MacOS.

Refs:
- https://chat.openai.com/share/7020ce72-65fc-45ec-b7be-9d9d798a5f3f
- https://github.com/SaschaWillems/Vulkan/issues/954
- https://github.com/haasn/libplacebo/issues/128
- https://github.com/KhronosGroup/Vulkan-Samples/issues/476

16 months agoAllow for Vulkan build with Accelerate.
Mathijs de Bruin [Sat, 3 Feb 2024 17:56:46 +0000 (17:56 +0000)]
Allow for Vulkan build with Accelerate.

Closes #5304

16 months agocuda : ignore peer access already enabled errors (llama/5597)
slaren [Mon, 19 Feb 2024 22:40:26 +0000 (23:40 +0100)]
cuda : ignore peer access already enabled errors (llama/5597)

* cuda : ignore peer access already enabled errors

* fix hip

16 months agoggml : compute forward no longer pass src tensors (ggml/729)
Siddharth Ramakrishnan [Wed, 21 Feb 2024 12:34:53 +0000 (04:34 -0800)]
ggml : compute forward no longer pass src tensors (ggml/729)

* refactored compute forward to not pass in the src tensors each time

* fix merge issues with flags

* missed one place in the last commit to fix the is_param / flags issue

* minor spacing fix

* fixed some variable assignments so all tests locally are passing

* new change after merge fix

---------

Co-authored-by: siddharthvader <redacted>
16 months agoggml : fix conv_2d batch mode (ggml/737)
bssrdf [Tue, 20 Feb 2024 19:17:09 +0000 (14:17 -0500)]
ggml : fix conv_2d batch mode (ggml/737)

Co-authored-by: bssrdf <redacted>
16 months agoopenvino : fix convert-whisper-to-openvino.py (#1890)
st-gr [Thu, 22 Feb 2024 13:11:35 +0000 (05:11 -0800)]
openvino : fix convert-whisper-to-openvino.py (#1890)

Fix issue: Conversion from Whisper to OpenVino failed #1870

convert-whisper-to-openvino.py stopped working with OpenVINO version 2023.0.0-10926-b4452d56304-releases/2023/0 .

Error was: TypeError: load(): incompatible function arguments. The following argument types are supported:
    1. (self: openvino._pyopenvino.FrontEnd, path: object) -> ov::frontend::InputModel

Tested successfully with a large-v3 conversion.

Co-authored-by: Stefan Grundmann <redacted>
16 months agomain : fix file existence check in main.cpp (#1889)
Davidson Francis [Thu, 22 Feb 2024 13:01:08 +0000 (10:01 -0300)]
main : fix file existence check in main.cpp (#1889)

In commit dda4b0e of PR #1872, I've introduced a check for the
existence of files before loading the model. However, I haven't
considered the case where whisper.cpp might read from stdin as well,
and in such cases, the checks should ignore the "-" argument as it
does not represent a regular file.

Additionally, this commit removes the usage of 'stat()' in favor of
the recently introduced function 'is_file_exist()' in common.cpp from
PR #1871.

Apologies for the bug introduced in the previous PR and any
inconvenience it may have caused.

16 months agotalk-llama : sync llama.cpp
Georgi Gerganov [Tue, 20 Feb 2024 10:09:57 +0000 (12:09 +0200)]
talk-llama : sync llama.cpp

16 months agomake : fix CUBLAS link with WSL (#1878)
LBlue [Tue, 20 Feb 2024 10:05:38 +0000 (18:05 +0800)]
make : fix CUBLAS link with WSL (#1878)

16 months agosync : ggml
Georgi Gerganov [Mon, 19 Feb 2024 13:54:25 +0000 (15:54 +0200)]
sync : ggml

16 months agoggml : resolve merge conflicts (ggml/0)
Georgi Gerganov [Mon, 19 Feb 2024 13:33:51 +0000 (15:33 +0200)]
ggml : resolve merge conflicts (ggml/0)

ggml-ci

16 months agocommon : add IQ1_S (ggml/0)
Georgi Gerganov [Mon, 19 Feb 2024 13:27:37 +0000 (15:27 +0200)]
common : add IQ1_S (ggml/0)

ggml-ci

16 months agoci : enable -Werror for CUDA builds (llama/5579)
Georgi Gerganov [Mon, 19 Feb 2024 12:45:41 +0000 (14:45 +0200)]
ci : enable -Werror for CUDA builds (llama/5579)

* cmake : pass -Werror through -Xcompiler

ggml-ci

* make, cmake : enable CUDA errors on warnings

ggml-ci

16 months agocuda, metal : fix nans in soft_max (llama/5574)
slaren [Mon, 19 Feb 2024 08:04:45 +0000 (09:04 +0100)]
cuda, metal : fix nans in soft_max (llama/5574)

* cuda : fix nans in soft_max

* metal : fix nans in soft_max

---------

Co-authored-by: Georgi Gerganov <redacted>
16 months agoggml : android and old glibc NUMA incompatibility bugfixes (llama/5557)
bmwl [Mon, 19 Feb 2024 07:38:32 +0000 (23:38 -0800)]
ggml : android and old glibc NUMA incompatibility bugfixes (llama/5557)

* #ifdef out some code NUMA blocks for Android due to lack of support

* added in some __ANDROID__ if def gates around numa code and forced GLIBC prior to 2.29 to use a syscall for getcpu instead of the wrapper

* Changed gates on numa platform specific stuff to __gnu_linux__ to skip any platforms without glibc

* harmonizing #if defined blocks for numa code to __gnu_linux__ since that's the only model that's being followed anyways

---------

Co-authored-by: root <redacted>
16 months agoggml : restore vec dot stride arg names (llama/5453)
Georgi Gerganov [Sun, 18 Feb 2024 20:58:57 +0000 (22:58 +0200)]
ggml : restore vec dot stride arg names (llama/5453)

16 months agoci : fix wikitext url + compile warnings (llama/5569)
Georgi Gerganov [Sun, 18 Feb 2024 20:39:30 +0000 (22:39 +0200)]
ci : fix wikitext url + compile warnings (llama/5569)

ggml-ci

16 months agometal : fix unused warnings (llama/0)
Georgi Gerganov [Sun, 18 Feb 2024 19:39:58 +0000 (21:39 +0200)]
metal : fix unused warnings (llama/0)

16 months agoggml, common, examples, tests : fixed type arguments in printf (llama/5528)
Herman Semenov [Sun, 18 Feb 2024 16:20:12 +0000 (16:20 +0000)]
ggml, common, examples, tests : fixed type arguments in printf (llama/5528)

16 months ago1.5 bit quantization (llama/5453)
Kawrakow [Sun, 18 Feb 2024 16:16:55 +0000 (18:16 +0200)]
1.5 bit quantization (llama/5453)

* iq1_s: WIP basics

* iq1_s: CUDA is working

* iq1_s: scalar CPU dot product

* iq1_s: WIP AVX2 dot product - something is not right

* Fix tests

* Fix shadow warnings

* Fix after merge with latest master

* iq1_s: AVX2 finally works

* iq1_s: ARM_NEON dot product. Works, but not very fast

* iq1_s: better grid

* iq1_s: use IQ2_XXS for attn_output

At a cost of 0.04 extra bpw this gives a big improvement in PPL.

* iq1_s: Metal basics

Dequantize works, but not dot product

* iq1_s: Metal works, but quite slow

As usual, Apple Silicon does not like the code I write.

* iq1_s: Tests

* iq1_s: slightly faster dot product

---------

Co-authored-by: Iwan Kawrakow <redacted>
16 months agoggml : add ALiBi support for ggml_soft_max_ext (llama/5488)
Georgi Gerganov [Mon, 19 Feb 2024 13:18:09 +0000 (15:18 +0200)]
ggml : add ALiBi support for ggml_soft_max_ext (llama/5488)

16 months agoci : add an option to fail on compile warning (llama/3952)
Ananta Bastola [Sat, 17 Feb 2024 21:03:14 +0000 (16:03 -0500)]
ci : add an option to fail on compile warning (llama/3952)

* feat(ci): add an option to fail on compile warning

* Update CMakeLists.txt

* minor : fix compile warnings

ggml-ci

* ggml : fix unreachable code warnings

ggml-ci

* ci : disable fatal warnings for windows, ios and tvos

* ggml : fix strncpy warning

* ci : disable fatal warnings for MPI build

* ci : add fatal warnings to ggml-ci

ggml-ci

---------

Co-authored-by: Georgi Gerganov <redacted>
16 months agocmake : fix VULKAN and ROCm builds (llama/5525)
Georgi Gerganov [Fri, 16 Feb 2024 17:05:56 +0000 (19:05 +0200)]
cmake : fix VULKAN and ROCm builds (llama/5525)

* cmake : fix VULKAN and ROCm builds

* cmake : fix (cont)

* vulkan : fix compile warnings

ggml-ci

* cmake : fix

ggml-ci

* cmake : minor

ggml-ci