pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
[pgvector/pgvector] issue #665: Question: Performance gain in using halfvec datatype
3+ messages / 2 participants
[nested] [flat]

* [pgvector/pgvector] issue #665: Question: Performance gain in using halfvec datatype
@ 2024-09-02 10:50  "bbkgh (@bbkgh)" <noreply+bbkgh@github.com>
  0 siblings, 0 replies; 3+ messages in thread

From: bbkgh (@bbkgh) @ 2024-09-02 10:50 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Hi. Can using the halfvec datatype instead of fp32 result in better search performance (response time and throughput) on the server side, or is it just for better storage usage and index creation?

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

* Re: [pgvector/pgvector] issue #665: Question: Performance gain in using halfvec datatype
@ 2024-09-03 14:24  "jkatz (@jkatz)" <noreply+jkatz@github.com>
  1 sibling, 0 replies; 3+ messages in thread

From: jkatz (@jkatz) @ 2024-09-03 14:24 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@bbkgh At the risk of a slightly unsatisfying answer, it depends on a few things, including:

1. Your access pattern (e.g., full table scans vs. index scans) and ultimately how many pages (units of storage) / vectors need to be compared.
1. Your chosen embedding model and how the data is ultimately clustered together in the vector index
1. How pgvector is compiled and on what architecture, as some architectures contain SIMD instructions that can speed up fp16 (`halfvec`) computations.
1. What your search parameters / recall targets are, which impact total number of vectors compared

In my own testing with a variety of embedding models on architectures that supported fp16 SIMD acceleration, with smaller numbers of vectors (low millions), I've seen either no performance difference, or `halfvec` edging out `vector` under high concurrency. However, in quantization cases, as the number of embeddings increased, I would need to increase `hnsw.ef_search` to get the same level of recall for `halfvec` compared to `vector`, though often I'd see both have comparable performance.  I haven't tried doing comparisons yet with fixed recall on 100MM+ datasets, so I can't comment to far beyond that, but this is why my answer is a "it depends." :smile:

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

* Re: [pgvector/pgvector] issue #665: Question: Performance gain in using halfvec datatype
@ 2024-09-03 16:19  "bbkgh (@bbkgh)" <noreply+bbkgh@github.com>
  1 sibling, 0 replies; 3+ messages in thread

From: bbkgh (@bbkgh) @ 2024-09-03 16:19 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@bbkgh closed this.

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


end of thread, other threads:[~2024-09-03 16:19 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-09-02 10:50 [pgvector/pgvector] issue #665: Question: Performance gain in using halfvec datatype "bbkgh (@bbkgh)" <noreply+bbkgh@github.com>
2024-09-03 14:24 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
2024-09-03 16:19 ` "bbkgh (@bbkgh)" <noreply+bbkgh@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