Skip to content

fix: make torch an optional dependency in sagemaker-core#5756

Draft
matteociccozzi-ah wants to merge 1 commit intoaws:masterfrom
matteociccozzi-ah:fix/torch-optional-dependency
Draft

fix: make torch an optional dependency in sagemaker-core#5756
matteociccozzi-ah wants to merge 1 commit intoaws:masterfrom
matteociccozzi-ah:fix/torch-optional-dependency

Conversation

@matteociccozzi-ah
Copy link
Copy Markdown

Summary

  • torch>=1.9.0 was declared as a hard dependency in sagemaker-core/pyproject.toml despite only being used by TorchTensorSerializer and TorchTensorDeserializer. This forced torch (a multi-GB package) onto all consumers of sagemaker-core, including those with no PyTorch workloads.
  • Moved torch to [project.optional-dependencies] under the torch extra — install with pip install sagemaker-core[torch]
  • Added proper ImportError handling with an actionable message in both classes (the serializer had no error handling at all; the deserializer raised a bare Exception)
  • Added unit tests for the ImportError path in both classes

torch>=1.9.0 was a hard dependency despite only being used by
TorchTensorSerializer and TorchTensorDeserializer. Moved to
optional-dependencies[torch]. Added proper ImportError handling
with actionable install hint in both classes and unit tests for
the ImportError path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant