MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / create_memory

Method create_memory

src/llama-model.cpp:8592–8763  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8590}
8591
8592llama_memory_i * llama_model::create_memory(const llama_memory_params & params, const llama_cparams & cparams) const {
8593 llama_memory_i * res;
8594
8595 switch (arch) {
8596 // Models that need specific instantiation should be handled in the
8597 // switch statement
8598 case LLM_ARCH_BERT:
8599 case LLM_ARCH_JINA_BERT_V2:
8600 case LLM_ARCH_JINA_BERT_V3:
8601 case LLM_ARCH_NOMIC_BERT:
8602 case LLM_ARCH_NOMIC_BERT_MOE:
8603 case LLM_ARCH_NEO_BERT:
8604 case LLM_ARCH_EUROBERT:
8605 case LLM_ARCH_WAVTOKENIZER_DEC:
8606 case LLM_ARCH_MODERN_BERT:
8607 case LLM_ARCH_GEMMA_EMBEDDING:
8608 case LLM_ARCH_DREAM:
8609 case LLM_ARCH_LLADA:
8610 case LLM_ARCH_LLADA_MOE:
8611 case LLM_ARCH_RND1:
8612 {
8613 res = nullptr;
8614 } break;
8615 case LLM_ARCH_DEEPSEEK4:
8616 {
8617 llama_memory_i::layer_filter_cb filter_attn = [&](int32_t) {
8618 return true;
8619 };
8620 llama_memory_i::layer_filter_cb filter_recr = [&](int32_t il) {
8621 return hparams.attn_compress_ratio[il] != 0;
8622 };
8623
8624 res = new llama_memory_hybrid_iswa(
8625 /* model */ *this,
8626 /* attn_type_k */ params.type_k,
8627 /* attn_type_v */ params.type_v,
8628 /* attn_v_trans */ !cparams.flash_attn,
8629 /* attn_swa_full */ params.swa_full,
8630 /* attn_kv_size */ cparams.n_ctx_seq,
8631 /* attn_n_ubatch */ cparams.n_ubatch,
8632 /* attn_n_pad */ 1,
8633 /* recurrent_type_r */ GGML_TYPE_F32,
8634 /* recurrent_type_s */ GGML_TYPE_F32,
8635 /* recurrent_rs_size */ std::max((uint32_t) 1, cparams.n_seq_max),
8636 /* n_seq_max */ cparams.n_seq_max,
8637 /* offload */ cparams.offload_kqv,
8638 /* unified */ cparams.kv_unified,
8639 /* filter_attn */ std::move(filter_attn),
8640 /* filter_recr */ std::move(filter_recr));
8641 } break;
8642 // Models that need standard caching should rely on recurrent/hybrid
8643 // checks
8644 default:
8645 {
8646 if (llm_arch_is_recurrent(arch)) {
8647 res = new llama_memory_recurrent(
8648 *this,
8649 GGML_TYPE_F32,

Callers 1

llama_contextMethod · 0.80

Calls 7

maxFunction · 0.85
llm_arch_is_recurrentFunction · 0.85
llm_arch_is_hybridFunction · 0.85
is_recurrentMethod · 0.80
n_ffMethod · 0.80
is_swaMethod · 0.80
is_swa_anyMethod · 0.80

Tested by

no test coverage detected