Commit Graph

423 Commits

Author SHA1 Message Date
Kawrakow 13d7178db9
Fix Gemma4-MoE graph parallel (#1604) 2026-04-09 17:31:09 +02:00
Samuel Oliveira Alves 557b674f63
Add llama_context to MTP (#1601)
* wip: separate llama_context for MTP with graph reuse

* wip: fix KV cache desync with separate MTP context

* refactor: remove dead mtp logic code, encapsulate KV mirroring

* mtp-context: derive args directly from the main model's context

* mtp: fix kv cache positions

* clean small comments

* minor refactor for context shift
2026-04-09 15:33:56 +02:00
Kawrakow 9b5785ad6b
Gemma4 tokenizer fixes (#1603) 2026-04-09 15:33:28 +02:00
Kawrakow 847e191936
Graph parallel for Gemma4 MoE (#1600)
* Use build_std_attention for Gemma4 when possible

It is possible for the 26b MoE and 31b dense models.
It is not possible for the E4B/E2B vaiants because they
don't have KV cache in each layer.

* Standardize Gemma4 dense ffn

* WIP: Gemma4 split mode graph

Runs but produces NaNs

* WIP: Gemma4 split mode graph

Runs but very high PPL. At least it is no longer NaN.

* WIP

* This works!

* Put attn_norm, attn_post_norm, ffn_norm, ffn_post_norm on all GPUs

* Fix crash when saving/loading KV cache

* WIP: split mode graph for Gemma4-MoE - crashes

* Split mode graph for Gemma4-MoE - this works

* Disable SWA optimization

Something goes wrong there

* Consolidate MoE and dense graph parallel
2026-04-09 14:07:29 +02:00
Kawrakow 9db5d9907e
Mixed KV cache (#1599) 2026-04-09 09:33:17 +02:00
Kawrakow 5950d0259e
Graph parallel for Gemma4-31B (#1596)
* Use build_std_attention for Gemma4 when possible

It is possible for the 26b MoE and 31b dense models.
It is not possible for the E4B/E2B vaiants because they
don't have KV cache in each layer.

* Standardize Gemma4 dense ffn

* WIP: Gemma4 split mode graph

Runs but produces NaNs

* WIP: Gemma4 split mode graph

Runs but very high PPL. At least it is no longer NaN.

* WIP

* This works!

* Put attn_norm, attn_post_norm, ffn_norm, ffn_post_norm on all GPUs

* Fix crash when saving/loading KV cache
2026-04-09 08:00:22 +02:00
Nexes the Elder 0a6e4335f7
Little maintenance (#1579)
* Little maintenance

* llama-quantize : Add the missing items in the help

* Add GGML_MAX_CONTEXTS define in the general cmakelist.txt

* Make the KV cache (CPU) based warnings clearer

* Correct placement of GGML_MAX_CONTEXTS definition

* Revert wrong indents

This reverts commit d0728cbb6c6d4d6d8dc13f062e542d232647a38d.

* Moving the GGML_MAX_CONTEXTS definition to src/CMakeLists.txt

* Update warning message for unsupported KV cache types

* forgotten antislash
2026-04-08 07:58:49 +02:00
Kawrakow 86e33fd6f4
Initial Gemma4 support (#1581)
* Gemma4: WIP

* Gemma4: WIP - runs with totally wrong results

* Gemma4: WIP - add CPU 512, 512 FA

* Gemma4: WIP

It gives a meaningful response in llama-cli, but PPL is still much too
high. Is this due to tokenizer issues?

* Gemma4: this works

I had forgotten the softcap on the final output.

* Remove log

* Gemma4: WIP E4B/E2B

* Gemma4: Q4B/E2B appear to work now

* gemma4: tokenizer fixes
2026-04-06 10:01:08 +02:00
Kawrakow 90ec1b80c4
Bonsai support (AVX2, generic) (#1570)
* Bonsai support (AVX2, generic)

* Fix ARM build

---------

Co-authored-by: Iwan Kawrakow <iwan.kawrakow@gmail.com>
2026-04-02 16:54:08 +02:00
Kawrakow 6ea7f321e8
Fix unknown tensor type warnings (#1565) 2026-04-01 09:45:32 +02:00
Kawrakow 9660eb4487
Control compute buffer sizes for large batches (#1560)
* Worst graph output tokens

* This is better
2026-04-01 07:57:52 +02:00
Kawrakow 8b575c4b1f
Fix re-quantizing a model using row-interleaved quants (#1561) 2026-03-31 15:35:10 +02:00
Kawrakow 7831c69e27
Do not override mmap if GGML_CUDA_NO_PINNED is set (#1546) 2026-03-29 08:04:43 +02:00
Samuel Oliveira Alves c050bb9f3f
graph: Remove duplicate functions in MTP (#1530) 2026-03-28 15:43:24 +01:00
Kawrakow f83a29ff5a
Honor manual splits (#1540) 2026-03-28 13:03:43 +01:00
Kawrakow a95981013a
V-cache Hadamard transform (#1527) 2026-03-28 11:28:50 +01:00
Kawrakow e46601cb19
Log probabilities on token sampling crash (#1519)
* Log probabilities on token sampling crash

* Typo
2026-03-26 14:34:41 +01:00
Kawrakow c06067fa14
Ignore MTP layer(s) when computing required memory (#1516) 2026-03-26 10:42:51 +01:00
Kawrakow 095bd3d3b2
Use pinned memory also with mmap when tensor overrides (#1510) 2026-03-26 06:15:54 +01:00
Kawrakow a84d90a4b8
Fix bug introduced in #1506 (#1515) 2026-03-26 06:04:51 +01:00
Kawrakow dd75fd054c
Fix KV cache for split mode graph with layers left on CPU (#1506) 2026-03-25 17:53:45 +01:00
Kawrakow d66dc7c0c4
CUDA: restore pinned memory usage for tensor overrides (#1508) 2026-03-25 17:18:32 +01:00
Samuel Oliveira Alves 1f3e832cb3
Improve mtp acceptance rate (#1499)
* wip: port MTP architecture

Ports the Multi-Token Prediction (MTP) architecture to the older `llama.cpp` codebase used by `ikllama`.

Changes include:
- Updating `llama_batch` to support `mtp_params`.
- Modifying `llama_decode_internal` (and `encode`) to handle MTP operations (Warmup, Update, Draft).
- Adding public APIs for MTP state management (`llama_set_draft_input_hidden_state`).
- Adapting the embedding extraction logic to skip MTP update passes.

* Refactors `server_slot` to support generic speculative decoding (MTP or Draft Model).

* core: enable hybrid outputs (logits + embeddings) for MTP support

* fix(mtp): correct KV-cache slot finding for updates

* fix(mtp): persist hidden states to prevent context corruption during drafting

* refactor(mtp): clean unused code

* fix(mtp): update server to new functions name

* fix(mtp): fix graph and save hidden state

* mtp: refactor integration, context params and kv cache search

* mtp: fix hidden state extraction and speculative acceptance flow

* server: fix MTP warmup for long prompts and reset token buffer

* llama: refactor MTP operation state to context parameters

* server: fix n_past calculation in MTP acceptance

* llama: fix mtp enable flags

* speculative: refactor MTP to use common_speculative interface

* context: remove unused signatures

* clip: fix deprecated enum-enum conversion warning

* common: fix format string crash in help message

* context: fix mtp activation logic

* llamat: always use the extracted embedding

* llama: get all embeddings to kv cache

* llama: revert logit to not run mtp for not supported arch

* llama: allocate all the n_outputs for MTP

* wip

* server-context: get only the last embedding for hidden state

* ggml-backend: fix array of bounds in debug build

* server-context: run mt kv update to each prompt batch

* revert segmentation fault fixes

* glm-mtp(feat): optimize graph embedding and recursive drafting
2026-03-25 10:20:22 +01:00
Kawrakow b6bac1aedb
Auto-fit for dense models (#1504)
* Auto-fit for dense models

* Minor
2026-03-25 08:28:15 +01:00
Kawrakow 86f4f516e5
Auto-fit offloaded tensors to available VRAM (MoE models) (#1501)
* WIP: automatically fit model in available VRAM

* WIP

* This seems pretty solid
2026-03-25 07:29:29 +01:00
Kawrakow 233225db8f
Take into account layer sizes for setting GPU layers (count 2) (#1498)
* Also take into account KV cache

* Take into account attn_wkv_b and mla = 3 compute buffers

* WIP

* Minor
2026-03-24 08:18:28 +01:00
Nexes the Elder 094f76ee86
Cleaner log for adjusted splits (#1494)
* sweep-bench: add more skipped patterns to --minilog

* cleaner log for adjusted splits

* Add totalization for adjusted splits

* Clean up semicolons

* Addition for totalizer ^^

* Change accordingly to review

* Forgotten leftover removed

* 'total' instead of 'totalized'
2026-03-24 07:49:40 +01:00
Kawrakow b7a2bde4cc
Take into account layer sizes for setting GPU layers (cont) (#1476)
* Also take into account KV cache

* Take into account attn_wkv_b and mla = 3 compute buffers
2026-03-23 17:46:53 +01:00
Kawrakow 3633a7cfca
Log HAVE_FANCY_SIMD via LLAMA_LOG_INFO (#1492) 2026-03-23 08:43:29 +01:00
gapeleon 716ecd6457
Added split mode graph for Command-R/R+ models. (#1491) 2026-03-23 08:10:41 +01:00
Kawrakow 56e026f6ba
Fix bug when splitting merged ffn_up/gate_exps tensors (#1479) 2026-03-20 18:54:45 +01:00
Kawrakow 0871ab2964
Take into account layer sizes for setting GPU layers (#1466)
* Take into account layer sizes for setting GPU layers

* Fix bug
2026-03-20 09:38:14 +01:00
Kawrakow b56a3c2dc9
Better barrier (#1456) 2026-03-19 07:33:00 +01:00
Kawrakow 9b7db9bc3f
Better --n-cpu-moe (#1464) 2026-03-19 06:57:01 +01:00
firecoperana f9b7fe9749
llama: add --dry-run option (#1462)
Co-authored-by: firecoperana <firecoperana>
2026-03-18 17:20:17 +01:00
Kawrakow 56477c7a9e
Mistral 4 support (#1450)
* WIP: mistral4

* CPU FA

* CUDA FA 320, 256
2026-03-18 07:32:39 +01:00
Kawrakow f6ca2fa8c0
Qwen-3.5/Next tweaks (#1447)
* Allow using -rtr and -muge together

* Various Qwen-3.5 tweaks

* No need to make v, g, beta contiguous

* Adjust NEON delta-net to non-contiguous v, g, b

* Cleanup

---------

Co-authored-by: Iwan Kawrakow <iwan.kawrakow@gmail.com>
2026-03-18 07:32:17 +01:00
Kawrakow 54bcafee16
Allow using -rtr and -muge together (#1444) 2026-03-16 18:26:26 +01:00
Kawrakow e3f5f3d823
Minor delta-net tweaks (#1429) 2026-03-16 13:59:55 +01:00
Kawrakow d83b0172b1
Attempt to fix #1438 (#1439) 2026-03-16 08:34:17 +01:00
Kawrakow 56f4e9e673
Fix the fix (#1433) 2026-03-15 17:33:10 +01:00
Kawrakow edf54621d2
Fix long max. context bottleneck (#1430) 2026-03-15 17:18:27 +01:00
Kawrakow 10a8f5f8f1
Fix hybrid graph parallel + muge (#1426) 2026-03-14 18:15:09 +01:00
dungquixote42 be2940f57a
Adaptive P sampler: update review logic, delete old code comments, put prep stage after logit bias (#1386)
* simpler n_rewind logic, delete old comments

* use more consistent names, add updt_w_cur to json schema

* align comments

* refactor review logic, update struct/variable names

* revert cosmetic changes

* check enable/disable in llama_prep_adaptive_p_impl()

* delete extra whitespaces after statement

* show target in debug prints

* more concise debug print

* delete old comments

* update with loop instead of move()

* comment out all adaptive p debug prints

* more debug prints

* move review() variables: common_sampler struct -> common_sampler_review() args

* match n_unsent type

* fix merge bugs, delete adaptive p references in buffer_and_check_string_ban()

* restore accidental erasure

* Revert "adaptive p: collect probability before logit bias"

This reverts commit 1434878461c49d1a2a9047fc15d5e7b78421fd2a.
2026-03-14 12:34:12 +01:00
Kawrakow 46018f89ed
Fuse SILU and SSM_CONV (CPU) (#1421) 2026-03-14 08:27:32 +01:00
Kawrakow c2b8e95700
Be able to use imatrix computed with merged ffn_gate_up_exps (#1419)
* Be able to use imatrix computed with merged ffn_gate_up_exps

* Also the other way around
2026-03-13 17:57:56 +01:00
Kawrakow 9f4656fa7d
Faster top_n_sigma sampler (#1417)
* Faster top_n_sigma sampler

* This is better: 4000 t/s -> 8000 t/s
2026-03-13 10:53:45 +01:00
Kawrakow 7fab617684
Enable split mode graph for on-the-fly merged up/gate experts (#1413)
* Split mode graph for on-the-fly merged ffn_up/gate_exps

* Cleanup

* Also handle merged bias
2026-03-13 08:11:46 +01:00
firecoperana 433531ddae
server : support multi-modal context checkpoints and prompt caching (#1398)
* server : support multi-modal context checkpoints and prompt caching

do not create checkpoint right after image processing

improve mtmd check for slot ops

fix context shift

do not abort if template parse failed

* change to debug message when detecting ban token

---------

Co-authored-by: firecoperana <firecoperana>
2026-03-13 08:07:57 +01:00
Kawrakow c85361fe2f
Split mode graph for models with pre-merged ffn_up/ffn_gate experts (#1412)
* WIP: support pre-merged up/gate experts

Haha, mainline has elected to arrange the merged tensors
the other way around compared to what I had done in the on-the-fly merge.

* Change the order of on-the-fly packed up/gate

* OpenAI

* CUDA TG

* CPU

* Split mode graph for models with pre-merged ffn_up/ffn_gate experts
2026-03-12 17:26:48 +01:00