From 978f4f7969190265e127e8a3d704bb173fbd171c Mon Sep 17 00:00:00 2001 From: Onur Gündüz Date: Thu, 11 Jun 2026 23:40:01 +0200 Subject: chore: rename project --- tests/test_bf16_model.c | 28 ++++++------ tests/test_cli.c | 8 ++-- tests/test_late.c | 80 ++++++++++++++++---------------- tests/test_safetensors.c | 2 +- tests/test_server.c | 8 ++-- tests/test_tokenizer.c | 2 +- tests/test_workspace.c | 116 +++++++++++++++++++++++------------------------ 7 files changed, 122 insertions(+), 122 deletions(-) (limited to 'tests') diff --git a/tests/test_bf16_model.c b/tests/test_bf16_model.c index 392f040..cc9b2fb 100644 --- a/tests/test_bf16_model.c +++ b/tests/test_bf16_model.c @@ -13,7 +13,7 @@ int main(void) { char root[1024], f32_dir[1088], bf16_dir[1088]; - snprintf(root, sizeof(root), "%s/pplx-bf16-test-XXXXXX", + snprintf(root, sizeof(root), "%s/embed-bf16-test-XXXXXX", getenv("TMPDIR") ? getenv("TMPDIR") : "/tmp"); if (!mkdtemp(root)) { perror("mkdtemp"); return 2; } snprintf(f32_dir, sizeof(f32_dir), "%s/f32", root); @@ -26,26 +26,26 @@ int main(void) { } int ids[] = {1, 2, 3, 4}; - pplx_model_t *mf32 = pplx_model_load(f32_dir); - pplx_model_t *mbf16 = pplx_model_load(bf16_dir); + embed_model_t *mf32 = embed_model_load(f32_dir); + embed_model_t *mbf16 = embed_model_load(bf16_dir); if (!mf32 || !mbf16) { fprintf(stderr, "model load failed\n"); return 1; } - const pplx_config_t *cfg = pplx_model_config(mf32); + const embed_config_t *cfg = embed_model_config(mf32); int dim = cfg->hidden_size; float *a = (float *)malloc((size_t)dim * sizeof(float)); float *b = (float *)malloc((size_t)dim * sizeof(float)); - pplx_workspace_t *wf32 = pplx_workspace_new(mf32); - pplx_workspace_t *wbf16 = pplx_workspace_new(mbf16); + embed_workspace_t *wf32 = embed_workspace_new(mf32); + embed_workspace_t *wbf16 = embed_workspace_new(mbf16); if (!a || !b || !wf32 || !wbf16) { fprintf(stderr, "allocation failed\n"); return 1; } - if (pplx_model_embed_into(mf32, wf32, ids, 4, a) != 0 || - pplx_model_embed_into(mbf16, wbf16, ids, 4, b) != 0) { + if (embed_model_encode_into(mf32, wf32, ids, 4, a) != 0 || + embed_model_encode_into(mbf16, wbf16, ids, 4, b) != 0) { fprintf(stderr, "embedding failed\n"); return 1; } @@ -74,8 +74,8 @@ int main(void) { enum { LONG_N = 24 }; int long_ids[LONG_N]; for (int i = 0; i < LONG_N; i++) long_ids[i] = (i % 14) + 1; - if (pplx_model_embed_into(mf32, wf32, long_ids, LONG_N, a) != 0 || - pplx_model_embed_into(mbf16, wbf16, long_ids, LONG_N, b) != 0) { + if (embed_model_encode_into(mf32, wf32, long_ids, LONG_N, a) != 0 || + embed_model_encode_into(mbf16, wbf16, long_ids, LONG_N, b) != 0) { fprintf(stderr, "long-sequence embedding failed\n"); return 1; } @@ -96,10 +96,10 @@ int main(void) { printf("ok: bf16 model parity dim=%d max_abs_diff=%.9g norm=%.9g\n", dim, max_diff, norm); - pplx_workspace_free(wf32); - pplx_workspace_free(wbf16); - pplx_model_free(mf32); - pplx_model_free(mbf16); + embed_workspace_free(wf32); + embed_workspace_free(wbf16); + embed_model_free(mf32); + embed_model_free(mbf16); free(a); free(b); return 0; diff --git a/tests/test_cli.c b/tests/test_cli.c index 0a5212a..a6a065c 100644 --- a/tests/test_cli.c +++ b/tests/test_cli.c @@ -1,4 +1,4 @@ -/* tests/test_cli.c - drives the pplx-embed CLI binary end to end. +/* tests/test_cli.c - drives the embed CLI binary end to end. * Hermetic: synthesizes a tiny model + tokenizer fixture, then runs the * binary given as argv[1] through its modes and flag validation paths, * checking exit codes and output shapes. Runs via `make test`. */ @@ -90,10 +90,10 @@ static int stdout_is_embedding(int dim) int main(int argc, char **argv) { - g_cli = argc > 1 ? argv[1] : "./pplx-embed"; + g_cli = argc > 1 ? argv[1] : "./embed"; tm_dims_t dims = {4, 2, 1, 2, 8, TF_VOCAB_SIZE}; - snprintf(g_dir, sizeof(g_dir), "%s/pplx-cli-test-XXXXXX", + snprintf(g_dir, sizeof(g_dir), "%s/embed-cli-test-XXXXXX", getenv("TMPDIR") ? getenv("TMPDIR") : "/tmp"); if (!mkdtemp(g_dir) || tf_write_vocab(g_dir) != 0 || tm_write_model_dims(g_dir, "F32", &dims) != 0) { @@ -109,7 +109,7 @@ int main(int argc, char **argv) /* Help and missing-argument handling. */ expect(run_cli("-h", NULL) == 0, "-h exits 0"); expect(run_cli("", NULL) == 1, "no arguments exits 1"); - expect(run_cli("-d /nonexistent-pplx-dir hi", NULL) == 1, + expect(run_cli("-d /nonexistent-embed-dir hi", NULL) == 1, "missing model dir exits 1"); /* Mode 1: one text prints one embedding line. */ diff --git a/tests/test_late.c b/tests/test_late.c index 2243057..94bdfe2 100644 --- a/tests/test_late.c +++ b/tests/test_late.c @@ -39,13 +39,13 @@ static int check_maxsim_batch_parity(const float *query, int query_tokens, { float scores[8]; if (n_docs > (int)(sizeof(scores) / sizeof(scores[0]))) return 1; - if (pplx_late_maxsim_batch(query, query_tokens, docs, offsets, n_docs, + if (embed_late_maxsim_batch(query, query_tokens, docs, offsets, n_docs, dim, scores) != 0) { fprintf(stderr, "maxsim_batch (%s) failed\n", what); return 1; } for (int i = 0; i < n_docs; i++) { - float one = pplx_late_maxsim(query, query_tokens, + float one = embed_late_maxsim(query, query_tokens, docs + (size_t)offsets[i] * dim, offsets[i + 1] - offsets[i], dim); if (fabsf(scores[i] - one) > 0.0001f) { @@ -64,10 +64,10 @@ int main(void) int hidden = dims.hidden; qwen_tokenizer_t *tok = NULL; - pplx_model_t *base = NULL; - pplx_workspace_t *base_ws = NULL; - pplx_late_model_t *late = NULL; - pplx_late_workspace_t *ws = NULL; + embed_model_t *base = NULL; + embed_workspace_t *base_ws = NULL; + embed_late_model_t *late = NULL; + embed_late_workspace_t *ws = NULL; int *ids = NULL; float *states = NULL, *raw = NULL, *vecs = NULL, *expected = NULL; float *doc_vecs = NULL; @@ -75,7 +75,7 @@ int main(void) int *doc_ids[3] = {0}; char dir[1024]; - snprintf(dir, sizeof(dir), "%s/pplx-late-test-XXXXXX", + snprintf(dir, sizeof(dir), "%s/embed-late-test-XXXXXX", getenv("TMPDIR") ? getenv("TMPDIR") : "/tmp"); if (!mkdtemp(dir) || tf_write_vocab(dir) != 0 || tm_write_model_dims(dir, "F32", &dims) != 0) { @@ -85,25 +85,25 @@ int main(void) /* The base model must load before the projection exists; keep it for * the reference forward pass below. */ - base = pplx_model_load(dir); - if (!base || !(base_ws = pplx_workspace_new(base))) { + base = embed_model_load(dir); + if (!base || !(base_ws = embed_workspace_new(base))) { fprintf(stderr, "failed to load base model\n"); goto fail; } /* No 1_Dense head yet: not a late model. */ - if (pplx_late_model_load(dir) != NULL) { + if (embed_late_model_load(dir) != NULL) { fprintf(stderr, "late load succeeded without 1_Dense\n"); goto fail; } - if (pplx_late_model_config(NULL) != NULL || - pplx_late_model_token_dim(NULL) != 0 || - pplx_late_workspace_new(NULL) != NULL) { + if (embed_late_model_config(NULL) != NULL || + embed_late_model_token_dim(NULL) != 0 || + embed_late_workspace_new(NULL) != NULL) { fprintf(stderr, "NULL-argument handling failed\n"); goto fail; } - pplx_late_workspace_free(NULL); - pplx_late_model_free(NULL); + embed_late_workspace_free(NULL); + embed_late_model_free(NULL); /* A head whose tensor is not named linear.weight must be rejected. */ if (tm_write_late_projection_named(dir, "F32", TOKEN_DIM, hidden, @@ -111,7 +111,7 @@ int main(void) fprintf(stderr, "failed to write malformed projection\n"); goto fail; } - if (pplx_late_model_load(dir) != NULL) { + if (embed_late_model_load(dir) != NULL) { fprintf(stderr, "late load accepted a head without linear.weight\n"); goto fail; } @@ -120,26 +120,26 @@ int main(void) fprintf(stderr, "failed to write projection\n"); goto fail; } - late = pplx_late_model_load(dir); + late = embed_late_model_load(dir); if (!late) { fprintf(stderr, "late model load failed\n"); goto fail; } /* With the projection present the dir is no longer a pooled model. */ - if (pplx_model_load(dir) != NULL) { + if (embed_model_load(dir) != NULL) { fprintf(stderr, "pooled load accepted a late-interaction snapshot\n"); goto fail; } - const pplx_config_t *cfg = pplx_late_model_config(late); + const embed_config_t *cfg = embed_late_model_config(late); if (!cfg || cfg->hidden_size != hidden || - pplx_late_model_token_dim(late) != TOKEN_DIM) { + embed_late_model_token_dim(late) != TOKEN_DIM) { fprintf(stderr, "late config/token_dim mismatch\n"); goto fail; } - ws = pplx_late_workspace_new(late); + ws = embed_late_workspace_new(late); if (!ws) { fprintf(stderr, "late workspace allocation failed\n"); goto fail; @@ -169,25 +169,25 @@ int main(void) goto fail; } - if (pplx_late_model_encode_tokens(late, ws, NULL, n_tokens, 1, vecs) == 0 || - pplx_late_model_encode_tokens(late, ws, ids, 0, 1, vecs) == 0 || - pplx_late_model_encode_tokens(NULL, ws, ids, n_tokens, 1, vecs) == 0 || - pplx_late_model_encode_tokens(late, NULL, ids, n_tokens, 1, vecs) == 0) { + if (embed_late_model_encode_tokens(late, ws, NULL, n_tokens, 1, vecs) == 0 || + embed_late_model_encode_tokens(late, ws, ids, 0, 1, vecs) == 0 || + embed_late_model_encode_tokens(NULL, ws, ids, n_tokens, 1, vecs) == 0 || + embed_late_model_encode_tokens(late, NULL, ids, n_tokens, 1, vecs) == 0) { fprintf(stderr, "encode accepted invalid arguments\n"); goto fail; } - if (pplx_late_model_encode_tokens(late, ws, ids, n_tokens, 0, raw) != 0 || - pplx_late_model_encode_tokens(late, ws, ids, n_tokens, 1, vecs) != 0) { + if (embed_late_model_encode_tokens(late, ws, ids, n_tokens, 0, raw) != 0 || + embed_late_model_encode_tokens(late, ws, ids, n_tokens, 1, vecs) != 0) { fprintf(stderr, "encode_tokens failed\n"); goto fail; } /* Reference: run the same tokens through the standalone base model and * apply the projection by hand from the fixture's deterministic values. */ - states = pplx_model_forward(base, base_ws, ids, n_tokens); + states = embed_model_forward(base, base_ws, ids, n_tokens); if (!states) { - fprintf(stderr, "pplx_model_forward failed\n"); + fprintf(stderr, "embed_model_forward failed\n"); goto fail; } for (int t = 0; t < n_tokens; t++) { @@ -227,13 +227,13 @@ int main(void) { static const float q2[4] = {1.0f, 0.0f, 0.0f, 1.0f}; static const float d2[4] = {1.0f, 0.0f, 0.0f, -1.0f}; - float s = pplx_late_maxsim(q2, 2, d2, 2, 2); + float s = embed_late_maxsim(q2, 2, d2, 2, 2); if (fabsf(s - 1.0f) > 0.000001f) { fprintf(stderr, "maxsim hand check: got %g, want 1\n", s); goto fail; } - if (pplx_late_maxsim(NULL, 2, d2, 2, 2) != 0.0f || - pplx_late_maxsim(q2, 0, d2, 2, 2) != 0.0f) { + if (embed_late_maxsim(NULL, 2, d2, 2, 2) != 0.0f || + embed_late_maxsim(q2, 0, d2, 2, 2) != 0.0f) { fprintf(stderr, "maxsim accepted invalid arguments\n"); goto fail; } @@ -260,7 +260,7 @@ int main(void) goto fail; } for (int i = 0; i < 3; i++) { - if (pplx_late_model_encode_tokens( + if (embed_late_model_encode_tokens( late, ws, doc_ids[i], lens[i], 1, doc_vecs + (size_t)offsets[i] * TOKEN_DIM) != 0) { fprintf(stderr, "doc encode failed\n"); @@ -274,11 +274,11 @@ int main(void) float scores[3]; int bad_first[4] = {1, 2, 3, 4}; int empty_doc[3] = {0, 2, 2}; - if (pplx_late_maxsim_batch(vecs, n_tokens, doc_vecs, bad_first, 3, + if (embed_late_maxsim_batch(vecs, n_tokens, doc_vecs, bad_first, 3, TOKEN_DIM, scores) == 0 || - pplx_late_maxsim_batch(vecs, n_tokens, doc_vecs, empty_doc, 2, + embed_late_maxsim_batch(vecs, n_tokens, doc_vecs, empty_doc, 2, TOKEN_DIM, scores) == 0 || - pplx_late_maxsim_batch(vecs, n_tokens, doc_vecs, offsets, 3, + embed_late_maxsim_batch(vecs, n_tokens, doc_vecs, offsets, 3, TOKEN_DIM, NULL) == 0) { fprintf(stderr, "maxsim_batch accepted invalid arguments\n"); goto fail; @@ -325,9 +325,9 @@ fail: free(states); free(ids); qwen_tokenizer_free(tok); - pplx_late_workspace_free(ws); - pplx_late_model_free(late); - pplx_workspace_free(base_ws); - pplx_model_free(base); + embed_late_workspace_free(ws); + embed_late_model_free(late); + embed_workspace_free(base_ws); + embed_model_free(base); return rc; } diff --git a/tests/test_safetensors.c b/tests/test_safetensors.c index fea570b..d527951 100644 --- a/tests/test_safetensors.c +++ b/tests/test_safetensors.c @@ -64,7 +64,7 @@ static const char ONE_TENSOR_X[] = int main(void) { - snprintf(tmproot, sizeof(tmproot), "%s/pplx-st-test-XXXXXX", + snprintf(tmproot, sizeof(tmproot), "%s/embed-st-test-XXXXXX", getenv("TMPDIR") ? getenv("TMPDIR") : "/tmp"); if (!mkdtemp(tmproot)) { perror("mkdtemp"); return 2; } diff --git a/tests/test_server.c b/tests/test_server.c index 5f1dbed..6f1e48e 100644 --- a/tests/test_server.c +++ b/tests/test_server.c @@ -228,15 +228,15 @@ static int http_req(int port, const char *method, const char *path, } typedef struct { - pplx_server_model_spec_t spec[2]; - pplx_server_config_t cfg; + embed_server_model_spec_t spec[2]; + embed_server_config_t cfg; int rc; } srv_ctx; static void *srv_thread_main(void *arg) { srv_ctx *s = (srv_ctx *)arg; - s->rc = pplx_run_server(&s->cfg); + s->rc = embed_run_server(&s->cfg); return NULL; } @@ -548,7 +548,7 @@ static void test_http_contextual(int port) static void test_http_server(void) { char dir[1024]; - snprintf(dir, sizeof(dir), "%s/pplx-srv-test-XXXXXX", + snprintf(dir, sizeof(dir), "%s/embed-srv-test-XXXXXX", getenv("TMPDIR") ? getenv("TMPDIR") : "/tmp"); if (!mkdtemp(dir)) { fprintf(stderr, "FAIL: mkdtemp\n"); diff --git a/tests/test_tokenizer.c b/tests/test_tokenizer.c index b0c694e..bed5b7d 100644 --- a/tests/test_tokenizer.c +++ b/tests/test_tokenizer.c @@ -271,7 +271,7 @@ static void test_loader_edges(const char *root) int main(void) { char dir[1024]; - snprintf(dir, sizeof(dir), "%s/pplx-tok-test-XXXXXX", + snprintf(dir, sizeof(dir), "%s/embed-tok-test-XXXXXX", getenv("TMPDIR") ? getenv("TMPDIR") : "/tmp"); if (!mkdtemp(dir) || tf_write_vocab(dir) != 0) { fprintf(stderr, "fixture creation failed\n"); diff --git a/tests/test_workspace.c b/tests/test_workspace.c index 334c4f2..4f83936 100644 --- a/tests/test_workspace.c +++ b/tests/test_workspace.c @@ -26,19 +26,19 @@ static float max_abs_diff(const float *a, const float *b, int n) /* The allocating and pooling API variants must agree with the *_into * results validated in main. reference is the batched row for ids0. */ -static int check_alloc_and_pooling_variants(const pplx_model_t *model, - pplx_workspace_t *ws, +static int check_alloc_and_pooling_variants(const embed_model_t *model, + embed_workspace_t *ws, const int *ids0, int n0, const float *states, const float *reference, - const pplx_config_t *cfg) + const embed_config_t *cfg) { int rc = 1; int dim = cfg->hidden_size; float *emb = NULL, *fwd = NULL, *pooled = NULL, *span_out = NULL; - emb = pplx_model_embed(model, ws, ids0, n0); - fwd = pplx_model_forward(model, ws, ids0, n0); + emb = embed_model_encode(model, ws, ids0, n0); + fwd = embed_model_forward(model, ws, ids0, n0); pooled = (float *)calloc((size_t)dim, sizeof(float)); span_out = (float *)calloc((size_t)2 * dim, sizeof(float)); if (!emb || !fwd || !pooled || !span_out) { @@ -46,44 +46,44 @@ static int check_alloc_and_pooling_variants(const pplx_model_t *model, goto done; } - if (pplx_model_embed(NULL, ws, ids0, n0) != NULL || - pplx_model_embed(model, ws, NULL, n0) != NULL || - pplx_model_forward(model, ws, ids0, 0) != NULL || - pplx_pool_batch(cfg, states, NULL, 1, pooled) == 0) { + if (embed_model_encode(NULL, ws, ids0, n0) != NULL || + embed_model_encode(model, ws, NULL, n0) != NULL || + embed_model_forward(model, ws, ids0, 0) != NULL || + embed_pool_batch(cfg, states, NULL, 1, pooled) == 0) { fprintf(stderr, "alloc variants accepted invalid arguments\n"); goto done; } if (max_abs_diff(emb, reference, dim) > 0.00005f) { - fprintf(stderr, "pplx_model_embed disagrees with batched row\n"); + fprintf(stderr, "embed_model_encode disagrees with batched row\n"); goto done; } if (max_abs_diff(fwd, states, n0 * dim) > 0.000001f) { - fprintf(stderr, "pplx_model_forward disagrees with forward_into\n"); + fprintf(stderr, "embed_model_forward disagrees with forward_into\n"); goto done; } /* Mean-pooling the final states reproduces the embedding. */ - if (pplx_pool_batch(cfg, states, &n0, 1, pooled) != 0 || + if (embed_pool_batch(cfg, states, &n0, 1, pooled) != 0 || max_abs_diff(pooled, reference, dim) > 0.00005f) { - fprintf(stderr, "pplx_pool_batch disagrees with embedding\n"); + fprintf(stderr, "embed_pool_batch disagrees with embedding\n"); goto done; } /* One span covering the whole sequence pools to the embedding, and * two halves recombine into it by token-count weighting. */ - pplx_span_t whole = {0, n0}; - if (pplx_model_embed_spans(model, ws, ids0, n0, &whole, 1, + embed_span_t whole = {0, n0}; + if (embed_model_encode_spans(model, ws, ids0, n0, &whole, 1, span_out) != 0 || max_abs_diff(span_out, reference, dim) > 0.00005f) { fprintf(stderr, "whole-sequence span disagrees with embedding\n"); goto done; } int h = n0 / 2; - pplx_span_t halves[2] = {{0, h}, {h, n0 - h}}; - if (pplx_model_embed_spans(model, ws, ids0, n0, halves, 2, + embed_span_t halves[2] = {{0, h}, {h, n0 - h}}; + if (embed_model_encode_spans(model, ws, ids0, n0, halves, 2, span_out) != 0) { - fprintf(stderr, "pplx_model_embed_spans failed for two spans\n"); + fprintf(stderr, "embed_model_encode_spans failed for two spans\n"); goto done; } for (int d = 0; d < dim; d++) { @@ -106,11 +106,11 @@ done: /* A multi-document contextual batch must match per-document runs. * doc0 is chunks 0 and 1 joined by a separator token; doc1 is chunk 2. */ -static int check_spans_batch_parity(const pplx_model_t *model, - pplx_workspace_t *ws, +static int check_spans_batch_parity(const embed_model_t *model, + embed_workspace_t *ws, int *const ids[], const int *ntok, int separator_id, - const pplx_config_t *cfg) + const embed_config_t *cfg) { int rc = 1; int dim = cfg->hidden_size; @@ -126,26 +126,26 @@ static int check_spans_batch_parity(const pplx_model_t *model, doc0[ntok[0]] = separator_id; memcpy(doc0 + ntok[0] + 1, ids[1], (size_t)ntok[1] * sizeof(int)); - pplx_span_t spans0[2] = {{0, ntok[0]}, {ntok[0] + 1, ntok[1]}}; - pplx_span_t span1 = {0, ntok[2]}; - if (pplx_model_embed_spans(model, ws, doc0, n0, spans0, 2, + embed_span_t spans0[2] = {{0, ntok[0]}, {ntok[0] + 1, ntok[1]}}; + embed_span_t span1 = {0, ntok[2]}; + if (embed_model_encode_spans(model, ws, doc0, n0, spans0, 2, expected) != 0 || - pplx_model_embed_spans(model, ws, ids[2], ntok[2], &span1, 1, + embed_model_encode_spans(model, ws, ids[2], ntok[2], &span1, 1, expected + (size_t)2 * dim) != 0) { fprintf(stderr, "singleton contextual embedding failed\n"); goto done; } - pplx_context_input_t inputs[2] = { + embed_context_input_t inputs[2] = { {{doc0, n0}, spans0, 2}, {{ids[2], ntok[2]}, &span1, 1}, }; - if (pplx_model_embed_spans_batch(model, ws, inputs, 2, actual) != 0) { + if (embed_model_encode_spans_batch(model, ws, inputs, 2, actual) != 0) { fprintf(stderr, "batched contextual embedding failed\n"); goto done; } - if (pplx_model_embed_spans_batch(model, ws, NULL, 2, actual) == 0 || - pplx_model_embed_spans_batch(model, ws, inputs, 0, actual) == 0) { + if (embed_model_encode_spans_batch(model, ws, NULL, 2, actual) == 0 || + embed_model_encode_spans_batch(model, ws, inputs, 0, actual) == 0) { fprintf(stderr, "spans batch accepted invalid arguments\n"); goto done; } @@ -174,7 +174,7 @@ int main(int argc, char **argv) /* Tiny hidden size keeps it fast; the vocab must cover every id the * byte-complete tokenizer fixture can emit. */ tm_dims_t dims = {4, 2, 1, 2, 8, TF_VOCAB_SIZE}; - snprintf(fixture_dir, sizeof(fixture_dir), "%s/pplx-ws-test-XXXXXX", + snprintf(fixture_dir, sizeof(fixture_dir), "%s/embed-ws-test-XXXXXX", getenv("TMPDIR") ? getenv("TMPDIR") : "/tmp"); if (!mkdtemp(fixture_dir) || tf_write_vocab(fixture_dir) != 0 || tm_write_model_dims(fixture_dir, "F32", &dims) != 0) { @@ -189,28 +189,28 @@ int main(int argc, char **argv) char vocab_path[4096]; snprintf(vocab_path, sizeof(vocab_path), "%s/vocab.json", model_dir); - pplx_model_t *model = pplx_model_load(model_dir); + embed_model_t *model = embed_model_load(model_dir); if (!model) { fprintf(stderr, "failed to load model\n"); return 1; } - const pplx_config_t *cfg = pplx_model_config(model); + const embed_config_t *cfg = embed_model_config(model); if (!cfg || cfg->hidden_size <= 0) { fprintf(stderr, "invalid model config\n"); - pplx_model_free(model); + embed_model_free(model); return 1; } - pplx_workspace_t *batch_ws = pplx_workspace_new(model); - pplx_workspace_t *single_ws = pplx_workspace_new(model); + embed_workspace_t *batch_ws = embed_workspace_new(model); + embed_workspace_t *single_ws = embed_workspace_new(model); qwen_tokenizer_t *tok = qwen_tokenizer_load(vocab_path); if (!batch_ws || !single_ws || !tok) { fprintf(stderr, "failed to allocate workspace or tokenizer\n"); qwen_tokenizer_free(tok); - pplx_workspace_free(single_ws); - pplx_workspace_free(batch_ws); - pplx_model_free(model); + embed_workspace_free(single_ws); + embed_workspace_free(batch_ws); + embed_model_free(model); return 1; } @@ -225,9 +225,9 @@ int main(int argc, char **argv) * sees indeterminate pointers. */ int *ids[4] = {0}; int ntok[4] = {0}; - pplx_input_t inputs[4]; + embed_input_t inputs[4]; - size_t initial_ws_bytes = pplx_workspace_nbytes(batch_ws); + size_t initial_ws_bytes = embed_workspace_nbytes(batch_ws); if (initial_ws_bytes == 0) { fprintf(stderr, "workspace byte accounting returned zero\n"); goto fail; @@ -257,8 +257,8 @@ int main(int argc, char **argv) goto fail; } - if (pplx_model_embed_batch(model, batch_ws, inputs, batch, batched) != 0) { - fprintf(stderr, "pplx_model_embed_batch failed\n"); + if (embed_model_encode_batch(model, batch_ws, inputs, batch, batched) != 0) { + fprintf(stderr, "embed_model_encode_batch failed\n"); free(states); free(normalized); free(single); @@ -266,7 +266,7 @@ int main(int argc, char **argv) goto fail; } - size_t batch_ws_bytes = pplx_workspace_nbytes(batch_ws); + size_t batch_ws_bytes = embed_workspace_nbytes(batch_ws); if (batch_ws_bytes <= initial_ws_bytes) { fprintf(stderr, "workspace byte accounting did not grow after embedding\n"); free(states); @@ -279,8 +279,8 @@ int main(int argc, char **argv) float worst_diff = 0.0f; float worst_cos = 1.0f; for (int i = 0; i < batch; i++) { - if (pplx_model_embed_into(model, single_ws, ids[i], ntok[i], single) != 0) { - fprintf(stderr, "pplx_model_embed_into failed at %d\n", i); + if (embed_model_encode_into(model, single_ws, ids[i], ntok[i], single) != 0) { + fprintf(stderr, "embed_model_encode_into failed at %d\n", i); free(states); free(normalized); free(single); @@ -290,14 +290,14 @@ int main(int argc, char **argv) const float *row = batched + (size_t)i * dim; float diff = max_abs_diff(row, single, dim); - float cos = pplx_cosine_similarity(row, single, dim); + float cos = embed_cosine_similarity(row, single, dim); if (diff > worst_diff) worst_diff = diff; if (cos < worst_cos) worst_cos = cos; } memcpy(normalized, batched, (size_t)dim * sizeof(float)); - if (pplx_l2_normalize(normalized, dim) != 0) { - fprintf(stderr, "pplx_l2_normalize failed\n"); + if (embed_l2_normalize(normalized, dim) != 0) { + fprintf(stderr, "embed_l2_normalize failed\n"); free(states); free(normalized); free(single); @@ -308,7 +308,7 @@ int main(int argc, char **argv) for (int i = 0; i < dim; i++) normalized_norm_sq += normalized[i] * normalized[i]; if (fabsf(normalized_norm_sq - 1.0f) > 0.00005f) { - fprintf(stderr, "pplx_l2_normalize produced norm_sq=%g\n", + fprintf(stderr, "embed_l2_normalize produced norm_sq=%g\n", normalized_norm_sq); free(states); free(normalized); @@ -317,8 +317,8 @@ int main(int argc, char **argv) goto fail; } - if (pplx_model_forward_into(model, batch_ws, ids[0], ntok[0], states) != 0) { - fprintf(stderr, "pplx_model_forward_into failed\n"); + if (embed_model_forward_into(model, batch_ws, ids[0], ntok[0], states) != 0) { + fprintf(stderr, "embed_model_forward_into failed\n"); free(states); free(normalized); free(single); @@ -338,7 +338,7 @@ int main(int argc, char **argv) /* Same separator resolution as the server: the fixture vocab defines * <|endoftext|>, real snapshots use the reserved id. */ int sep_id = qwen_tokenizer_token_id(tok, "<|endoftext|>"); - if (sep_id < 0) sep_id = PPLX_CONTEXT_SEPARATOR_TOKEN_ID; + if (sep_id < 0) sep_id = EMBED_CONTEXT_SEPARATOR_TOKEN_ID; if (check_spans_batch_parity(model, batch_ws, ids, ntok, sep_id, cfg) != 0) { free(states); @@ -355,9 +355,9 @@ int main(int argc, char **argv) for (int i = 0; i < batch; i++) free(ids[i]); qwen_tokenizer_free(tok); - pplx_workspace_free(single_ws); - pplx_workspace_free(batch_ws); - pplx_model_free(model); + embed_workspace_free(single_ws); + embed_workspace_free(batch_ws); + embed_model_free(model); if (worst_diff > 0.00005f || worst_cos < 0.99999f) { fprintf(stderr, "workspace API parity failed: max_abs_diff=%g cosine=%g\n", @@ -372,8 +372,8 @@ int main(int argc, char **argv) fail: for (int i = 0; i < batch; i++) free(ids[i]); qwen_tokenizer_free(tok); - pplx_workspace_free(single_ws); - pplx_workspace_free(batch_ws); - pplx_model_free(model); + embed_workspace_free(single_ws); + embed_workspace_free(batch_ws); + embed_model_free(model); return 1; } -- cgit v1.3.1