Skip to content
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
1 change: 1 addition & 0 deletions examples/qa_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
template="templates.qa.open",
split="test",
format="formats.chat_api",
data_classification_policy=["public"],
)

model = CrossProviderInferenceEngine(model="SmolLM2-1.7B-Instruct", provider="hf-local")
Expand Down
12 changes: 6 additions & 6 deletions src/unitxt/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,9 +728,9 @@ def _get_model_args(self) -> Dict[str, Any]:
args["quantization_config"] = quantization_config
elif self.use_fp16:
if self.device == torch.device("mps"):
args["torch_dtype"] = torch.float16
args["dtype"] = torch.float16
else:
args["torch_dtype"] = torch.bfloat16
args["dtype"] = torch.bfloat16

# We do this, because in some cases, using device:auto will offload some weights to the cpu
# (even though the model might *just* fit to a single gpu), even if there is a gpu available, and this will
Expand Down Expand Up @@ -937,7 +937,7 @@ def _init_model(self):

self.model = LlavaForConditionalGeneration.from_pretrained(
self.model_name,
torch_dtype=self._get_torch_dtype(),
dtype=self._get_torch_dtype(),
low_cpu_mem_usage=self.low_cpu_mem_usage,
device_map=self.device_map,
)
Expand Down Expand Up @@ -1108,7 +1108,7 @@ def _init_model(self):
trust_remote_code=True,
device_map=self.device_map,
low_cpu_mem_usage=self.low_cpu_mem_usage,
torch_dtype=self._get_torch_dtype(),
dtype=self._get_torch_dtype(),
)
self.model = self.model.to(
dtype=self._get_torch_dtype()
Expand Down Expand Up @@ -1197,9 +1197,9 @@ def _get_model_args(self) -> Dict[str, Any]:
args["quantization_config"] = quantization_config
elif self.use_fp16:
if self.device == torch.device("mps"):
args["torch_dtype"] = torch.float16
args["dtype"] = torch.float16
else:
args["torch_dtype"] = torch.bfloat16
args["dtype"] = torch.bfloat16

# We do this, because in some cases, using device:auto will offload some weights to the cpu
# (even though the model might *just* fit to a single gpu), even if there is a gpu available, and this will
Expand Down