Skip to content

Commit

Permalink
fea(937): fixes related to OSError
Browse files Browse the repository at this point in the history
  • Loading branch information
imangohari1 committed Aug 7, 2024
1 parent 74611d9 commit 99e7df1
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1257,12 +1257,8 @@ def get_logits(model, input_features):
pt_filepath = os.path.join(tempdir, WAV2VEC2_ADAPTER_PT_FILE.format("eng"))
torch.save(adapter_weights, pt_filepath)

# model.load_adapter is broken in transformers
# since adapter_weights fails to load with weights_only=True
with self.assertRaises(OSError):
model.load_adapter("eng")
with self.assertRaises(OSError):
model.load_adapter("eng", use_safetensors=False)
model.load_adapter("eng")
model.load_adapter("eng", use_safetensors=False)
# we will load adapter_weights directly while model.load_adapter fails
state_dict = torch.load(pt_filepath)
state_dict = {k: v.to(adapter_weights[k]) for k, v in state_dict.items()}
Expand Down

0 comments on commit 99e7df1

Please sign in to comment.