Skip to content

Commit

Permalink
Add specific Emu2 loading: bfloat16 weights
Browse files Browse the repository at this point in the history
  • Loading branch information
Gnurro committed Apr 30, 2024
1 parent ddf47d5 commit ff86080
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion backends/huggingface_multimodal_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ def load_model(model_spec: backends.ModelSpec):

if hasattr(model_spec, 'trust_remote_code'):
if model_spec['trust_remote_code']:
model = model_type.from_pretrained(hf_model_str, device_map="auto", torch_dtype="auto",
if model_spec['model_type'] == "Emu2":
model = model_type.from_pretrained(hf_model_str, device_map="auto", torch_dtype="bfloat16",
trust_remote_code=model_spec['trust_remote_code'])
else:
model = model_type.from_pretrained(hf_model_str, device_map="auto", torch_dtype="auto",
trust_remote_code=model_spec['trust_remote_code'])
else:
model = model_type.from_pretrained(hf_model_str, device_map="auto", torch_dtype="auto") # Load the model
Expand Down

0 comments on commit ff86080

Please sign in to comment.