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

Fp16 clip update #331

Merged
merged 2 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
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
9 changes: 5 additions & 4 deletions src/marqo/s2_inference/clip_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,11 @@ def __init__(self, model_type: str = "fp16/ViT-B/32", device: str = 'cuda', emb
'''

if not self.device.startswith("cuda"):
raise IncompatibleModelDeviceError(f"Marqo can not load the provided model `{self.model_type}`"
f"FP16 clip model `{self.model_type}` is only available with device `cuda`."
f"Please check you cuda availability or try the fp32 version `{self.model_type.replace('fp16/','')}`"
f"Check `https://docs.marqo.ai/0.0.13/Models-Reference/dense_retrieval/#generic-clip-models` for more info.")
logger.warning(f"The fp16 clip model `{self.model_type} is loaded with device `{self.device}`."
f"FP16 clip model `{self.model_type}` is only available with device `cuda`.\n"
f"With current device `{self.device}`, the model will be loaded in `float32` mode. \n"
f"Please check you cuda availability or try the fp32 version `{self.model_type.replace('fp16/','')}`"
f"Check `https://docs.marqo.ai/0.0.13/Models-Reference/dense_retrieval/#generic-clip-models` for more info.")

self.model_name = self.model_type.replace("fp16/", "")

Expand Down
8 changes: 4 additions & 4 deletions tests/s2_inference/test_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def tearDown(self) -> None:
clear_loaded_models()

def test_vectorize(self):
names = ["open_clip/convnext_base_w/laion2b_s13b_b82k",
names = ["fp16/ViT-B/32", "open_clip/convnext_base_w/laion2b_s13b_b82k",
"open_clip/convnext_base_w_320/laion_aesthetic_s13b_b82k_augreg",
"onnx16/open_clip/ViT-B-32/laion400m_e32", 'onnx32/open_clip/ViT-B-32-quickgelu/laion400m_e32',
"all-MiniLM-L6-v1", "all_datasets_v4_MiniLM-L6", "hf/all-MiniLM-L6-v1", "hf/all_datasets_v4_MiniLM-L6",
Expand All @@ -51,7 +51,7 @@ def test_vectorize(self):


def test_load_clip_text_model(self):
names = [ "onnx16/open_clip/ViT-B-32/laion400m_e32", 'onnx32/open_clip/ViT-B-32-quickgelu/laion400m_e32',
names = ["fp16/ViT-B/32", "onnx16/open_clip/ViT-B-32/laion400m_e32", 'onnx32/open_clip/ViT-B-32-quickgelu/laion400m_e32',
'RN50', "ViT-B/16", "open_clip/convnext_base_w/laion2b_s13b_b82k",
"open_clip/convnext_base_w_320/laion_aesthetic_s13b_b82k_augreg",]

Expand Down Expand Up @@ -131,7 +131,7 @@ def test_compare_onnx_sbert_text_models(self):


def test_model_outputs(self):
names = ["open_clip/convnext_base_w/laion2b_s13b_b82k",
names = ["fp16/ViT-B/32", "open_clip/convnext_base_w/laion2b_s13b_b82k",
"open_clip/convnext_base_w_320/laion_aesthetic_s13b_b82k_augreg",
"onnx16/open_clip/ViT-B-32/laion400m_e32", 'onnx32/open_clip/ViT-B-32-quickgelu/laion400m_e32',
'open_clip/ViT-B-32/laion400m_e32', "all-MiniLM-L6-v1",
Expand All @@ -153,7 +153,7 @@ def test_model_outputs(self):


def test_model_normalization(self):
names = ["onnx16/open_clip/ViT-B-32/laion400m_e32", 'onnx32/open_clip/ViT-B-32-quickgelu/laion400m_e32',
names = ["fp16/ViT-B/32", "onnx16/open_clip/ViT-B-32/laion400m_e32", 'onnx32/open_clip/ViT-B-32-quickgelu/laion400m_e32',
'open_clip/ViT-B-32/laion400m_e32', 'RN50', "ViT-B/16", "all-MiniLM-L6-v1",
"all_datasets_v4_MiniLM-L6", "hf/all-MiniLM-L6-v1", "hf/all_datasets_v4_MiniLM-L6",
"onnx/all-MiniLM-L6-v1", "onnx/all_datasets_v4_MiniLM-L6"]
Expand Down