aboutsummaryrefslogtreecommitdiff
path: root/pplx_embed_mlx.h
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-06-03 19:18:09 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-06-14 08:27:03 +0200
commite751321fc00e07aeeb9337f5f21b7191b051c08a (patch)
tree2eaa7ad5075e37b31e45134bc40838c9b9f55e0e /pplx_embed_mlx.h
parentcb6ae157a09b6794f5d6da27dbc97e0ad791a146 (diff)
downloadffwd-e751321fc00e07aeeb9337f5f21b7191b051c08a.tar.gz
ffwd-e751321fc00e07aeeb9337f5f21b7191b051c08a.zip
mlx: keep late maxsim device resident
Diffstat (limited to 'pplx_embed_mlx.h')
-rw-r--r--pplx_embed_mlx.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/pplx_embed_mlx.h b/pplx_embed_mlx.h
index a7cb749..f2ad136 100644
--- a/pplx_embed_mlx.h
+++ b/pplx_embed_mlx.h
@@ -14,6 +14,7 @@
/* Opaque MLX model context */
typedef struct pplx_mlx_ctx pplx_mlx_ctx_t;
typedef struct pplx_mlx_late_ctx pplx_mlx_late_ctx_t;
+typedef struct pplx_mlx_late_vectors pplx_mlx_late_vectors_t;
typedef struct {
int quantize_bits; /* 0 disables; currently 8 */
@@ -65,6 +66,32 @@ int pplx_mlx_late_encode_tokens(pplx_mlx_late_ctx_t *ctx,
int normalize, float *out_vectors);
/*
+ * Device-resident late-interaction token vectors.
+ *
+ * The model context owns the MLX stream; the returned vector handle must not
+ * outlive ctx. Copying is optional: MaxSim can consume these handles directly
+ * and copy back only final candidate scores.
+ */
+pplx_mlx_late_vectors_t *pplx_mlx_late_encode_tokens_device(
+ pplx_mlx_late_ctx_t *ctx, const int *token_ids, int n_tokens,
+ int normalize);
+void pplx_mlx_late_vectors_free(pplx_mlx_late_vectors_t *vecs);
+int pplx_mlx_late_vectors_token_count(const pplx_mlx_late_vectors_t *vecs);
+int pplx_mlx_late_vectors_dim(const pplx_mlx_late_vectors_t *vecs);
+int pplx_mlx_late_vectors_copy(const pplx_mlx_late_vectors_t *vecs,
+ float *out_vectors);
+pplx_mlx_late_vectors_t *pplx_mlx_late_vectors_concat(
+ pplx_mlx_late_ctx_t *ctx,
+ const pplx_mlx_late_vectors_t *const *items, int count);
+pplx_mlx_late_vectors_t *pplx_mlx_late_vectors_select(
+ pplx_mlx_late_ctx_t *ctx, const pplx_mlx_late_vectors_t *vecs,
+ const int *token_indices, int count);
+int pplx_mlx_late_maxsim_batch_device(
+ pplx_mlx_late_ctx_t *ctx, const pplx_mlx_late_vectors_t *query,
+ const pplx_mlx_late_vectors_t *docs, const int *doc_offsets,
+ int docs_count, float *scores);
+
+/*
* Compute embedding for token_ids[0..n_tokens-1].
* Returns malloc'd float[hidden_size] (caller frees). NULL on error.
*/