Skip to content

Commit 367be2f

Browse files
authored
v2.3.2 (#179)
1 parent e4bd5e7 commit 367be2f

File tree

9 files changed

+17
-15
lines changed

9 files changed

+17
-15
lines changed

cpp/actions.hpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -649,13 +649,14 @@ glue_msg_get_kv_remove_res action_kv_remove(app_t &app, const char *req_raw)
649649
PARSE_REQ(glue_msg_get_kv_remove_req);
650650
const int n_keep = req.n_keep.value;
651651
const int n_discard = req.n_discard.value;
652+
auto * mem = llama_get_memory(app.ctx);
652653

653654
if (n_discard > 0)
654655
{
655656
// TODO: this code branch is kinda broken, to be fixed later
656657
const int n_past = app.tokens.size();
657-
llama_kv_self_seq_rm(app.ctx, 0, n_keep, n_keep + n_discard);
658-
llama_kv_self_seq_add(app.ctx, 0, n_keep + n_discard, n_past, -n_discard);
658+
llama_memory_seq_rm(mem, 0, n_keep, n_keep + n_discard);
659+
llama_memory_seq_add(mem, 0, n_keep + n_discard, n_past, -n_discard);
659660
app.tokens.erase(
660661
app.tokens.begin() + n_keep,
661662
app.tokens.begin() + n_keep + n_discard);
@@ -664,11 +665,11 @@ glue_msg_get_kv_remove_res action_kv_remove(app_t &app, const char *req_raw)
664665
{
665666
if (n_keep == 0)
666667
{
667-
llama_kv_self_clear(app.ctx);
668+
llama_memory_clear(mem, true);
668669
}
669670
else
670671
{
671-
llama_kv_self_seq_rm(app.ctx, 0, n_keep, -1);
672+
llama_memory_seq_rm(mem, 0, n_keep, -1);
672673
app.tokens.erase(
673674
app.tokens.begin() + n_keep,
674675
app.tokens.end());
@@ -685,7 +686,8 @@ glue_msg_get_kv_remove_res action_kv_remove(app_t &app, const char *req_raw)
685686
glue_msg_get_kv_clear_res action_kv_clear(app_t &app, const char *req_raw)
686687
{
687688
PARSE_REQ(glue_msg_get_kv_clear_req);
688-
llama_kv_self_clear(app.ctx);
689+
auto * mem = llama_get_memory(app.ctx);
690+
llama_memory_clear(mem, true);
689691
app.tokens.clear();
690692

691693
glue_msg_get_kv_clear_res res;
@@ -766,7 +768,7 @@ glue_msg_test_benchmark_res action_test_benchmark(app_t &app, const char *req_ra
766768
std::string type = req.type.value; // "pp" (prompt proc) or "tg" (tok gen)
767769
int n_samples = req.n_samples.value; // n_batch in pp and n_predict in pg
768770

769-
llama_kv_self_clear(app.ctx);
771+
llama_memory_clear(llama_get_memory(app.ctx), true);
770772
int n_vocab = llama_vocab_n_tokens(app.vocab);
771773
int64_t t_start = ggml_time_ms();
772774

@@ -837,7 +839,7 @@ glue_msg_test_perplexity_res action_test_perplexity(app_t &app, const char *req_
837839
}
838840

839841
// Clear existing context to start fresh
840-
llama_kv_self_clear(app.ctx);
842+
llama_memory_clear(llama_get_memory(app.ctx), true);
841843
app.tokens.clear();
842844

843845
const int32_t n_vocab = llama_vocab_n_tokens(app.vocab);

llama.cpp

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wllama/wllama",
3-
"version": "2.3.1",
3+
"version": "2.3.2",
44
"description": "WebAssembly binding for llama.cpp - Enabling on-browser LLM inference",
55
"main": "index.js",
66
"type": "module",

src/multi-thread/wllama.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/multi-thread/wllama.wasm

60.5 KB
Binary file not shown.

src/single-thread/wllama.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/single-thread/wllama.wasm

60.3 KB
Binary file not shown.

src/wasm-from-cdn.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Do not edit this file directly
33

44
const WasmFromCDN = {
5-
'single-thread/wllama.wasm': 'https://cdn.jsdelivr.net/npm/@wllama/[email protected].1/src/single-thread/wllama.wasm',
6-
'multi-thread/wllama.wasm': 'https://cdn.jsdelivr.net/npm/@wllama/[email protected].1/src/multi-thread/wllama.wasm',
5+
'single-thread/wllama.wasm': 'https://cdn.jsdelivr.net/npm/@wllama/[email protected].2/src/single-thread/wllama.wasm',
6+
'multi-thread/wllama.wasm': 'https://cdn.jsdelivr.net/npm/@wllama/[email protected].2/src/multi-thread/wllama.wasm',
77
};
88

99
export default WasmFromCDN;

src/workers-code/generated.ts

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)