Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 1 deletion gguf-py/gguf/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,9 @@ class ClipVision:
IMAGE_MEAN = "clip.vision.image_mean"
IMAGE_STD = "clip.vision.image_std"
SPATIAL_MERGE_SIZE = "clip.vision.spatial_merge_size"
SWIGLU_CLAMP = "clip.vision.swiglu_clamp"
EXPERT_COUNT_PER_LAYER = "clip.vision.expert_count_per_layer" # dots3note pyramid MoE, 0 = dense layer
EXPERT_USED_COUNT = "clip.vision.expert_used_count"
SWIGLU_CLAMP = "clip.vision.swiglu_clamp"
USE_GELU = "clip.use_gelu"
USE_SILU = "clip.use_silu"
N_WA_PATTERN = "clip.vision.n_wa_pattern" # used by qwen2.5vl
Expand Down
1 change: 1 addition & 0 deletions src/llama-arch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,7 @@ bool llm_arch_supports_rs_rollback(const llm_arch & arch) {
case LLM_ARCH_QWEN35MOE:
case LLM_ARCH_QWEN4EXP:
case LLM_ARCH_DEEPSEEK4:
case LLM_ARCH_GLM5_NEXT:
case LLM_ARCH_NEMOTRON_H:
case LLM_ARCH_NEMOTRON_H_MOE:
case LLM_ARCH_LFM2:
Expand Down
5 changes: 4 additions & 1 deletion src/llama-graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2690,7 +2690,10 @@ ggml_tensor * llm_graph_context::build_attn_mha(
// split the batch into streams if needed
const auto n_stream = k->ne[3];

q = ggml_view_4d(ctx0, q, q->ne[0], q->ne[1], q->ne[2]/n_stream, n_stream, q->nb[1], q->nb[2], q->nb[3]/n_stream, 0);
// the stream dim steps over one stream's worth of dim-2 (tokens): (ne[2]/n_stream) rows of stride nb[2].
// q->nb[3]/n_stream only equals that for a contiguous q; nope-only MLA (glm5-next) passes a permuted
// q_absorbed where nb[3] != ne[2]*nb[2], so using nb[3] read another head's queries for streams s >= 1.
q = ggml_view_4d(ctx0, q, q->ne[0], q->ne[1], q->ne[2]/n_stream, n_stream, q->nb[1], q->nb[2], q->nb[2]*(q->ne[2]/n_stream), 0);

q = ggml_permute(ctx0, q, 0, 2, 1, 3);
k = ggml_permute(ctx0, k, 0, 2, 1, 3);
Expand Down
4 changes: 4 additions & 0 deletions src/llama-hparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ struct llama_hparams {
uint32_t indexer_kpool = 0; // k-pool size
bool indexer_kpool_select_tail = true;
bool indexer_index_share_mtp = false; // MTP iterations reuse one indexer selection
// head-size slots per cached indexer row, the last one holds the pooled key
uint32_t indexer_kpool_row = 3;
// pools are consecutive cells in sequence order, not runs of consecutive positions
bool indexer_kpool_by_order = false;
// MSA
uint32_t indexer_block_size = 0;
uint32_t indexer_local_blocks = 0;
Expand Down
12 changes: 4 additions & 8 deletions src/llama-kv-cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,10 @@ uint32_t llama_kv_cache::get_size() const {
return cells.size();
}

uint32_t llama_kv_cache::get_n_seq_max() const {
return n_seq_max;
}

uint32_t llama_kv_cache::get_n_stream() const {
return n_stream;
}
Expand Down Expand Up @@ -1369,10 +1373,6 @@ uint32_t llama_kv_cache::get_stream(llama_seq_id seq_id) const {
return seq_to_stream[seq_id];
}

uint32_t llama_kv_cache::get_n_seq_ids() const {
return (uint32_t) seq_to_stream.size();
}

uint32_t llama_kv_cache::get_n_kv(const slot_info & sinfo) const {
uint32_t result = 0;

Expand Down Expand Up @@ -2960,10 +2960,6 @@ ggml_tensor * llama_kv_cache_context::get_k(ggml_context * ctx, int32_t il) cons
return kv->get_k(ctx, il, n_kv, sinfos[i_cur]);
}

ggml_tensor * llama_kv_cache_context::get_k_storage(int32_t il) const {
return kv->get_k_storage(il);
}

ggml_tensor * llama_kv_cache_context::get_v(ggml_context * ctx, int32_t il) const {
return kv->get_v(ctx, il, n_kv, sinfos[i_cur]);
}
Expand Down
5 changes: 1 addition & 4 deletions src/llama-kv-cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ class llama_kv_cache : public llama_memory_i {
//

uint32_t get_size() const;
uint32_t get_n_seq_max() const;
uint32_t get_n_stream() const;
uint32_t get_n_seq_ids() const;

bool get_has_shift() const;

Expand Down Expand Up @@ -411,9 +411,6 @@ class llama_kv_cache_context : public llama_memory_context_i {
ggml_tensor * get_k(ggml_context * ctx, int32_t il) const;
ggml_tensor * get_v(ggml_context * ctx, int32_t il) const;

// The full K storage tensor of the layer, spanning all streams.
ggml_tensor * get_k_storage(int32_t il) const;

// store k_cur and v_cur in the cache based on the provided head location
// note: the heads in k_cur and v_cur should be laid out contiguously in memory
// - k_cur [n_embd_head_k, n_head_k, n_tokens]
Expand Down
8 changes: 8 additions & 0 deletions src/llama-kv-cells.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,14 @@ class llama_kv_cells {
return seq[i].test(seq_id);
}

// the (pos, cell) pairs of sequence seq_id, ordered by position
const std::set<std::pair<llama_pos, uint32_t>> & seq_pos_get(llama_seq_id seq_id) const {
assert(seq_id >= 0);
assert(seq_id < LLAMA_MAX_SEQ);

return seq_pos[seq_id];
}

// the token of the cell of sequence seq_id at the largest position <= p
// when several cells share that position, the one with the highest index wins
// return LLAMA_TOKEN_NULL if the sequence has no cell at or before p
Expand Down
Loading
Loading