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

Drop torch 1.10, 1.11, 1.12 #845

Merged
merged 3 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 0 additions & 99 deletions .flexci/config.pbtxt
Original file line number Diff line number Diff line change
@@ -1,51 +1,3 @@
configs {
key: "pytorch-pfn-extras.torch110-linux"
value {
requirement {
cpu: 8
gpu: 2
memory: 52
disk: 10
}
time_limit: {
seconds: 1800
}
command: "bash .flexci/linux/main-flexci.sh torch110"
}
}

configs {
key: "pytorch-pfn-extras.torch111-linux"
value {
requirement {
cpu: 8
gpu: 2
memory: 52
disk: 10
}
time_limit: {
seconds: 1800
}
command: "bash .flexci/linux/main-flexci.sh torch111"
}
}

configs {
key: "pytorch-pfn-extras.torch112-linux"
value {
requirement {
cpu: 8
gpu: 2
memory: 52
disk: 10
}
time_limit: {
seconds: 1800
}
command: "bash .flexci/linux/main-flexci.sh torch112"
}
}

configs {
key: "pytorch-pfn-extras.torch113-linux"
value {
Expand Down Expand Up @@ -110,57 +62,6 @@ configs {
}
}

configs {
key: "pytorch-pfn-extras.torch110-win"
value {
requirement {
cpu: 4
gpu: 1
memory: 24
disk: 10
image: "windows"
}
time_limit: {
seconds: 1800
}
command: ".flexci\\windows\\run.bat torch110"
}
}

configs {
key: "pytorch-pfn-extras.torch111-win"
value {
requirement {
cpu: 4
gpu: 1
memory: 24
disk: 10
image: "windows"
}
time_limit: {
seconds: 1800
}
command: ".flexci\\windows\\run.bat torch111"
}
}

configs {
key: "pytorch-pfn-extras.torch112-win"
value {
requirement {
cpu: 4
gpu: 1
memory: 24
disk: 10
image: "windows"
}
time_limit: {
seconds: 1800
}
command: ".flexci\\windows\\run.bat torch112"
}
}

configs {
key: "pytorch-pfn-extras.torch113-win"
value {
Expand Down
27 changes: 0 additions & 27 deletions .flexci/linux/build_and_push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,6 @@ docker_build_and_push() {
}

case "${TARGET}" in
torch110 )
# PyTorch 1.10 + Python 3.9
docker_build_and_push \
--build-arg base_image="nvidia/cuda:11.3.1-cudnn8-devel-ubuntu20.04" \
--build-arg python_version="3.9.7" \
--build-arg pip_install_torch_args="torch==1.10.* torchvision==0.11.* -f https://download.pytorch.org/whl/cu113/torch_stable.html" \
--build-arg pip_install_dep_args="cupy-cuda11x"
;;

torch111 )
# PyTorch 1.11 + Python 3.9
docker_build_and_push \
--build-arg base_image="nvidia/cuda:11.5.2-cudnn8-devel-ubuntu20.04" \
--build-arg python_version="3.9.7" \
--build-arg pip_install_torch_args="torch==1.11.* torchvision==0.12.* -f https://download.pytorch.org/whl/cu115/torch_stable.html" \
--build-arg pip_install_dep_args="cupy-cuda11x"
;;

torch112 )
# PyTorch 1.12 + Python 3.10
docker_build_and_push \
--build-arg base_image="nvidia/cuda:11.7.1-cudnn8-devel-ubuntu20.04" \
--build-arg python_version="3.10.5" \
--build-arg pip_install_torch_args="torch==1.12.* torchvision==0.13.* -f https://download.pytorch.org/whl/cu117/torch_stable.html" \
--build-arg pip_install_dep_args="cupy-cuda11x"
;;

torch113 )
# PyTorch 1.13 + Python 3.10
docker_build_and_push \
Expand Down
35 changes: 1 addition & 34 deletions .flexci/windows/test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,7 @@ $ErrorActionPreference = "Stop"


# Setup environment
if ($test -eq "torch110") {
# PyTorch 1.10 + Python 3.9
ActivateCUDA 11.8
ActivatePython 3.9
RunOrDie python -m pip install -U pip "setuptools<59.6"
RunOrDieWithRetry 3 python -m pip install torch==1.10.* torchvision==0.11.* -f https://download.pytorch.org/whl/cu113/torch_stable.html
# NOTE(linsho):
# Due to reports of the ONNX build for Windows being broken, we are temporarily limiting the version of ONNX.
# cf. https://github.com/onnx/onnx/issues/6267
RunOrDie python -m pip install -r tests/requirements.txt cupy-cuda11x "onnx<=1.16.1"

} elseif ($test -eq "torch111") {
# PyTorch 1.11 + Python 3.9
ActivateCUDA 11.3
ActivatePython 3.9
RunOrDie python -m pip install -U pip "setuptools<59.6"
RunOrDieWithRetry 3 python -m pip install torch==1.11.* torchvision==0.12.* -f https://download.pytorch.org/whl/cu113/torch_stable.html
# NOTE(linsho):
# Due to reports of the ONNX build for Windows being broken, we are temporarily limiting the version of ONNX.
# cf. https://github.com/onnx/onnx/issues/6267
RunOrDie python -m pip install -r tests/requirements.txt cupy-cuda11x "onnx<=1.16.1"

} elseif ($test -eq "torch112") {
# PyTorch 1.12 + Python 3.10
ActivateCUDA 11.3
ActivatePython 3.10
RunOrDie python -m pip install -U pip "setuptools<59.6"
RunOrDieWithRetry 3 python -m pip install torch==1.12.* torchvision==0.13.* -f https://download.pytorch.org/whl/cu113/torch_stable.html
# NOTE(linsho):
# Due to reports of the ONNX build for Windows being broken, we are temporarily limiting the version of ONNX.
# cf. https://github.com/onnx/onnx/issues/6267
RunOrDie python -m pip install -r tests/requirements.txt cupy-cuda11x "onnx<=1.16.1"

} elseif ($test -eq "torch113") {
if ($test -eq "torch113") {
# PyTorch 1.13 + Python 3.10
ActivateCUDA 11.7
ActivatePython 3.10
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pretest-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
torch: ['1.10.*', '1.11.*', '1.12.*', '1.13.*', '2.0.*', '2.1.*', '2.2.*']
torch: ['1.13.*', '2.0.*', '2.1.*', '2.2.*']

steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pip install cupy # or cupy-cudaXXX
## Requirements

* Python 3.9+
* PyTorch 1.10+
* PyTorch 1.13+

Optional dependencies:

Expand Down
16 changes: 4 additions & 12 deletions pytorch_pfn_extras/onnx/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@
import torch.onnx
import torch.onnx.symbolic_helper

if pytorch_pfn_extras.requires("1.13.0"):
from torch.onnx._constants import ONNX_DEFAULT_OPSET, ONNX_CONSTANT_FOLDING_MIN_OPSET, ONNX_MAX_OPSET # type: ignore[attr-defined]
onnx_default_opset = ONNX_DEFAULT_OPSET
onnx_constant_folding_opsets = range(ONNX_CONSTANT_FOLDING_MIN_OPSET, ONNX_MAX_OPSET)
onnx_main_opset = ONNX_MAX_OPSET
elif pytorch_pfn_extras.requires("1.12.0"):
from torch.onnx._constants import * # type: ignore # NOQA
else:
onnx_default_opset = torch.onnx.symbolic_helper._default_onnx_opset_version # type: ignore
onnx_main_opset = torch.onnx.symbolic_helper._onnx_main_opset # type: ignore
onnx_stable_opsets = torch.onnx.symbolic_helper._onnx_stable_opsets # type: ignore
onnx_constant_folding_opsets = torch.onnx.symbolic_helper._constant_folding_opset_versions if pytorch_pfn_extras.requires("1.11.0") else torch.onnx.constant_folding_opset_versions # type: ignore[attr-defined]
from torch.onnx._constants import ONNX_DEFAULT_OPSET, ONNX_CONSTANT_FOLDING_MIN_OPSET, ONNX_MAX_OPSET # type: ignore[attr-defined]
onnx_default_opset = ONNX_DEFAULT_OPSET
onnx_constant_folding_opsets = range(ONNX_CONSTANT_FOLDING_MIN_OPSET, ONNX_MAX_OPSET)
onnx_main_opset = ONNX_MAX_OPSET
26 changes: 2 additions & 24 deletions pytorch_pfn_extras/onnx/_globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,6 @@
from typing import Optional


if pytorch_pfn_extras.requires("1.12.0"):
import torch.onnx._globals
GLOBALS = torch.onnx._globals.GLOBALS
import torch.onnx._globals
GLOBALS = torch.onnx._globals.GLOBALS

else:
import torch.onnx.symbolic_helper as symhel

class _InternalGlobalsBeforeTorch1_11:
@property
def export_onnx_opset_version(self) -> int:
return symhel._export_onnx_opset_version # type: ignore

@property
def operator_export_type(self) -> Optional[torch._C._onnx.OperatorExportTypes]:
return symhel._operator_export_type # type: ignore

@property
def training_mode(self) -> Optional[torch._C._onnx.TrainingMode]:
return symhel._training_mode # type: ignore

@property
def onnx_shape_inference(self) -> bool:
return symhel._onnx_shape_inference # type: ignore

GLOBALS = _InternalGlobalsBeforeTorch1_11() # type: ignore[assignment]
4 changes: 0 additions & 4 deletions pytorch_pfn_extras/onnx/annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ def __init__(self) -> None:
def setup(self, model: nn.Module, opset_ver: int) -> None:
self._model: Optional[nn.Module] = model
# dryrun to register every aten ops
if not pytorch_pfn_extras.requires("1.13.0"):
import pytorch_pfn_extras.onnx.symbolic_registry as sym_reg

sym_reg.register_version('', opset_ver) # type: ignore[no-untyped-call,attr-defined]
self.opset_ver = opset_ver

@property
Expand Down
71 changes: 28 additions & 43 deletions pytorch_pfn_extras/onnx/export_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,9 @@ def _export_util(
if aten or export_raw_ir:
assert operator_export_type is None
assert aten ^ export_raw_ir
# Note: OperatorExportTypes.RAW unavailable in PyTorch 1.10+
operator_export_type = OperatorExportTypes.ONNX_ATEN if\
aten else OperatorExportTypes.RAW # type: ignore
operator_export_type = OperatorExportTypes.ONNX_ATEN
elif operator_export_type is None:
if pytorch_pfn_extras.requires("1.12.0"):
use_onnx_aten_fallback = torch.onnx._CAFFE2_ATEN_FALLBACK # type: ignore[attr-defined]
else:
use_onnx_aten_fallback = torch.onnx.PYTORCH_ONNX_CAFFE2_BUNDLE # type: ignore[attr-defined]

use_onnx_aten_fallback = torch.onnx._CAFFE2_ATEN_FALLBACK # type: ignore[attr-defined]
if use_onnx_aten_fallback:
operator_export_type = OperatorExportTypes.ONNX_ATEN_FALLBACK
else:
Expand All @@ -128,24 +122,19 @@ def _export_util(
# This is a temporal workaround until a fix is introduced in PyTorch.
try:
torch.onnx.utils._model_to_graph = _model_to_graph_with_value_names
if pytorch_pfn_extras.requires('1.10.0'):
checker_error = getattr(torch.onnx, "CheckerError", None)
if checker_error is None:
checker_error = torch.onnx.utils.ONNXCheckerError # type: ignore[attr-defined]
try:
enable_onnx_checker = kwargs.pop('enable_onnx_checker', None)
return torch_export( # type: ignore[no-untyped-call]
model, args, f, **kwargs)
except checker_error:
if enable_onnx_checker:
raise
if return_output:
# Re-run the model to obtain the output.
return model(*args)
else:
kwargs['_retain_param_name'] = True
checker_error = getattr(torch.onnx, "CheckerError", None)
if checker_error is None:
checker_error = torch.onnx.utils.ONNXCheckerError # type: ignore[attr-defined]
try:
enable_onnx_checker = kwargs.pop('enable_onnx_checker', None)
return torch_export( # type: ignore[no-untyped-call]
model, args, f, **kwargs)
except checker_error:
if enable_onnx_checker:
raise
if return_output:
# Re-run the model to obtain the output.
return model(*args)
finally:
torch.onnx.utils._model_to_graph = old_model_to_graph

Expand All @@ -165,32 +154,29 @@ def _export(
opset_ver = kwargs.get('opset_version', None)
force_verbose = False

if pytorch_pfn_extras.requires("1.13.0"):
if "training" in kwargs and (isinstance(kwargs["training"], bool) or kwargs['training'] is None):
kwargs["training"] = torch.onnx.TrainingMode.TRAINING \
if kwargs["training"] \
else torch.onnx.TrainingMode.EVAL
if "training" in kwargs and (isinstance(kwargs["training"], bool) or kwargs['training'] is None):
kwargs["training"] = torch.onnx.TrainingMode.TRAINING \
if kwargs["training"] \
else torch.onnx.TrainingMode.EVAL

if pytorch_pfn_extras.requires('1.12.0'):
original_log = torch.onnx.log # type: ignore[attr-defined]
original_log = torch.onnx.log # type: ignore[attr-defined]
if opset_ver is None:
opset_ver = pytorch_pfn_extras.onnx._constants.onnx_default_opset
kwargs['opset_version'] = opset_ver
if use_pfto or not pytorch_pfn_extras.requires('1.10.0'):
if use_pfto:
strip_doc_string = kwargs.get('strip_doc_string', True)
kwargs['strip_doc_string'] = False
else:
strip_doc_string = kwargs.pop('strip_doc_string', True)
if not kwargs.get('verbose', False):
force_verbose = True
if pytorch_pfn_extras.requires('1.12.0'):
# Following line won't work because verbose mode always
# enable logging so we are replacing python function instead:
# torch.onnx.disable_log()
def no_op(*args: Any) -> None:
pass

torch.onnx.log = no_op # type: ignore[attr-defined]
# Following line won't work because verbose mode always
# enable logging so we are replacing python function instead:
# torch.onnx.disable_log()
def no_op(*args: Any) -> None:
pass

torch.onnx.log = no_op # type: ignore[attr-defined]
kwargs['verbose'] = True
# Exted args with kwargs (including default values)
args = _decide_input_format(model, args) # type: ignore[no-untyped-call]
Expand Down Expand Up @@ -223,9 +209,8 @@ def no_op(*args: Any) -> None:
_strip_large_initializer_raw_data(onnx_graph, large_tensor_threshold)

if force_verbose:
if pytorch_pfn_extras.requires('1.12.0'):
# torch.onnx.enable_log()
torch.onnx.log = original_log # type: ignore[attr-defined]
# torch.onnx.enable_log()
torch.onnx.log = original_log # type: ignore[attr-defined]

return onnx_graph, outs

Expand Down
Loading
Loading