Commit Graph
3 Commits
Author SHA1 Message Date
Chao Zhang 3a716ead1a Add Windows ARM64 support to CI (#5544)
Summary:
Hi team, I'm from Microsoft and recently I'm working on improving Python ecosystem support for Windows on Arm.
So I updates the CI workflows to add support for Windows ARM64 build and release. Could you please help to review? Thanks.

**Windows ARM64 support and OpenBLAS installation improvements:**

* Added a new PowerShell script `install-openblas.ps1` that automatically detects the runner architecture (x64 or ARM64), downloads the appropriate OpenBLAS binary, verifies its hash, and installs it to `C:\openblas`. This ensures consistent and secure OpenBLAS setup on all Windows runners.
* Updated the build matrix in `.github/workflows/build-pip.yml` to include `windows-11-arm`, enabling CI builds and tests on Windows ARM64 runners.
* Refactored the Windows `before-all` build step in `pyproject.toml` to use the new PowerShell script, replacing the previous hardcoded x64-only download command. This allows seamless support for both x64 and ARM64 architectures.

Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5544

Reviewed By: mnorris11

Differential Revision: D117818430

Pulled By: trang-nm-nguyen

fbshipit-source-id: dac342878d063828437952e1b19f76e6699e1b6b
2026-08-28 10:06:58 -07:00
Alibek Zhakubayev 262fc3c7a2 Re-enable musllinux wheels for faiss-cpu (#5299)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5299

Re-enables musllinux wheel builds for the `faiss-cpu` PyPI package, restoring coverage that shipped through 1.13.x via the community `faiss-wheels` project and was dropped during the move to official wheels (#4862). Closes the gap reported in #5272 for Alpine and other musl-based container users.

musllinux builds on the existing Linux runners (`ubuntu-latest` for x86_64, `2-core-ubuntu-arm` for aarch64) using a different container image, so no GitHub Actions workflow change is needed. All changes are confined to `public_tld/pyproject.toml`:

- Remove `*-musllinux_*` from the cibuildwheel `skip` list. The deliberate `*-win32` and `cp3*t-*` (free-threaded, no abi3) skips are preserved.
- Add `*-musllinux*` to the abi3 build-collapse override so musl builds a single `cp310-abi3` wheel per arch. Without this, the global `build` list would rebuild the identical abi3 wheel filename 5x per arch into one `wheelhouse/`.
- Add `*-musllinux*` to the abi3audit override so the new wheels get `--strict` Stable ABI auditing.
- Add a musllinux-scoped override: OpenBLAS via `apk add --no-cache openblas-dev` (Alpine has no `dnf`), and `OMP_STACKSIZE=8M` for the test command. musl defaults thread stacks to ~128 KB vs glibc's ~8 MB, which causes SIGSEGV in HNSW/IVF OpenMP workers; 8M restores glibc parity. `test-requires` drops `scipy` (the smoke test does not import it) to avoid a fragile scipy sdist build on aarch64 musllinux.

Result: two new wheels, `cp310-abi3 musllinux_x86_64` and `cp310-abi3 musllinux_aarch64`.

Reviewed By: mnorris11

Differential Revision: D107909727

fbshipit-source-id: 90d0755ba90970cbd035fefeda9de4df9e28c872
2026-06-11 09:39:50 -07:00
Alibek Zhakubayev 585ba7954a Add pip install support via scikit-build-core + cibuildwheel (#4862)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4862

Add official pip wheel packaging for `faiss-cpu`, enabling
`pip install faiss-cpu` from PyPI. Builds binary wheels across Linux
x86_64/aarch64, macOS arm64/x86_64, and Windows x86_64 for Python 3.10-3.14.
Linux and macOS use Python Stable ABI (abi3) — a single cp310-abi3 wheel
per platform works on all Python 3.10+ versions without per-version rebuilds.

**BLAS strategy:**
- Linux (x86_64 and aarch64): Threaded OpenBLAS (`libopenblaso`). The
  CMake build prefers `libopenblaso` (OpenMP-threaded) or `libopenblasp`
  (pthreads-threaded) over the serial default on RHEL/Fedora-based
  manylinux containers.
- macOS: Apple Accelerate (found automatically).
- Windows: Prebuilt OpenBLAS from GitHub releases (v0.3.30).

**SIMD optimization strategy:**
- Linux and macOS: Dynamic Dispatch (`FAISS_OPT_LEVEL=dd`) compiles SIMD-hot
  kernel files at multiple ISA levels (generic + AVX2 + AVX-512 on x86_64,
  NEON + SVE on aarch64) into a single library. Runtime CPUID detection
  selects the optimal code path automatically.
- Windows: MSVC does not support DD, so uses `FAISS_OPT_LEVEL=generic`.
  Shared libraries (`BUILD_SHARED_LIBS=ON`) are used to avoid MSVC's
  single-pass static archive scanning issue.

**New files:**
- `pyproject.toml`: scikit-build-core build backend config with cibuildwheel
  settings. Version is dynamically extracted from CMakeLists.txt. Enables
  abi3 on Linux/macOS via SWIG 4.2+ and NumPy 2.0+ Limited API support.
  Enables LTO and dead-code stripping for smaller wheel sizes.
- `.github/workflows/build-pip.yml`: CI workflow using cibuildwheel to build
  binary wheels on 5 platform runners. All GitHub Actions are pinned to
  commit SHAs for supply chain security. Publishes wheels to PyPI via OIDC
  trusted publishers on tag push.
- `THIRD_PARTY_NOTICES`: License notices for bundled dependencies (OpenBLAS,
  LLVM OpenMP).
- `tests/test_wheel_smoke.py`: 12-test smoke suite validating import,
  OpenMP, BLAS (FlatL2/FlatIP), index factory (IVF+PQ), HNSW, serialization
  roundtrip, GC safety, contrib imports, and SIMD level detection.

**Modified files:**
- `faiss/CMakeLists.txt`: Added threaded OpenBLAS fallback — prefers
  `libopenblaso` (OpenMP-threaded) or `libopenblasp` (pthreads-threaded)
  over the serial default on RHEL/Fedora-based manylinux containers.
- `python/CMakeLists.txt`: Added `install()` targets for scikit-build-core
  wheel packaging, including all Dynamic Dispatch SWIG variants
  (avx2/avx512/avx512_spr/sve). Added abi3 support: conditionally uses
  `Python::SABIModule`, defines `Py_LIMITED_API`, and sets `.abi3.so` suffix
  when `SKBUILD_SABI_VERSION` is set.
- `.github/workflows/build.yml`: Wired `build-pip.yml` into the root CI
  trigger so pip builds run alongside conda builds.
- `tests/BUCK`: Added `python_pytest` target for the smoke test.

Reviewed By: mnorris11

Differential Revision: D95258115

fbshipit-source-id: 3593ed4fa5c1d8b7bebfc61c933bb3204c9666eb
2026-05-01 15:26:26 -07:00