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

Remove conditional import of FAISS for Windows #819

Merged
merged 2 commits into from
Feb 12, 2021
Merged

Conversation

tanaysoni
Copy link
Contributor

Since FAISS is now supported on Windows, we can remove the conditional import of faiss in the FAISSDocumentDocumentStore.

Resolves #817

Copy link
Member

@tholor tholor left a comment

Choose a reason for hiding this comment

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

I gave it a quick test in a Windows VM. Installation of 1.6.3 via pip still seems to crash:

    Complete output (38 lines):
    running install
    running build
    running build_ext
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\PietschMalte\AppData\Local\Temp\pip-install-iue3tn7s\faiss-cpu\setup.py", line 87, in <module>
        setup(
      File "C:\Users\PietschMalte\Miniconda3\lib\site-packages\setuptools\__init__.py", line 144, in setup
        return distutils.core.setup(**attrs)
      File "C:\Users\PietschMalte\Miniconda3\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "C:\Users\PietschMalte\Miniconda3\lib\distutils\dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "C:\Users\PietschMalte\Miniconda3\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\PietschMalte\Miniconda3\lib\site-packages\setuptools\command\install.py", line 61, in run
        return orig.install.run(self)
      File "C:\Users\PietschMalte\Miniconda3\lib\distutils\command\install.py", line 545, in run
        self.run_command('build')
      File "C:\Users\PietschMalte\Miniconda3\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\Users\PietschMalte\Miniconda3\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\PietschMalte\Miniconda3\lib\distutils\command\build.py", line 135, in run
        self.run_command(cmd_name)
      File "C:\Users\PietschMalte\Miniconda3\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\Users\PietschMalte\Miniconda3\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\PietschMalte\AppData\Local\Temp\pip-install-iue3tn7s\faiss-cpu\setup.py", line 45, in run
        build_ext.run(self)
      File "C:\Users\PietschMalte\Miniconda3\lib\distutils\command\build_ext.py", line 340, in run
        self.build_extensions()
      File "C:\Users\PietschMalte\AppData\Local\Temp\pip-install-iue3tn7s\faiss-cpu\setup.py", line 50, in build_extensions
        self._remove_flag('-Wstrict-prototypes')
      File "C:\Users\PietschMalte\AppData\Local\Temp\pip-install-iue3tn7s\faiss-cpu\setup.py", line 58, in _remove_flag
        compiler = self.compiler.compiler
    AttributeError: 'MSVCCompiler' object has no attribute 'compiler'
    ----------------------------------------

1.6.5 and 1.7.0 seem to work (at least installation succeeded).
I would propose to update to faiss 1.7.0 and test if everything in Haystack is still compatible

@lalitpagaria
Copy link
Contributor

Actually we can use 1.7.0 which have latest changes.

Also soon they will support M1 Mac support

@lalitpagaria
Copy link
Contributor

Actually we can use 1.7.0 which have latest changes.

Also soon they will support M1 Mac support

Sorry I missed reading @tholor comment

@tholor
Copy link
Member

tholor commented Feb 10, 2021

@tanaysoni we'll need FAISS benchmarks here (which are not included yet in the CI runs). I can take care of this

@tholor
Copy link
Member

tholor commented Feb 12, 2021

Benchmarks look okay. mAP is similar. speed is a bit slower but can be due to smaller random fluctuations. I think the benefit of moving to the latest FAISS version is big enough to justify merging.

FAISS Benchmarks for this branch:

retriever doc_store n_docs n_queries retrieve_time queries_per_second seconds_per_query recall map top_k date_time error
0 dpr faiss_flat 1000 1064 30.651 34.7133 0.0288074 99.1541 92.9511 10 2021-02-11 09:23:44.893784
2 dpr faiss_flat 10000 5637 256.807 21.9503 0.0455574 97.4987 89.871 10 2021-02-11 09:29:55.871041
4 dpr faiss_flat 100000 5637 1187.45 4.74715 0.210653 95.7956 86.5461 10 2021-02-11 09:57:26.376901
1 dpr faiss_hnsw 1000 1064 30.4996 34.8857 0.028665 99.1541 92.9511 10 2021-02-11 09:24:47.604630
3 dpr faiss_hnsw 10000 5637 193.939 29.0658 0.0344047 97.2503 89.6994 10 2021-02-11 09:34:11.557157
5 dpr faiss_hnsw 100000 5637 503.186 11.2026 0.0892648 94.0216 85.0798 10 2021-02-11 10:11:33.449578

Last run on master:

retriever doc_store n_docs n_queries retrieve_time queries_per_second seconds_per_query recall map top_k date_time error
2 dpr faiss_flat 1000 1064 30.0533 35.4038 0.0282456 0.991541 0.929511 10 2021-02-01 11:28:55.544474
6 dpr faiss_flat 10000 5637 218.594 25.7875 0.0387785 0.974987 0.89871 10 2021-02-01 11:42:07.545869
10 dpr faiss_flat 100000 5637 865.744 6.51116 0.153582 0.957956 0.865461 10 2021-02-01 12:34:29.493598
14 dpr faiss_flat 500000 5637 3717.95 1.51616 0.659561 0.930814 0.808614 10 2021-02-01 16:12:52.804436
3 dpr faiss_hnsw 1000 1064 27.1677 39.1641 0.0255336 0.991541 0.929511 10 2021-02-01 11:30:02.684535
7 dpr faiss_hnsw 10000 5637 167.552 33.6432 0.0297237 0.972503 0.896994 10 2021-02-01 11:46:07.130588
11 dpr faiss_hnsw 100000 5637 167.482 33.6573 0.0297112 0.940216 0.850798 10 2021-02-01 12:43:21.697968
15 dpr faiss_hnsw 500000 5637 164.456 34.2767 0.0291743 0.882562 0.769148 10 2021-02-01 16:47:01.710072

@tanaysoni tanaysoni merged commit 8b0031b into master Feb 12, 2021
@tanaysoni tanaysoni deleted the fix-faiss-import branch February 12, 2021 11:15
@tholor tholor mentioned this pull request Feb 17, 2021
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.

Importing Haystack with Windows Fails due to FAISS
4 participants