Skip to content

Commit

Permalink
Bugfix: properly pass kwargs to torch.jit.load from `mlfow.pytorch.…
Browse files Browse the repository at this point in the history
…load_model` (#5163)

* pass kwargs to `torch.jit.load`

Signed-off-by: Jake Schmidt <jacob.schmidt@recursionpharma.com>

* pop pickle_module

Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>

Co-authored-by: harupy <17039389+harupy@users.noreply.github.com>
  • Loading branch information
Jake Schmidt and harupy committed Dec 16, 2021
1 parent 9cf25c0 commit 044ad9e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mlflow/pytorch/__init__.py
Expand Up @@ -635,7 +635,8 @@ def _load_model(path, **kwargs):
return torch.load(model_path, **kwargs)
except Exception:
# If fails, assume the model as a scripted model
return torch.jit.load(model_path)
kwargs.pop("pickle_module", None) # `torch.jit.load` does not accept `pickle_module`.
return torch.jit.load(model_path, **kwargs)


def load_model(model_uri, dst_path=None, **kwargs):
Expand Down

0 comments on commit 044ad9e

Please sign in to comment.