-
Notifications
You must be signed in to change notification settings - Fork 2k
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
feat!: Add extra for inference dependencies such as torch #5147
Conversation
Pull Request Test Coverage Report for Build 5314673912
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's just one problem I'd like to clarify before approving this
haystack/document_stores/memory.py
Outdated
torch_import.check() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: I would always put these check at the very first line of the init. If the deps are not there, no point doing anything else, running any super(), making any checks, etc... It should be the first issue the users are warned about.
haystack/modeling/infer.py
Outdated
from haystack.lazy_imports import LazyImport | ||
|
||
with LazyImport() as torch_import: | ||
import torch | ||
from torch.utils.data.sampler import SequentialSampler | ||
from torch.utils.data import Dataset | ||
from haystack.modeling.utils import initialize_device_settings, set_all_seeds # pylint: disable=ungrouped-imports |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be needed: this check is done in haystack/modeling/__init__.py
, which always run before this module: https://github.com/deepset-ai/haystack/blob/main/haystack/modeling/__init__.py
If that check does not work, let's rather understand why and fix it at that level. Otherwise we would have to try-catch all imports across all modeling modules, which I'd rather avoid 😅
haystack/modeling/infer.py
Outdated
@@ -73,6 +77,7 @@ def __init__( | |||
:return: An instance of the Inferencer. | |||
|
|||
""" | |||
torch_import.check() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
Thank you for your feedback @ZanSara I addressed the change requests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thank you! I'll let you choose the name of the extra, I don't have strong opinions there 👍
@bilgeyucel and I agreed on the name |
Related Issues
Proposed Changes:
pip install farm-haystack
->pip install farm-haystack[inference]
. Users who ran the former in the past now need to run the latter to install the same set of dependencies.inference
.Let's discuss the name of this extra.inference
extra contains torch, sentencepiece extras of transformers so that the versions that are compatible with transformers are installed. It also contains the huggingface hub dependency and sentence-transformers.How did you test it?
Notes for the reviewer
haystack/haystack/nodes/retriever/multimodal/embedder.py
Line 8 in 7731713
transformers
#5101 .still need tochecked whether it makes more sense to keephuggingface-hub
as a core dependencyhuggingface-hub
can be part of the inference extra.Once we have agreed on the name of the extra, I will add a message to all the lazydonetorch_imports
andtorch_and_transformers_imports
sayingmessage="Run 'pip install farm-haystack[inference]'"
Alternatives
An alternative would be to also remove plain transformers (without extras) from Haystack's standard dependencies. I think we shouldn't do that. It further reduces the installation to a minimum and thus saves installation time and memory but transformers is required for many things users can do with Haystack and even a PromptNode with a transformers model requires it.
Checklist
fix:
,feat:
,build:
,chore:
,ci:
,docs:
,style:
,refactor:
,perf:
,test:
.