Skip to content

fix(python): only bundle the DiskANN plugin where it is supported#510

Open
Cuiyus wants to merge 2 commits into
alibaba:mainfrom
Cuiyus:fix/wheel-diskann-only-when-supported
Open

fix(python): only bundle the DiskANN plugin where it is supported#510
Cuiyus wants to merge 2 commits into
alibaba:mainfrom
Cuiyus:fix/wheel-diskann-only-when-supported

Conversation

@Cuiyus

@Cuiyus Cuiyus commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Non-Linux-x86_64 wheels (e.g. macOS arm64) ship a useless libcore_knn_diskann.dylib — a ~16 KB shared library with zero exported symbols.

DiskAnn is only buildable on Linux x86_64 (it needs libaio). On every other platform src/core/algorithm/CMakeLists.txt still defines the core_knn_diskann target, but builds it from an empty stub (diskann_stub.cc). The runtime load path that would dlopen it is also compiled out via #if DISKANN_SUPPORTED (src/core/interface/index_factory.cc), so the stub is never loaded.

The wheel install rule gated on if(TARGET core_knn_diskann), which is always true (the stub target exists everywhere), so the dead stub got packaged into every wheel.

Fix

Gate the install on DISKANN_SUPPORTED instead of the target's existence:

if(DISKANN_SUPPORTED)
    install(TARGETS core_knn_diskann LIBRARY DESTINATION ${ZVEC_PY_INSTALL_DIR})
endif()

The plugin is now packaged only where it is real (Linux x86_64 with libaio). On Linux x86_64 the behaviour is unchanged.

Verification (macOS arm64)

  • libcore_knn_diskann.dylib no longer present in the wheel (nm -gU on the old stub confirmed 0 exported symbols)
  • import zvec works; HNSW/IVF/Flat/Vamana index types unaffected

@Cuiyus Cuiyus requested a review from feihongxu0824 as a code owner June 22, 2026 09:19
@Cuiyus Cuiyus force-pushed the fix/wheel-diskann-only-when-supported branch from 3d4f931 to f15e692 Compare June 22, 2026 09:54
The wheel install rule for the DiskANN plugin was gated on
`if(TARGET core_knn_diskann)`. That target always exists: on platforms where
DiskAnn is unsupported (macOS, ARM64, ...) it is built from an empty stub
(src/core/algorithm/CMakeLists.txt) with zero exported symbols, and the
runtime load path is compiled out via `#if DISKANN_SUPPORTED`. So the
condition was always true and a useless ~16 KB stub `.dylib` was shipped in
every non-Linux-x86_64 wheel.

Gate the install on `DISKANN_SUPPORTED` instead, so the plugin is packaged
only where it is real (currently Linux x86_64 with libaio).

Verified on macOS arm64: `libcore_knn_diskann.dylib` no longer appears in the
wheel; `import zvec` and other index types are unaffected.
@Cuiyus Cuiyus force-pushed the fix/wheel-diskann-only-when-supported branch from f15e692 to a6588ee Compare June 22, 2026 11:45
`wheel.packages = ["python/zvec"]` copies the directory into the wheel
verbatim, so a stray `_zvec*.so` / `*.dylib` / `*.pyd` left in the source
tree gets bundled — e.g. a stale binary with the wrong macOS deployment
target, which then fails `delocate` during wheel repair. Ignore these build
artifacts so they can never be committed or bundled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant