Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import 'optim' only if PyTorch is installed #22072

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nfnt
Copy link

@nfnt nfnt commented Sep 12, 2024

Description

Classes in onnxruntime.training.optim depend on 'torch' being installed. This dependency spreads to all packages in onnxruntime.training when adding it in training/__init__.py. By ensuring that it is only added if 'torch' is installed, we can avoid this dependency.

Motivation and Context

The 'torch' package can be very large and its size can be problematic in some training environments on the edge. As it won't be used if not using onnxruntime.training.optim it would be great to not depend on it in these environments.
See also #22070

Classes in 'onnxruntime.training.optim' depend on 'torch' being installed.
This dependency spread to all packages in 'onnxruntime.training' when adding in in 'training/__init__.py'.
By ensuring that it is only added if 'torch' is installed, we can avoid this dependency.
@xadupre
Copy link
Member

xadupre commented Sep 13, 2024

/azp run Big Models,Linux Android Emulator QNN CI Pipeline,Linux CPU CI Pipeline,Linux CPU Minimal Build E2E CI Pipeline,Linux GPU CI Pipeline,Linux GPU TensorRT CI Pipeline,Linux OpenVINO CI Pipeline,Linux QNN CI Pipeline

Copy link

Azure Pipelines successfully started running 8 pipeline(s).

@xadupre
Copy link
Member

xadupre commented Sep 13, 2024

/azp run MacOS CI Pipeline,MacOS CI Pipeline,ONNX Runtime Web CI Pipeline,Windows ARM64 QNN CI Pipeline,Windows CPU CI Pipeline,Windows GPU CUDA CI Pipeline,Windows GPU DML CI Pipeline

Copy link

Azure Pipelines successfully started running 6 pipeline(s).

@xadupre
Copy link
Member

xadupre commented Sep 13, 2024

/azp run Windows GPU Doc Gen CI Pipeline,Windows GPU TensorRT CI Pipeline,Windows x64 QNN CI Pipeline,onnxruntime-binary-size-checks-ci-pipeline,orttraining-linux-ci-pipeline,orttraining-linux-gpu-ci-pipeline

Copy link

Azure Pipelines successfully started running 6 pipeline(s).

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.

2 participants