Skip to content

Initial implementation of vector similarity index#63675

Merged
rschu1ze merged 31 commits intoClickHouse:masterfrom
rschu1ze:vector-search
Aug 13, 2024
Merged

Initial implementation of vector similarity index#63675
rschu1ze merged 31 commits intoClickHouse:masterfrom
rschu1ze:vector-search

Conversation

@rschu1ze
Copy link
Copy Markdown
Member

@rschu1ze rschu1ze commented May 12, 2024

This PR changed too many things to enumerate here. I tried to keep individual commits small, self-contained, and properly described (commit msg). Reviewers may go through the individual commits.

In sum:

  • the old (experimental) vector indexes annoy and usearch are gone (*)
  • they were replaced by a new (still experimental) index type vector_similarity,
  • obscure edge cases of vector search are no longer supported: tuples, WHERE-type queries, Lp norms
  • polishing and fixes all over the place
  • the new vector_similarity index is under setting allow_experimental_vector_similarity_index

(*) it will still be possible to load old tables annoy/usearch indexes but data insert / search will throw a message that recommends migration to vector_similarity.

Fixes: #49669

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

@robot-ch-test-poll1 robot-ch-test-poll1 added pr-not-for-changelog This PR should not be mentioned in the changelog submodule changed At least one submodule changed in this PR. labels May 12, 2024
@robot-ch-test-poll1
Copy link
Copy Markdown
Contributor

robot-ch-test-poll1 commented May 12, 2024

This is an automated comment for commit fb76cb9 with description of existing statuses. It's updated for the latest CI running

❌ Click here to open a full report in a separate page

Check nameDescriptionStatus
Stateful testsRuns stateful functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc❌ failure
Successful checks
Check nameDescriptionStatus
AST fuzzerRuns randomly generated queries to catch program errors. The build type is optionally given in parenthesis. If it fails, ask a maintainer for help✅ success
BuildsThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
ClickBenchRuns [ClickBench](https://github.com/ClickHouse/ClickBench/) with instant-attach table✅ success
Compatibility checkChecks that clickhouse binary runs on distributions with old libc versions. If it fails, ask a maintainer for help✅ success
Docker keeper imageThe check to build and optionally push the mentioned image to docker hub✅ success
Docker server imageThe check to build and optionally push the mentioned image to docker hub✅ success
Docs checkBuilds and tests the documentation✅ success
Fast testNormally this is the first check that is ran for a PR. It builds ClickHouse and runs most of stateless functional tests, omitting some. If it fails, further checks are not started until it is fixed. Look at the report to see which tests fail, then reproduce the failure locally as described here✅ success
Flaky testsChecks if new added or modified tests are flaky by running them repeatedly, in parallel, with more randomization. Functional tests are run 100 times with address sanitizer, and additional randomization of thread scheduling. Integration tests are run up to 10 times. If at least once a new test has failed, or was too long, this check will be red. We don't allow flaky tests, read the doc✅ success
Install packagesChecks that the built packages are installable in a clear environment✅ success
Integration testsThe integration tests report. In parenthesis the package type is given, and in square brackets are the optional part/total tests✅ success
Performance ComparisonMeasure changes in query performance. The performance test report is described in detail here. In square brackets are the optional part/total tests✅ success
Stateless testsRuns stateless functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc✅ success
Stress testRuns stateless functional tests concurrently from several clients to detect concurrency-related errors✅ success
Style checkRuns a set of checks to keep the code style clean. If some of tests failed, see the related log from the report✅ success
Unit testsRuns the unit tests for different release types✅ success
Upgrade checkRuns stress tests on server version from last release and then tries to upgrade it to the version from the PR. It checks if the new server can successfully startup without any errors, crashes or sanitizer asserts✅ success

@rschu1ze rschu1ze force-pushed the vector-search branch 7 times, most recently from b0655d4 to a819c8c Compare May 14, 2024 22:45
@aaroncueckermann
Copy link
Copy Markdown

@rschu1ze Sorry to jump into the draft, I was just wondering if you had an idea about what kind of search speed performance improvements we might see in Clickhouse Cloud (if any) due to the SimSIMD hardware acceleration (e.g. negligible, 2x, 10x?)

@rschu1ze
Copy link
Copy Markdown
Member Author

rschu1ze commented Jun 5, 2024

@rschu1ze rschu1ze force-pushed the vector-search branch 2 times, most recently from 7c03aaa to 93daa99 Compare June 10, 2024 18:35
@rschu1ze rschu1ze changed the title (wip) Polishing vector search Initial implementation of vector similarity index Jun 10, 2024
@rschu1ze rschu1ze marked this pull request as ready for review June 10, 2024 20:10
@antaljanosbenjamin antaljanosbenjamin self-assigned this Jun 12, 2024
antaljanosbenjamin

This comment was marked as resolved.

@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Aug 6, 2024

Dear @antaljanosbenjamin, this PR hasn't been updated for a while. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

First, index type "vector_similarity" is more speaking and user-friendly
than "usearch". Second, we should not expose the name of the library
doing the job (usearch). Of course, the docs will continue to mention
usearch (credit where credit is due).

Existing setting `allow_experimental_usearch_index` was marked obsolete.
A new settings `allow_experimental_vector_similarity_index` was added.
Index types 'annoy' and 'usearch' were removed and replaced by
'vector_similarity' indexes in an earlier commit.

This means unfortuantely, that if customers have tables with these
indexes and upgrade, their database might not start anymore - the
system loads the metadata at startup, thinks something is wrong with
such tables, and halts immediately.

This commit adds support for loading and attaching such indexes back.
Data insert or use (search) return an error which recommends a migration
to 'vector_similarity' indexes. The implementation is generally similar
to what has recently been implemented for 'full_text' indexes [1, 2].

[1] ClickHouse#64656
[2] ClickHouse#64846
USearch (similar to FAISS) allows to specify the distance function,
quantization, and various HNSW meta-parameters for index creation and
sarch. Some users wished for greater configurability, so let's expose
them.

Index creation now requires either
- 2 parameters (with the other 4 parameters taking on default values), or
- 6 parameters for full control

This commit also remove quantization `f64` (that would be upsampling).
Previously, only this syntax to create a skip index worked:

   INDEX index_name column_name TYPE vector_similarity('hnsw', 'L2Distance')

Now, this syntax will work as well:

  INDEX index_name column_name TYPE vector_similarity(hnsw, L2Distance)
@rschu1ze
Copy link
Copy Markdown
Member Author

ClickHouse Stateful tests (tsan, ParallelReplicas): #66683

Copy link
Copy Markdown
Member

@antaljanosbenjamin antaljanosbenjamin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only minor things, feel free to merge the PR and the issues can be addressed in another PR easily, none of them critical.

@rschu1ze
Copy link
Copy Markdown
Member Author

Thanks @antaljanosbenjamin Thanks for checking. I actually already work on the successor PR and will include all your suggestions there.

@rschu1ze rschu1ze added this pull request to the merge queue Aug 13, 2024
Merged via the queue into ClickHouse:master with commit 2ffcc97 Aug 13, 2024
@rschu1ze rschu1ze deleted the vector-search branch August 13, 2024 15:39
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 13, 2024
@rschu1ze rschu1ze mentioned this pull request Aug 20, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for ANN index for arm64 (graviton)

5 participants