Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

faiss: 1.8.0->1.9.0 #341418

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 8 additions & 52 deletions pkgs/development/libraries/science/math/faiss/default.nix
SomeoneSerge marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@
in
# Choose the maximum available optimization level
builtins.head optLevels,
faiss, # To run demos in the tests
runCommand,
}@inputs:

let
pname = "faiss";
version = "1.8.0";
version = "1.9.0";

inherit (cudaPackages) flags backendStdenv;

Expand All @@ -46,27 +44,15 @@ in
stdenv.mkDerivation {
inherit pname version;

outputs = [
"out"
"demos"
] ++ lib.optionals pythonSupport [ "dist" ];
outputs = [ "out" ] ++ lib.optionals pythonSupport [ "dist" ];

src = fetchFromGitHub {
owner = "facebookresearch";
repo = pname;
rev = "v${version}";
hash = "sha256-nS8nhkNGGb2oAJKfr/MIAZjAwMxBGbNd16/CkEtv67I=";
hash = "sha256-P8TynU6jz5NbcWLdI7n4LX5Gdz0Ks72bmOzQ3LGjQCQ=";
};

# Remove the following substituteInPlace when updating
# to a release that contains change from PR
# https://github.com/facebookresearch/faiss/issues/3239
# that fixes building faiss with swig 4.2.x
postPatch = ''
substituteInPlace faiss/python/swigfaiss.swig \
--replace-fail '#ifdef SWIGWORDSIZE64' '#if (__SIZEOF_LONG__ == 8)'
'';

nativeBuildInputs =
[ cmake ]
++ lib.optionals cudaSupport [
Expand Down Expand Up @@ -99,13 +85,7 @@ stdenv.mkDerivation {
(lib.cmakeFeature "CMAKE_CUDA_ARCHITECTURES" flags.cmakeCudaArchitecturesString)
];

buildFlags =
[ "faiss" ]
# This is just a demo app used as a test.
# Disabled because linkage fails:
# https://github.com/facebookresearch/faiss/issues/3484
++ lib.optionals (!cudaSupport) [ "demo_ivfpq_indexing" ]
++ lib.optionals pythonSupport [ "swigfaiss" ];
buildFlags = [ "faiss" ] ++ lib.optionals pythonSupport [ "swigfaiss" ];

# pip wheel->pip install commands copied over from opencv4

Expand All @@ -114,32 +94,10 @@ stdenv.mkDerivation {
python -m pip wheel --verbose --no-index --no-deps --no-clean --no-build-isolation --wheel-dir dist .)
'';

postInstall =
''
mkdir -p $demos/bin
if [[ "$buildInputs" == *demo_ivfpq_indexing* ]] ; then
cp ./demos/demo_ivfpq_indexing $demos/bin/
fi
''
+ lib.optionalString pythonSupport ''
mkdir "$dist"
cp faiss/python/dist/*.whl "$dist/"
'';

passthru = {
inherit cudaSupport cudaPackages pythonSupport;

tests = {
runDemos =
Comment on lines -132 to -133
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to have more thorough integration testing in the long term, but I guess right now this is more of a maintenance burden

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. The demos don't seem to go through their CI, alas.

runCommand "${pname}-run-demos" { buildInputs = [ faiss.demos ]; }
# There are more demos, we run just the one that documentation mentions
''
demo_ivfpq_indexing && touch $out
'';
pythonFaiss = pythonPackages.faiss;
pytest = pythonPackages.faiss.tests.pytest;
};
};
postInstall = lib.optionalString pythonSupport ''
mkdir "$dist"
cp faiss/python/dist/*.whl "$dist/"
'';

meta = {
description = "Library for efficient similarity search and clustering of dense vectors by Facebook Research";
Expand All @@ -148,7 +106,5 @@ stdenv.mkDerivation {
license = lib.licenses.mit;
platforms = lib.platforms.unix;
maintainers = with lib.maintainers; [ SomeoneSerge ];
# error: use of undeclared identifier 'SWIGTYPE_p_long'
broken = stdenv.hostPlatform.isDarwin;
};
}