aboutsummaryrefslogtreecommitdiff
path: root/tests/test_qwen3.c
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-06-20 20:36:55 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-06-21 06:00:26 +0200
commit6652fcbc653d84e75cb5c08c5f5edf52263ed50f (patch)
tree1ccffa48e1dc86c59c61dcd4672ffedcf1e0c873 /tests/test_qwen3.c
parentdbdf714bb57578431924e5d069089bdfd9f4c604 (diff)
downloadffwd-6652fcbc653d84e75cb5c08c5f5edf52263ed50f.tar.gz
ffwd-6652fcbc653d84e75cb5c08c5f5edf52263ed50f.zip
tests: upgrade unit tests and add integration/parity tests
Diffstat (limited to 'tests/test_qwen3.c')
-rw-r--r--tests/test_qwen3.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/tests/test_qwen3.c b/tests/test_qwen3.c
index d66e0f7..5d1387a 100644
--- a/tests/test_qwen3.c
+++ b/tests/test_qwen3.c
@@ -1,6 +1,6 @@
/* tests/test_qwen3.c - hermetic Qwen3 model semantics. */
-#include "embed.h"
+#include "internal.h"
#include "tiny_model.h"
#include <math.h>
@@ -21,7 +21,7 @@ static float max_abs_diff(const float *a, const float *b, int n) {
int main(void) {
char dir[1024];
- snprintf(dir, sizeof(dir), "%s/embed-qwen3-test-XXXXXX",
+ snprintf(dir, sizeof(dir), "%s/ffwd-qwen3-test-XXXXXX",
getenv("TMPDIR") ? getenv("TMPDIR") : "/tmp");
tm_dims_t dims = {4, 2, 1, 2, 8, 16};
if (!mkdtemp(dir) || tm_write_qwen3_model_dims(dir, "F32", &dims, 15) != 0) {
@@ -29,15 +29,15 @@ int main(void) {
return 2;
}
- embed_model_t *model = embed_model_load(dir);
- embed_workspace_t *ws = embed_workspace_new(model);
- const embed_config_t *cfg = embed_model_config(model);
+ ffwd_model_t *model = ffwd_model_load(dir);
+ ffwd_workspace_t *ws = ffwd_workspace_new(model);
+ const ffwd_config_t *cfg = ffwd_model_config(model);
if (!model || !ws || !cfg) {
fprintf(stderr, "model setup failed\n");
return 1;
}
- if (cfg->attention_mode != EMBED_ATTENTION_CAUSAL ||
- cfg->pooling_mode != EMBED_POOL_LAST_TOKEN || !cfg->normalize_embeddings ||
+ if (cfg->attention_mode != FFWD_ATTENTION_CAUSAL ||
+ cfg->pooling_mode != FFWD_POOL_LAST_TOKEN || !cfg->normalize_embeddings ||
!cfg->append_terminal_token) {
fprintf(stderr, "Qwen3 config semantics were not detected\n");
return 1;
@@ -47,16 +47,16 @@ int main(void) {
float states[4 * 4];
float embedding[4];
float pooled[4];
- if (embed_model_forward_into(model, ws, ids, 4, states) != 0 ||
- embed_model_encode_into(model, ws, ids, 4, embedding) != 0 ||
- embed_pool_batch(cfg, states, (int[]){4}, 1, pooled) != 0) {
+ if (ffwd_model_forward_into(model, ws, ids, 4, states) != 0 ||
+ ffwd_model_encode_into(model, ws, ids, 4, embedding) != 0 ||
+ ffwd_pool_batch(cfg, states, (int[]){4}, 1, pooled) != 0) {
fprintf(stderr, "Qwen3 inference failed\n");
return 1;
}
float expected[4];
memcpy(expected, states + 3 * 4, sizeof(expected));
- if (embed_l2_normalize(expected, 4) != 0 || max_abs_diff(embedding, expected, 4) > 1e-5f ||
+ if (ffwd_l2_normalize(expected, 4) != 0 || max_abs_diff(embedding, expected, 4) > 1e-5f ||
max_abs_diff(pooled, expected, 4) > 1e-5f) {
fprintf(stderr, "last-token pooling mismatch\n");
return 1;
@@ -71,18 +71,18 @@ int main(void) {
}
int short_ids[] = {4, 15};
- embed_input_t inputs[] = {{ids, 4}, {short_ids, 2}};
+ ffwd_input_t inputs[] = {{ids, 4}, {short_ids, 2}};
float batch[8];
float single[4];
- if (embed_model_encode_batch(model, ws, inputs, 2, batch) != 0 ||
- embed_model_encode_into(model, ws, short_ids, 2, single) != 0 ||
+ if (ffwd_model_encode_batch(model, ws, inputs, 2, batch) != 0 ||
+ ffwd_model_encode_into(model, ws, short_ids, 2, single) != 0 ||
max_abs_diff(batch, embedding, 4) > 1e-5f || max_abs_diff(batch + 4, single, 4) > 1e-5f) {
fprintf(stderr, "Qwen3 packed batch parity failed\n");
return 1;
}
- embed_workspace_free(ws);
- embed_model_free(model);
+ ffwd_workspace_free(ws);
+ ffwd_model_free(model);
puts("ok: Qwen3 causal attention and last-token pooling");
return 0;
}