Skip to content

Commit 601996b

Browse files
authored
Add security warning for vulnerable PyTorch versions (#123)
This commit adds security warning and tidies up some codes. TICO-DCO-1.0-Signed-off-by: seongwoo <mhs4670go@naver.com>
1 parent 621e94c commit 601996b

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

tico/__init__.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,25 @@
1818
from packaging.version import Version
1919

2020
from tico.config import CompileConfigV1, get_default_config
21-
2221
from tico.utils.convert import convert, convert_from_exported_program, convert_from_pt2
2322

2423
# THIS LINE IS AUTOMATICALLY GENERATED BY setup.py
2524
__version__ = "0.1.0"
2625

26+
MINIMUM_SUPPORTED_VERSION = "2.5.0"
27+
SECURE_TORCH_VERSION = "2.6.0"
28+
29+
if Version(torch.__version__) < Version(MINIMUM_SUPPORTED_VERSION):
30+
warnings.warn(
31+
f"TICO officially supports torch>={MINIMUM_SUPPORTED_VERSION}. "
32+
f"You are using a lower version of torch ({torch.__version__}). "
33+
f"We highly recommend to upgrade torch>={MINIMUM_SUPPORTED_VERSION} to avoid unexpected behaviors."
34+
)
2735

28-
if Version(torch.__version__) < Version("2.5.0"):
36+
if Version(torch.__version__) < Version(SECURE_TORCH_VERSION):
2937
warnings.warn(
30-
f"TICO officially supports torch>=2.5. You are using a lower version of torch ({torch.__version__}). We highly recommend to upgrade torch >= 2.5 to avoid unexpected behaviors."
38+
f"Detected PyTorch version {torch.__version__}, which may include known security vulnerabilities. "
39+
f"We recommend upgrading to {SECURE_TORCH_VERSION} or later for better security.\n"
40+
"Upgrade command: pip install --upgrade torch\n"
41+
"For more details, see: https://pytorch.org/security"
3142
)

0 commit comments

Comments
 (0)