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

Function common_context_can_seq_rm

common/common.cpp:1401–1435  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1399}
1400
1401common_context_seq_rm_type common_context_can_seq_rm(llama_context * ctx) {
1402 auto * mem = llama_get_memory(ctx);
1403 if (mem == nullptr) {
1404 return COMMON_CONTEXT_SEQ_RM_TYPE_NO;
1405 }
1406
1407 common_context_seq_rm_type res = COMMON_CONTEXT_SEQ_RM_TYPE_PART;
1408
1409 llama_memory_clear(mem, true);
1410
1411 // eval 2 tokens to check if the context is compatible
1412 std::vector<llama_token> tmp;
1413 tmp.push_back(0);
1414 tmp.push_back(0);
1415
1416 int ret = llama_decode(ctx, llama_batch_get_one(tmp.data(), tmp.size()));
1417 if (ret != 0) {
1418 LOG_ERR("%s: llama_decode() failed: %d\n", __func__, ret);
1419 res = COMMON_CONTEXT_SEQ_RM_TYPE_NO;
1420 goto done;
1421 }
1422
1423 // try to remove the last tokens
1424 if (!llama_memory_seq_rm(mem, 0, 1, -1)) {
1425 LOG_WRN("%s: the target context does not support partial sequence removal\n", __func__);
1426 res = COMMON_CONTEXT_SEQ_RM_TYPE_FULL;
1427 goto done;
1428 }
1429
1430done:
1431 llama_memory_clear(mem, true);
1432 llama_synchronize(ctx);
1433
1434 return res;
1435}
1436
1437void common_set_adapter_lora(struct llama_context * ctx, std::vector<common_adapter_lora_info> & lora) {
1438 std::vector<llama_adapter_lora *> loras;

Callers 3

load_modelMethod · 0.85
common_speculative_initFunction · 0.85
mainFunction · 0.85

Calls 9

llama_get_memoryFunction · 0.85
llama_memory_clearFunction · 0.85
llama_decodeFunction · 0.85
llama_batch_get_oneFunction · 0.85
llama_memory_seq_rmFunction · 0.85
llama_synchronizeFunction · 0.85
push_backMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by 2

common_speculative_initFunction · 0.68
mainFunction · 0.68