Skip to content

Releases

v0.9.2 — Micro-batched index scans no longer fail with 64 or more concurrent clients

Choose a tag to compare

@github-actions github-actions released this 15 Nov 12:38
21680ce

Micro-batched index scans no longer fail with 64 or more concurrent clients

The GPU regression workflow (gpu.yml) was not run on release/v0.9.2. The fix
below was run on one GPU host: 1x A100-SXM4-80GB, 24 vCPU, PostgreSQL 16.15, cuVS
26.04 built with SDK patches 0001-0004, 0006 and 0007, 999,000 x 768 float32
vectors, L2, LIMIT 10, pgbench in prepared mode, 30 s per run, one run per client
count unless noted. With a cagra index, cuvs.k = 100 and
cuvs.cagra_batch_wait_us = 200, the source of 0.9.1 plus the version bump
(dfdce616) aborted 14 and 11 of 64 clients (two runs) and 461 of 512; the source
of this release aborted none at 64, 128, 256 and 2048 clients. With a flat index,
cuvs.k = 10 and cuvs.bf_batch_wait_us = 200, dfdce616 aborted 4 of 64 clients
and this release none at 64 and 256.

Fixed

  • With a CAGRA or brute-force micro-batch window (cuvs.cagra_batch_wait_us or
    cuvs.bf_batch_wait_us > 0) and 64 pgbench clients, some statements failed with
    GPU daemon unavailable after planning while the daemon was running. A batch
    releases all its waiters at once, every request opens a new connection, and the
    daemon's listen backlog of 32 filled up. A backend whose connect() waited for a
    slot and received a signal failed with EINTR, because the socket's send timeout
    keeps the kernel from restarting the call. PostgreSQL 15 and later backends can receive
    SIGALRM while busy: the idle stats-flush timeout (10 s) is armed when a backend
    goes idle and is not disarmed when the next query starts (postgres.c, "we don't
    disable the timeout below"). Every connect() now waits in 250 ms slices and
    retries after a signal or an expired slice within the call's timeout (30 s for a
    search), and checks for a pending cancel or termination after each attempt.
    cuvs_ipc_search, which CAGRA and flat index scans use, then reports a canceled
    query; the other calls (filtered, streaming, transient brute-force, IVF-PQ and
    batch search, builds) end the connect as before with their connect-failure status.
    A connect that finally fails is logged with its errno ([cuvs_ipc] connect to ... failed; a missing or stale socket stays at debug level). The daemon listens
    with a backlog of 1024, which shortens the wait but is not the fix; the kernel caps
    it at net.core.somaxconn, and the daemon logs a warning at startup when that cap
    is below one batch (256). The scan errors no longer say that the breaker is open
    (retry will use CPU while breaker is open): the per-backend breaker opens only
    after cuvs.circuit_breaker_threshold consecutive failures, and the errors now say
    so. The UNAVAILABLE error reads GPU daemon unavailable after planning; connecting to the daemon socket failed, and its HINT no longer says that the daemon crashed.
    The protocol-mismatch error, which non-scan paths raise too, drops the breaker
    clause. When make_shm_key fails, the plain, batch, filtered, streaming
    brute-force and IVF-PQ search calls no longer pass an uninitialized name to
    shm_unlink. The retry is covered by a Linux unit test against a full
    backlog. (#224)

Upgrading

  • Build the release from its tag, install the extension and the daemon together
    (make install and make install-server), restart PostgreSQL and then the
    daemon, and run ALTER EXTENSION pg_cuvs UPDATE TO '0.9.2'; in each database
    (SELECT extversion FROM pg_extension WHERE extname = 'pg_cuvs' shows 0.9.2
    afterwards). The upgrade script changes no SQL object, and the IPC protocol is
    the one of 0.9.1. The connect retry is in the extension and the larger listen
    backlog is in the daemon. The steps and the restart order are in
    docs/playbooks/release-upgrade.md.

v0.9.1 — Faster HNSW import, resident NN-descent builds, a WAL fix and two CAGRA SDK patches

Choose a tag to compare

@github-actions github-actions released this 15 Nov 08:51
b171e13

Faster HNSW import, resident NN-descent builds, a WAL fix and two CAGRA SDK patches

The GPU regression workflow (gpu.yml) was not run on release/v0.9.1; the GPU
measurements below are the ones named in each entry.

Added

  • pg_cuvs_hnsw_connectivity_status(regclass) and a connectivity object in
    pg_cuvs_hnsw_build_info(): a snapshot, taken when an HNSW index is built, of
    structural reachability from the entry point, level-0 reachability and the number
    of weakly connected components. It is opt-in: SET cuvs.hnsw_connectivity_check = on (bool, default off, USERSET) before CREATE INDEX or REINDEX. A build with
    the setting off records {"status":"disabled",...}, which differs from
    not_recorded of an index built before the snapshot existed. It is a build
    snapshot, not live graph integrity: INSERT, DELETE, VACUUM and entry-point changes
    do not update it, structural reachability does not guarantee recall at a finite
    ef_search, and rows that the check finds unreachable are not recovered by search
    (#203 stays open for that). The check changes no edge, seed or search result, and a
    check that cannot finish does not fail the build. One that needs more than
    maintenance_work_mem continues in an unlinked file under base/pgsql_tmp and is
    unavailable under a finite temp_file_limit. Cost on one A100-SXM4-80GB over a
    999,000 x 768 fp32 heap with build_algo='ivf_pq': CREATE INDEX took 25.41 to
    25.95 s with the setting off (five runs, median 25.60 s) and 27.45 to 27.74 s with
    it on (four runs, mean 27.59 s, of which the check is 2.26 to 2.28 s); the
    unchanged main took 25.60 to 25.70 s (four runs). recall@10 at ef_search 40 and
    160 was 0.9667 and 0.9948 off and 0.9675 and 0.9947 on; two builds of the same
    index differ from each other, so this is not a claim of identical results. With
    build_algo='nn_descent' the same setting applies: 34.46 s off, 36.56 s on, 34.32 s
    on unchanged main, one run each, recall not measured. A graph file larger than the
    page cache was not measured. Native GPU runs on four inputs of 1.0 to 2.2 million
    rows passed, made with the check always on before the setting existed, and were not
    repeated on the final code. (#208)
  • build_algo='nn_descent' for CREATE INDEX ... USING pg_cuvs_hnsw builds a
    resident NN-descent base graph and never falls back to another builder. It rejects
    fewer than 16 rows, an effective intermediate degree above 1024, non-finite input
    and input whose conservative FP32 distance bound overflows. The base dtype is FP32
    when the dimension is 16 or less, an element exceeds the half range, or the
    resident IVF-PQ norm bound reaches 65504, and FP16 otherwise. L2 builds feed
    NN-descent a column-centered copy (mean accumulated in float64) so that a common
    offset does not destroy the neighbour order; stored vectors and search distances use
    the original rows. The build receipt is policy v3 with an NN tail, and the HNSW
    op 23 payload is v6: deploy the extension and the daemon together. GPU check, made
    after the merge message was written, on one A100 80GB PCIe VM: CREATE INDEX ... USING pg_cuvs_hnsw (embedding vector_l2_ops) WITH (build_algo='nn_descent', ef_construction=64, mode='hnsw') over a 999000 x 768 fp32 heap took 40.8 s (one
    run) and gave recall@10 0.7905, 0.9850 and 0.9953 at ef_search 10, 80 and 160;
    with ef_construction=128 (one run, a profiler attached) 49.4 s and 0.7584,
    0.9812 and 0.9949, a lower recall at small ef_search than at 64 that is not
    explained yet (#209). The binary was built from commit 09de6aef with a cuVS SDK
    of patches 0001 to 0007 (libcuvs.so SHA-256 ceda5af3...). That commit has the
    source files of the merged code (the head of the merged branch has the tree of the
    merge commit and differs from 09de6aef in tests and documentation only); the
    merged commit itself was not rebuilt. (#211)
  • SDK patch 0005 (resident NN-descent upper levels) is tracked in
    infra/cuvs-patches. The runtime marker that the daemon requires now ends in the
    SHA-256 of the three patched files, so for build_algo='nn_descent' with a GPU
    hierarchy an SDK build with the old marker is rejected and must be rebuilt. The
    recipe builds against a copy of the installed RAFT patched by raft/0001 and with
    BUILD_MG_ALGOS=ON (infra/cuvs-patches/prepare-raft-prefix.sh,
    scripts/prepare-patched-cuvs-source.sh). (#211)
  • The Tier 1 CI job runs make test-hnsw-converter (fixtures of the HNSW page
    writers, the node-location table and the source-less import). No workflow ran it
    before. (#210)
  • The Tier 1 CI job runs make test-k3-digest: CREATE INDEX on a live backend
    against a scripted fake daemon (daemon failure, daemon CANCELED, success, a
    held RPC with statement_timeout, a client lost during the RPC), checking the
    digest LOG line count, the digest against SHA-256 of the inserted rows and the
    build error. The unit-test step has a 20 minute limit and the digest step 10. (#214)
  • Unit tests: test-hnsw-digest (in test-unit); the read windows of the
    source-less import against direct reads under injected EIO, EINTR and short
    reads; idle-work cases in test-hnsw-build-ipc that are ordered by flags instead
    of sleeps and fail after 10 s with a named condition instead of hanging.
    (#214, #215)
  • The CPU CI job runs make test-source-checks: the HNSW route source checks and
    their mutation scripts, which no workflow ran before. Two of the checks had gone
    stale on main (one expected an order of calls that a later change had renamed,
    one read a commit that a depth-1 checkout does not have) and were repaired, each
    with a planted defect that must turn it red. (#218)
  • Release process: CHANGELOG.md; the "Branches and releases" rules in
    CONTRIBUTING.md; CI runs on release/** branches; the Release draft workflow
    creates a draft GitHub release from a vX.Y.Z tag and refuses a tag that is not
    on release/vX.Y.Z or whose version files or changelog section do not match
    (scripts/release-check.sh, scripts/release-notes.sh, tested by
    test/release/test_release_scripts.sh).
  • CI refuses a pull request that edits, renames or deletes an SQL script of a
    version below default_version, and any SQL script change into a release branch
    (scripts/check-sql-frozen.sh, tested by test/release/test_sql_frozen.sh).

Changed

  • Extension version 0.9.1. sql/pg_cuvs--0.9.1.sql is the 0.9.0 install script plus
    pg_cuvs_hnsw_connectivity_status(), which sql/pg_cuvs--0.9.0--0.9.1.sql adds
    too and which is the only SQL object it changes; the two 0.9.0 scripts are
    frozen. Object-store manifests are stamped with the
    new PG_CUVS_VERSION; a manifest with another pg_cuvs version logs a version
    drift warning and loads, and only a cuVS version mismatch rejects an artifact.
    make docs-contract-check reads the version from pg_cuvs.control and checks
    that every sql/pg_cuvs--*.sql is in the Makefile DATA list. (#219)
  • Source-less HNSW import (CREATE INDEX ... USING pg_cuvs_hnsw), four changes
    that leave pages, page order and WAL records as they were. Timings are from one
    A100-SXM4-80GB VM (24 vCPU, 113 GiB RAM) with build_algo='ivf_pq',
    ef_construction=128, shared_buffers 32GB, maintenance_work_mem 8GB and 11
    parallel maintenance workers, over a 999000 x 768 fp32 heap, with cuVS 26.04
    patches 0001 to 0004, 0006 and an earlier form of 0007 held fixed (the absolute
    times need that SDK). Medians of three runs with min to max in parentheses,
    except where one run is stated; the daemon and PostgreSQL were started fresh for
    every run. On the 10,000 official queries recall@10 stayed in the run-to-run range
    (0.966 to 0.968 at ef_search 40, 0.994 to 0.995 at 160).
    • (#210) Node locations that follow the regular page layout are computed instead of read
      back through a four-page cache. Replaying the access order of the import gave
      64,935,002 lookups with 56,497,735 cache misses, about 462 GB of 8 KB read
      requests against a table of about 8 MB. One run on a diagnostic build: import
      of the data pages 48.57 s to 11.25 s, CREATE INDEX 81.67 s to 44.27 s, the same
      3,588,907,769 bytes of WAL. Any row that does not match the layout turns the
      computation off for that table and the old path serves it; for graphs with
      hierarchy the computation switched off, so they take the old path and gain
      nothing from this change.
    • (#213) Data pages are added to the relation in groups of up to 32 buffers
      (ExtendBufferedRelBy(), PostgreSQL 16 and later) instead of one block per
      call. CREATE INDEX 33.150 s (32.77 to 33.36) to 30.004 s (29.94 to 30.08); the
      import after the daemon reply 14.105 s to 11.130 s. A batch holds up to 32 extra
      buffer pins. Not run on a PostgreSQL build with assertions, not through crash
      recovery.
    • (#214) The input digest (the SHA-256 LOG line that binds a build to its input) is
      computed from the vectors spool file while the backend waits for the daemon,
      not inside the heap scan. Against the code before the read windows below:
      CREATE INDEX 30.145 s (29.99 to 30.77) to 28.145 s (27.99 to 28.70); heap scan,
      spool and preflight 8.982 s to 6.882 s; the daemon job did not change. The
      value and the text of the LOG line are unchanged, but it is now printed after
      the daemon reply, an interrupt or an error before the RPC no longer prints it,
      and if rereading the spool fails after a successful daemon build CREATE INDEX
      aborts and the GPU build time is lost. The gain depends on the CPU (about 2 s
      here, on a VM with SHA instructions).
    • (#215) Level-0 fields, upper-level records and TIDs are read through fixed 1 MiB
      windows instead of one pread each. Against the same baseline: CREATE INDEX
      27.739 s (27.58 to 27.94), together with the digest change 25.608 s (25.58 to
      ...
Read more

v0.0.1 - Phase 1 (Proof of Mechanism)

Choose a tag to compare

@ysys143 ysys143 released this 24 May 14:53

Phase 1 Complete — Proof of Mechanism

GPU-accelerated vector search for PostgreSQL via NVIDIA cuVS, end-to-end working.

Architecture

  • PostgreSQL C extension with C++/CUDA wrapper split (ADR-001)
  • pg_cuvs_server GPU sidecar daemon (UDS command + shm_open zero-copy data)
  • cuVS 26.04 CAGRA build/search/serialize via libcuvs
  • PostgreSQL 16 + pgvector 0.8 integration

Acceptance criteria met

  • CREATE INDEX USING cagra triggers GPU build via cuvsCagraBuild
  • Daemon serves >=2 concurrent UDS connections
  • Index persistence: SIGTERM serialize + startup deserialize
  • 4-condition CPU fallback: cost model, enable_cuvs=off, daemon down, circuit breaker
  • pgvector operator classes (<->, <=>, <#>) via cagra AM
  • pg_cuvs_reset_circuit(regclass) admin function

Infrastructure

  • Terraform: GCP A100/L4/H100 VM provisioning
  • Conda-based libcuvs + CUDA toolchain
  • Targeted libstdc++ symlink to avoid ldconfig pollution
  • systemd unit for daemon

Project skills

  • gpu-vm-provision: VM provisioning with failure-mode catalog (depth-2)
  • pg-cuvs-dev: dev workflow, traps and fixes

Known limits

  • pg_cuvs_server runs single-threaded GPU ops (mutex-guarded)
  • Search top_k hardcoded at 100 (planner LIMIT integration deferred)
  • DiskANN/Vamana AM and S3 storage deferred to Phase 2/3

Verified on

  • GCP us-central1-b a2-highgpu-1g (A100-SXM4-40GB)
  • Ubuntu 22.04 LTS + CUDA 12.4 + libcuvs 26.04 + PG 16.14 + pgvector 0.8.0