pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
[pgvector/pgvector] issue #832: Perf: SIMD optimization for cosine similarity in pgvector
3+ messages / 1 participants
[nested] [flat]

* [pgvector/pgvector] issue #832: Perf: SIMD optimization for cosine similarity in pgvector
@ 2025-05-02 07:47  "rbalamohan (@rbalamohan)" <noreply+rbalamohan@github.com>
  0 siblings, 0 replies; 3+ messages in thread

From: rbalamohan (@rbalamohan) @ 2025-05-02 07:47 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

There are various cases where comparisons like 
`vector <=> '[0.01180855743587017,....-0.014453507959842682]` (1536 embeddings) are compared. This involves cosine similarity.  i.e in vector.c

Current implementation is based on scalar loop. Request is to provide options to make use of SIMD instructions on supported platforms. Almost all of modern h/w should support it, some docker images may not have the support. 

But basic request is to explore using SIMD instructions to speeden up things for this, when dimension are greater than 8.

^ permalink  raw  [nested|flat] 3+ messages in thread

* Re: [pgvector/pgvector] issue #832: Perf: SIMD optimization for cosine similarity in pgvector
@ 2025-05-02 07:58  "rbalamohan (@rbalamohan)" <noreply+rbalamohan@github.com>
  1 sibling, 0 replies; 3+ messages in thread

From: rbalamohan (@rbalamohan) @ 2025-05-02 07:58 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Looks like it is auto vectorized?
`make CFLAGS="-O3 -Rpass=loop-vectorize -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math"`
That mentioned the loop `for (int i = 0; i < dim; i++)` with remark `remark: vectorized loop`. 
If so, may be this ticket can be closed.

^ permalink  raw  [nested|flat] 3+ messages in thread

* Re: [pgvector/pgvector] issue #832: Perf: SIMD optimization for cosine similarity in pgvector
@ 2025-05-02 08:52  "rbalamohan (@rbalamohan)" <noreply+rbalamohan@github.com>
  1 sibling, 0 replies; 3+ messages in thread

From: rbalamohan (@rbalamohan) @ 2025-05-02 08:52 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@rbalamohan closed this.

^ permalink  raw  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2025-05-02 08:52 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-05-02 07:47 [pgvector/pgvector] issue #832: Perf: SIMD optimization for cosine similarity in pgvector "rbalamohan (@rbalamohan)" <noreply+rbalamohan@github.com>
2025-05-02 07:58 ` "rbalamohan (@rbalamohan)" <noreply+rbalamohan@github.com>
2025-05-02 08:52 ` "rbalamohan (@rbalamohan)" <noreply+rbalamohan@github.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox