Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
a258721
vulkan: add INTEL_XE1 arch enum and enable coopmat1 on Intel Xe-LPG P…
fish-jiang Jun 26, 2026
6d2ea21
vulkan: opt mul_mat_vecq for mi50 (llama/22933)
chraac Jun 26, 2026
e02b405
openvino: Update to OV 2026.2.1, self-contained release packages, ope…
ravi9 Jun 26, 2026
6565140
sched : reintroduce less synchronizations during split compute (llama…
aendk Jun 26, 2026
fa7cfd1
vulkan: fix step operator for 0 input (llama/25036)
0cc4m Jun 27, 2026
cfd6a43
sycl : fix failed ut cases of norm (llama/25044)
arthw Jun 27, 2026
65b3e6b
Added a cudaMemcpy2DAsync fast path to ggml_cuda_cpy (llama/25057)
gaugarg-nv Jun 27, 2026
574f0df
opencl: flash attention improvement (llama/25069)
wanghqc Jun 27, 2026
f1b813a
vulkan: use flops instead of weight tensor size for submission heuris…
0cc4m Jun 29, 2026
e619be8
Revert "sched : reintroduce less synchronizations during split comput…
ORippler Jun 30, 2026
44e3325
ggml-webgpu: add support for NVFP4 (llama/25143)
yomaytk Jun 30, 2026
d9f59cf
HIP: use hipBLAS for dense prefill on gfx900, keep MMQ for MoE (llama…
DEV-DUFORD Jun 30, 2026
e2fc68d
vulkan: roll bk loop in matmul for asahi linux (llama/24663)
xingjianll Jun 30, 2026
f1929d8
CUDA: fix Gemma E4B MTP FlashAttention (llama/25148)
JohannesGaessler Jun 30, 2026
8b3f270
CUDA: fix get_rows_back for tables with more than 65535 rows (grid-y …
mattjallo Jun 30, 2026
bb9ad3c
cuda : prevent integer truncation and overflow errors when using KQ m…
fairydreaming Jun 30, 2026
369762e
opencl: initial q1_0 support (llama/25160)
lhez Jul 1, 2026
7481d6f
ggml-cpu: add AVX2 optimization for nvfp4 dot product and use UE4M3 L…
ragz4125 Jul 1, 2026
213f87a
CUDA: consistent use of __restrict__ + PDL for FA (llama/25185)
JohannesGaessler Jul 1, 2026
60a9720
hexagon: flash attention rework (optimizations, accuracy improvements…
max-krasnyansky Jul 1, 2026
eef3bee
opencl: allow loading precompiled binary kernels from library (llama/…
lhez Jul 1, 2026
3d3ab46
Remove redundant CUDA copies after gated_delta_net. (llama/23940)
gaugarg-nv Jul 3, 2026
9376485
cuda: enable topk-moe fusion for 288 experts (llama/25267)
pwilkin Jul 3, 2026
0dfafc7
ggml : fix broken CPU concat implementation for quantized types (llam…
fairydreaming Jul 4, 2026
ee94c39
cuda : concat implementation for quantized types (llama/25303)
fairydreaming Jul 5, 2026
52ce7c4
ggml: Update VMM Pool allocation ggml-cuda.cu - Turing P2P access fix…
VexxieCode Jul 5, 2026
e1670e8
ggml : fix tensor-parallel + -ncmoe crash on MoE models (llama/25028)
liminfei-amd Jul 5, 2026
27cee35
abort if we see a multi buffer (llama/25276)
netrunnereve Jul 5, 2026
be1e13c
ggml-cuda: optimize conv_transpose_1d indexing (llama/25310)
adavyas Jul 6, 2026
d4a4325
ggml-hip: enable -ffast-math for HIP builds (llama/23862)
a-huk Jul 6, 2026
8666e2b
vulkan: fix 32-bit integer overflow in CEIL_DIV (llama/25245)
hokanosekai Jul 6, 2026
fbfc85f
ggml-cpu: Enable tiled matmul on AIX (llama/25199)
shalinib-ibm Jul 6, 2026
36c215f
ggml-cpu: use UE4M3 LUT in ARM NVFP4 dot product (llama/25331)
ragz4125 Jul 6, 2026
238e08a
CUDA: extend K-type validation to V-types for flash attention (llama/…
sanmai Jul 6, 2026
305b17c
CUDA: remove -sm row, refactor cuBLAS (llama/24216)
JohannesGaessler Jul 6, 2026
abd0745
metal: add col2im_1d op (f32/f16/bf16) (llama/25176)
ServeurpersoCom Jul 6, 2026
9d3a1a2
opencl: general flash attention decode performance optimizations (lla…
wanghqc Jul 7, 2026
5a4f7e0
vulkan : check src0 type in GGML_OP_SET_ROWS to avoid failures due to…
fairydreaming Jul 7, 2026
65d6ee8
ggml : make ggml_time_init idempotent (llama/24422)
aisk Jul 7, 2026
9ebe7cd
sycl : rename the env vars from "disable" to "enable" (llama/25042)
arthw Jul 7, 2026
c45ed2c
sycl : use sycl func to fix AOT double type issue (llama/25081)
arthw Jul 7, 2026
622aed8
sycl : enhance argsort to support all UT cases (llama/25125)
arthw Jul 7, 2026
1a1dccd
fix unsupport ACC UT cases for noncontiguous (llama/25124)
arthw Jul 7, 2026
d8fe932
sycl : set K_QUANTS_PER_ITERATION to 1 on DMMV path (llama/25063)
malsbat Jul 7, 2026
ce4fdf6
support OP cross_entropy_loss, cross_entropy_loss_back (llama/25236)
arthw Jul 7, 2026
b0e1737
support op col2im_1d (llama/25264)
arthw Jul 7, 2026
f52bd31
fix unsupported UT cases of CONT & CPY (llama/25231)
arthw Jul 7, 2026
82325be
ggml-hip : add -fno-finite-math-only alongside -ffast-math (llama/25373)
asf0 Jul 7, 2026
ccf9d4f
CUDA: Fuse MMVQ post-scale for NVFP4 (llama/24481)
ORippler Jul 7, 2026
5551202
Add Q2_0 quantization: type definition and CPU backend (llama/24448)
khosravipasha Jul 7, 2026
5154e55
opencl: fix potential crash in aos reconstruct (llama/25383)
lhez Jul 8, 2026
b127bbd
ggml : add support for CPU f16->f16 GGML_OP_SET_ROWS (llama/25344)
fairydreaming Jul 8, 2026
43117c1
ggml : fix A indexing in simd_gemm scalar tail-column path (llama/25390)
tyronecai Jul 8, 2026
ae44bd7
metal : add set_rows with src0 f16 (llama/25434)
fairydreaming Jul 8, 2026
7dc9a0f
cuda : add support for f16->f16 GGML_OP_SET_ROWS (llama/25367)
fairydreaming Jul 8, 2026
ee88009
hexagon: new vtcm layouts and improved pipelines for MUL_MAT, MUL_MAT…
max-krasnyansky Jul 8, 2026
066fe13
vulkan: for small AMD GPUs, reduce submission threshold based on CU c…
0cc4m Jul 8, 2026
35b7c38
opencl: ragged-tile MoE prefill FP16 GEMM optimization (skip padded e…
wanghqc Jul 8, 2026
111b05f
vulkan: disable FA mask_opt on GCN to improve performance (llama/24362)
0cc4m Jul 8, 2026
00e2ea2
opencl: Q6_K GEMM/GEMV fix for ne01 of weights that are not multiples…
wanghqc Jul 8, 2026
d0f81e0
ggml-webgpu: tune subgroup split (d_split) in flash_attn_vec (llama/2…
yomaytk Jul 8, 2026
d71436a
hexagon: add VISION RoPE support (llama/25216)
aparmp-quic Jul 9, 2026
35ab8c1
cuda: align snake fusion matcher with the other backends (llama/25460)
ServeurpersoCom Jul 9, 2026
7a424b1
ggml-hip: enable -funsafe-math-optimizations (llama/24668)
RapidMark Jul 9, 2026
0143229
metal : add CONV_2D_DW (depthwise convolution) support (llama/21565)
Sou-ly Jul 9, 2026
58cc0a6
Only index by compile times + always multiply/add (llama/25445)
ORippler Jul 9, 2026
40d987e
common : adapt to q2_0 (ggml/0)
ggerganov Jul 9, 2026
535eab9
ggml : fix conv 2d dw (llama/25490)
ggerganov Jul 9, 2026
a75cf2b
ggml : bump version to 0.16.0 (ggml/1559)
ggerganov Jul 10, 2026
be9dc6e
sync : ggml
ggerganov Jul 10, 2026
08c6dc1
talk-llama : sync llama.cpp
ggerganov Jul 10, 2026
558b5f9
ggml : use ggml_vqtbl1q_u8 for 32-bit compat (#0)
ggerganov Jul 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/common-ggml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ bool ggml_common_quantize_0(
case GGML_FTYPE_MOSTLY_MXFP4:
case GGML_FTYPE_MOSTLY_NVFP4:
case GGML_FTYPE_MOSTLY_Q1_0:
case GGML_FTYPE_MOSTLY_Q2_0:
{
fprintf(stderr, "%s: invalid model type %d\n", __func__, ftype);
return false;
Expand Down Expand Up @@ -217,6 +218,7 @@ bool ggml_common_quantize_0(
case GGML_TYPE_MXFP4:
case GGML_TYPE_NVFP4:
case GGML_TYPE_Q1_0:
case GGML_TYPE_Q2_0:
case GGML_TYPE_COUNT:
{
fprintf(stderr, "%s: unsupported quantization type %d (%s)\n", __func__, ttype, ggml_type_name((ggml_type) ttype));
Expand Down
1 change: 1 addition & 0 deletions examples/talk-llama/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ if (WHISPER_SDL2)
llama-kv-cache.cpp
llama-kv-cache-iswa.cpp
llama-kv-cache-dsa.cpp
llama-kv-cache-dsv4.cpp
llama-memory-recurrent.cpp
llama-memory-hybrid.cpp
llama-memory-hybrid-iswa.cpp
Expand Down
57 changes: 57 additions & 0 deletions examples/talk-llama/llama-arch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ static const std::map<llm_arch, const char *> LLM_ARCH_NAMES = {
{ LLM_ARCH_DEEPSEEK2, "deepseek2" },
{ LLM_ARCH_DEEPSEEK2OCR, "deepseek2-ocr" },
{ LLM_ARCH_DEEPSEEK32, "deepseek32" },
{ LLM_ARCH_DEEPSEEK4, "deepseek4" },
{ LLM_ARCH_CHATGLM, "chatglm" },
{ LLM_ARCH_GLM4, "glm4" },
{ LLM_ARCH_GLM4_MOE, "glm4moe" },
Expand Down Expand Up @@ -129,6 +130,7 @@ static const std::map<llm_arch, const char *> LLM_ARCH_NAMES = {
{ LLM_ARCH_PANGU_EMBED, "pangu-embedded" },
{ LLM_ARCH_MISTRAL3, "mistral3" },
{ LLM_ARCH_EAGLE3, "eagle3" },
{ LLM_ARCH_DFLASH, "dflash" },
{ LLM_ARCH_MISTRAL4, "mistral4" },
{ LLM_ARCH_PADDLEOCR, "paddleocr" },
{ LLM_ARCH_MIMO2, "mimo2" },
Expand Down Expand Up @@ -249,9 +251,19 @@ static const std::map<llm_kv, const char *> LLM_KV_NAMES = {
{ LLM_KV_ATTENTION_INDEXER_HEAD_COUNT, "%s.attention.indexer.head_count" },
{ LLM_KV_ATTENTION_INDEXER_KEY_LENGTH, "%s.attention.indexer.key_length" },
{ LLM_KV_ATTENTION_INDEXER_TOP_K, "%s.attention.indexer.top_k" },
{ LLM_KV_ATTENTION_OUTPUT_GROUP_COUNT, "%s.attention.output_group_count" },
{ LLM_KV_ATTENTION_OUTPUT_LORA_RANK, "%s.attention.output_lora_rank" },
{ LLM_KV_ATTENTION_COMPRESS_ROPE_FREQ_BASE, "%s.attention.compress_rope_freq_base" },
{ LLM_KV_ATTENTION_COMPRESS_RATIOS, "%s.attention.compress_ratios" },
{ LLM_KV_ATTENTION_SHARED_KV_LAYERS, "%s.attention.shared_kv_layers" },
{ LLM_KV_ATTENTION_RECURRENT_LAYERS, "%s.attention.recurrent_layers" },

{ LLM_KV_HYPER_CONNECTION_COUNT, "%s.hyper_connection.count" },
{ LLM_KV_HYPER_CONNECTION_SINKHORN_ITERATIONS, "%s.hyper_connection.sinkhorn_iterations" },
{ LLM_KV_HYPER_CONNECTION_EPSILON, "%s.hyper_connection.epsilon" },

{ LLM_KV_HASH_LAYER_COUNT, "%s.hash_layer_count" },

{ LLM_KV_ROPE_DIMENSION_COUNT, "%s.rope.dimension_count" },
{ LLM_KV_ROPE_DIMENSION_COUNT_SWA, "%s.rope.dimension_count_swa" },
{ LLM_KV_ROPE_DIMENSION_SECTIONS, "%s.rope.dimension_sections" },
Expand Down Expand Up @@ -439,6 +451,23 @@ static const std::map<llm_tensor, const char *> LLM_TENSOR_NAMES = {
{ LLM_TENSOR_ATTN_Q_B, "blk.%d.attn_q_b" },
{ LLM_TENSOR_ATTN_KV_A_MQA, "blk.%d.attn_kv_a_mqa" },
{ LLM_TENSOR_ATTN_KV_B, "blk.%d.attn_kv_b" },
{ LLM_TENSOR_ATTN_KV, "blk.%d.attn_kv" },
{ LLM_TENSOR_ATTN_KV_NORM, "blk.%d.attn_kv_a_norm" },
{ LLM_TENSOR_ATTN_OUT_A, "blk.%d.attn_output_a" },
{ LLM_TENSOR_ATTN_OUT_B, "blk.%d.attn_output_b" },
{ LLM_TENSOR_HC_HEAD_FN, "output_hc_fn" },
{ LLM_TENSOR_HC_HEAD_BASE, "output_hc_base" },
{ LLM_TENSOR_HC_HEAD_SCALE, "output_hc_scale" },
{ LLM_TENSOR_HC_ATTN_FN, "blk.%d.hc_attn_fn" },
{ LLM_TENSOR_HC_ATTN_BASE, "blk.%d.hc_attn_base" },
{ LLM_TENSOR_HC_ATTN_SCALE, "blk.%d.hc_attn_scale" },
{ LLM_TENSOR_HC_FFN_FN, "blk.%d.hc_ffn_fn" },
{ LLM_TENSOR_HC_FFN_BASE, "blk.%d.hc_ffn_base" },
{ LLM_TENSOR_HC_FFN_SCALE, "blk.%d.hc_ffn_scale" },
{ LLM_TENSOR_ATTN_COMPRESSOR_WKV, "blk.%d.attn_compressor_kv" },
{ LLM_TENSOR_ATTN_COMPRESSOR_WGATE, "blk.%d.attn_compressor_gate" },
{ LLM_TENSOR_ATTN_COMPRESSOR_APE, "blk.%d.attn_compressor_ape" },
{ LLM_TENSOR_ATTN_COMPRESSOR_NORM, "blk.%d.attn_compressor_norm" },
{ LLM_TENSOR_PER_LAYER_TOKEN_EMBD, "per_layer_token_embd" },
{ LLM_TENSOR_PER_LAYER_MODEL_PROJ, "per_layer_model_proj" },
{ LLM_TENSOR_PER_LAYER_PROJ_NORM, "per_layer_proj_norm" },
Expand Down Expand Up @@ -565,6 +594,11 @@ static const std::map<llm_tensor, const char *> LLM_TENSOR_NAMES = {
{ LLM_TENSOR_INDEXER_PROJ, "blk.%d.indexer.proj" },
{ LLM_TENSOR_INDEXER_ATTN_K, "blk.%d.indexer.attn_k" },
{ LLM_TENSOR_INDEXER_ATTN_Q_B, "blk.%d.indexer.attn_q_b" },
{ LLM_TENSOR_INDEXER_COMPRESSOR_WKV, "blk.%d.indexer_compressor_kv" },
{ LLM_TENSOR_INDEXER_COMPRESSOR_WGATE, "blk.%d.indexer_compressor_gate" },
{ LLM_TENSOR_INDEXER_COMPRESSOR_APE, "blk.%d.indexer_compressor_ape" },
{ LLM_TENSOR_INDEXER_COMPRESSOR_NORM, "blk.%d.indexer_compressor_norm" },
{ LLM_TENSOR_FFN_GATE_TID2EID, "blk.%d.ffn_gate_tid2eid" },
{ LLM_TENSOR_MASKED_EMBD_CENTROIDS, "masked_embd_centroids" },
{ LLM_TENSOR_MASKED_EMBD_ORDERING, "masked_embd_ordering" },
{ LLM_TENSOR_FC, "fc" },
Expand Down Expand Up @@ -615,6 +649,23 @@ static const std::map<llm_tensor, llm_tensor_info> LLM_TENSOR_INFOS = {
{LLM_TENSOR_ATTN_Q_B, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
{LLM_TENSOR_ATTN_KV_A_MQA, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
{LLM_TENSOR_ATTN_KV_B, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
{LLM_TENSOR_ATTN_KV, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
{LLM_TENSOR_ATTN_KV_NORM, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL}},
{LLM_TENSOR_ATTN_OUT_A, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
{LLM_TENSOR_ATTN_OUT_B, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
{LLM_TENSOR_HC_HEAD_FN, {LLM_TENSOR_LAYER_OUTPUT, GGML_OP_MUL_MAT}},
{LLM_TENSOR_HC_HEAD_BASE, {LLM_TENSOR_LAYER_OUTPUT, GGML_OP_ADD}},
{LLM_TENSOR_HC_HEAD_SCALE, {LLM_TENSOR_LAYER_OUTPUT, GGML_OP_MUL}},
{LLM_TENSOR_HC_ATTN_FN, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
{LLM_TENSOR_HC_ATTN_BASE, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_ADD}},
{LLM_TENSOR_HC_ATTN_SCALE, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL}},
{LLM_TENSOR_HC_FFN_FN, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
{LLM_TENSOR_HC_FFN_BASE, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_ADD}},
{LLM_TENSOR_HC_FFN_SCALE, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL}},
{LLM_TENSOR_ATTN_COMPRESSOR_WKV, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
{LLM_TENSOR_ATTN_COMPRESSOR_WGATE, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
{LLM_TENSOR_ATTN_COMPRESSOR_APE, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_ADD}},
{LLM_TENSOR_ATTN_COMPRESSOR_NORM, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL}},
{LLM_TENSOR_ATTN_K_B, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
{LLM_TENSOR_ATTN_V_B, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
{LLM_TENSOR_ATTN_SINKS, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_SCALE}},
Expand Down Expand Up @@ -778,6 +829,11 @@ static const std::map<llm_tensor, llm_tensor_info> LLM_TENSOR_INFOS = {
{LLM_TENSOR_INDEXER_PROJ, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
{LLM_TENSOR_INDEXER_ATTN_K, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
{LLM_TENSOR_INDEXER_ATTN_Q_B, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
{LLM_TENSOR_INDEXER_COMPRESSOR_WKV, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
{LLM_TENSOR_INDEXER_COMPRESSOR_WGATE, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
{LLM_TENSOR_INDEXER_COMPRESSOR_APE, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_ADD}},
{LLM_TENSOR_INDEXER_COMPRESSOR_NORM, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL}},
{LLM_TENSOR_FFN_GATE_TID2EID, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_GET_ROWS}},
{LLM_TENSOR_NEXTN_PROJ_PRE, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
{LLM_TENSOR_NEXTN_PROJ_POST, {LLM_TENSOR_LAYER_OUTPUT, GGML_OP_MUL_MAT}},
// NextN/MTP tensors are stored per-block (blk.%d.nextn.*) even though only the
Expand Down Expand Up @@ -932,6 +988,7 @@ bool llm_arch_supports_sm_tensor(const llm_arch & arch) {
case LLM_ARCH_OLMOE:
case LLM_ARCH_DEEPSEEK2:
case LLM_ARCH_DEEPSEEK32:
case LLM_ARCH_DEEPSEEK4:
case LLM_ARCH_GLM_DSA:
case LLM_ARCH_BITNET:
case LLM_ARCH_T5:
Expand Down
34 changes: 34 additions & 0 deletions examples/talk-llama/llama-arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ enum llm_arch {
LLM_ARCH_DEEPSEEK2,
LLM_ARCH_DEEPSEEK2OCR,
LLM_ARCH_DEEPSEEK32,
LLM_ARCH_DEEPSEEK4,
LLM_ARCH_CHATGLM,
LLM_ARCH_GLM4,
LLM_ARCH_GLM4_MOE,
Expand Down Expand Up @@ -143,6 +144,7 @@ enum llm_arch {
LLM_ARCH_TALKIE,
LLM_ARCH_MELLUM,
LLM_ARCH_EAGLE3,
LLM_ARCH_DFLASH,
LLM_ARCH_UNKNOWN,
};

Expand Down Expand Up @@ -254,9 +256,19 @@ enum llm_kv {
LLM_KV_ATTENTION_INDEXER_HEAD_COUNT,
LLM_KV_ATTENTION_INDEXER_KEY_LENGTH,
LLM_KV_ATTENTION_INDEXER_TOP_K,
LLM_KV_ATTENTION_OUTPUT_GROUP_COUNT,
LLM_KV_ATTENTION_OUTPUT_LORA_RANK,
LLM_KV_ATTENTION_COMPRESS_ROPE_FREQ_BASE,
LLM_KV_ATTENTION_COMPRESS_RATIOS,
LLM_KV_ATTENTION_SHARED_KV_LAYERS,
LLM_KV_ATTENTION_RECURRENT_LAYERS,

LLM_KV_HYPER_CONNECTION_COUNT,
LLM_KV_HYPER_CONNECTION_SINKHORN_ITERATIONS,
LLM_KV_HYPER_CONNECTION_EPSILON,

LLM_KV_HASH_LAYER_COUNT,

LLM_KV_ROPE_DIMENSION_COUNT,
LLM_KV_ROPE_DIMENSION_COUNT_SWA,
LLM_KV_ROPE_DIMENSION_SECTIONS,
Expand Down Expand Up @@ -500,10 +512,27 @@ enum llm_tensor {
LLM_TENSOR_ATTN_Q_B,
LLM_TENSOR_ATTN_KV_A_MQA,
LLM_TENSOR_ATTN_KV_B,
LLM_TENSOR_ATTN_KV,
LLM_TENSOR_ATTN_KV_NORM,
LLM_TENSOR_ATTN_OUT_A,
LLM_TENSOR_ATTN_OUT_B,
LLM_TENSOR_ATTN_K_B,
LLM_TENSOR_ATTN_V_B,
LLM_TENSOR_ATTN_Q_A_NORM,
LLM_TENSOR_ATTN_KV_A_NORM,
LLM_TENSOR_HC_HEAD_FN,
LLM_TENSOR_HC_HEAD_BASE,
LLM_TENSOR_HC_HEAD_SCALE,
LLM_TENSOR_HC_ATTN_FN,
LLM_TENSOR_HC_ATTN_BASE,
LLM_TENSOR_HC_ATTN_SCALE,
LLM_TENSOR_HC_FFN_FN,
LLM_TENSOR_HC_FFN_BASE,
LLM_TENSOR_HC_FFN_SCALE,
LLM_TENSOR_ATTN_COMPRESSOR_WKV,
LLM_TENSOR_ATTN_COMPRESSOR_WGATE,
LLM_TENSOR_ATTN_COMPRESSOR_APE,
LLM_TENSOR_ATTN_COMPRESSOR_NORM,
LLM_TENSOR_ATTN_SUB_NORM,
LLM_TENSOR_FFN_SUB_NORM,
LLM_TENSOR_DEC_ATTN_NORM,
Expand Down Expand Up @@ -565,6 +594,11 @@ enum llm_tensor {
LLM_TENSOR_INDEXER_PROJ,
LLM_TENSOR_INDEXER_ATTN_K,
LLM_TENSOR_INDEXER_ATTN_Q_B,
LLM_TENSOR_INDEXER_COMPRESSOR_WKV,
LLM_TENSOR_INDEXER_COMPRESSOR_WGATE,
LLM_TENSOR_INDEXER_COMPRESSOR_APE,
LLM_TENSOR_INDEXER_COMPRESSOR_NORM,
LLM_TENSOR_FFN_GATE_TID2EID,
LLM_TENSOR_NEXTN_PROJ_PRE,
LLM_TENSOR_NEXTN_PROJ_POST,
LLM_TENSOR_NEXTN_EH_PROJ,
Expand Down
76 changes: 72 additions & 4 deletions examples/talk-llama/llama-batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ bool llama_batch_allocr::init(
LLAMA_LOG_ERROR("%s: sequence %d positions are decreasing (not allowed)\n", __func__, seq_id);
return false;
}

cur_seq_pos[seq_id] = pos;
}
}
}
Expand Down Expand Up @@ -505,7 +507,7 @@ llama_ubatch llama_batch_allocr::split_simple(uint32_t n_ubatch) {
return ubatch_add(idxs, idxs.size(), false);
}

llama_ubatch llama_batch_allocr::split_equal(uint32_t n_ubatch, bool sequential) {
llama_ubatch llama_batch_allocr::split_equal(uint32_t n_ubatch, bool sequential, uint32_t n_keep_tail) {
if (sequential && has_cpl) {
LLAMA_LOG_ERROR("%s: sequential split is not supported when there are coupled sequences in the input batch (you may need to use the -kvu flag)\n", __func__);

Expand Down Expand Up @@ -548,7 +550,7 @@ llama_ubatch llama_batch_allocr::split_equal(uint32_t n_ubatch, bool sequential)
}
}

const uint32_t n_seqs = cur_seq_set.size();
uint32_t n_seqs = cur_seq_set.size();

// we are done
if (n_seqs == 0) {
Expand All @@ -569,7 +571,7 @@ llama_ubatch llama_batch_allocr::split_equal(uint32_t n_ubatch, bool sequential)
std::vector<idx_vec_t> idxs_per_seq(n_seqs);

while (true) {
// we can only add new n_seq_tokens tokens if all the sequence sets have at least one more unused token and
// we can only add new n_seq_tokens tokens if all the sequence sets have at least 1 more unused tokens and
// if we haven't reached n_ubatch
bool can_expand = true;

Expand Down Expand Up @@ -600,6 +602,72 @@ llama_ubatch llama_batch_allocr::split_equal(uint32_t n_ubatch, bool sequential)
}
}

// if n_keep_tail > 0, keep only the seqs that either finish in this ubatch or have at least
// n_keep_tail tokens remaining for a future ubatch, so that the trailing n_keep_tail tokens
// of each seq are never split across ubatches
if (n_keep_tail > 0) {
GGML_ASSERT(n_ubatch > n_keep_tail);

auto n_remaining = [&](uint32_t s) {
return (uint32_t) (seq_set_map[cur_seq_set[s]].size() - cur_idx[s]);
};

// keep the longest prefix of seqs that satisfy the constraint, to preserve sequential seq ids
uint32_t n_keep = 0;
while (n_keep < n_seqs) {
const uint32_t remaining = n_remaining(n_keep);

if (remaining != 0 && remaining < n_keep_tail) {
break;
}

n_keep++;
}

// all seqs violate the constraint - resolve the first one directly and emit it alone
if (n_keep == 0) {
auto & idxs = idxs_per_seq[0];

const auto & seq_idxs = seq_set_map[cur_seq_set[0]];

if (idxs.size() + n_remaining(0) <= n_ubatch) {
// extend the seq to completion
while (n_remaining(0) > 0) {
const int32_t idx = seq_idxs[cur_idx[0]];

idxs.push_back(idx);

used[idx] = true;
++n_used;

++cur_idx[0];
}
} else {
// truncate the seq so that at least n_keep_tail tokens remain
while (n_remaining(0) < n_keep_tail) {
used[idxs.back()] = false;
--n_used;

idxs.pop_back();

--cur_idx[0];
}
}

n_keep = 1;
}

// return the tokens of the deferred seqs back to the pool
for (uint32_t s = n_keep; s < n_seqs; ++s) {
for (const int32_t idx : idxs_per_seq[s]) {
used[idx] = false;
--n_used;
}
}

n_seqs = n_keep;
}

// concat the per-sequence-set lists
std::vector<int32_t> idxs;

Expand Down Expand Up @@ -814,7 +882,7 @@ void llama_batch_allocr::ubatch_print(const llama_ubatch & ubatch, int debug) {
LLAMA_LOG_DEBUG("%s: output = %p\n", __func__, (void *) ubatch.output);
LLAMA_LOG_DEBUG("%s: n_outputs = %d\n", __func__, n_outputs);

if (debug > 1) {
if (debug > 0) {
int seq_id_max = 0;
for (uint32_t i = 0; i < ubatch.n_tokens; ++i) {
for (int s = 0; s < ubatch.n_seq_id[i]; ++s) {
Expand Down
3 changes: 2 additions & 1 deletion examples/talk-llama/llama-batch.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ class llama_batch_allocr {

// make ubatches of equal-length sequences sets
// if sequential == true, the tokens in the ubatch will have increasing sequential sequence ids
llama_ubatch split_equal(uint32_t n_ubatch, bool sequential);
// n_keep_tail = minimum trailing tokens of a seq that must land in the same ubatch
llama_ubatch split_equal(uint32_t n_ubatch, bool sequential, uint32_t n_keep_tail);

// sequence-set-wise split - each ubatch contains a single sequence-set
llama_ubatch split_seq(uint32_t n_ubatch);
Expand Down
Loading
Loading