[dynamo, 3.13t] raise error if torch.compile is attempted in 3.13t (nogil) (#143404)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/143404
Approved by: https://github.com/colesbury, https://github.com/atalman
This commit is contained in:
William Wen
2024-12-18 23:30:05 +00:00
committed by PyTorch MergeBot
parent 33c27be017
commit e1e83015d2
2 changed files with 4 additions and 0 deletions

View File

@ -2494,6 +2494,8 @@ def compile(
_C._log_api_usage_once("torch.compile")
if sys.version_info >= (3, 14):
raise RuntimeError("Dynamo is not supported on Python 3.14+")
elif sys.version_info >= (3, 13) and not sys._is_gil_enabled():
raise RuntimeError("Dynamo is not supported on Python with GIL disabled")
# Decorator mode
if model is None:

View File

@ -809,6 +809,8 @@ class _NullDecorator(contextlib.nullcontext): # type: ignore[type-arg]
def check_if_dynamo_supported():
if sys.version_info >= (3, 14):
raise RuntimeError("Python 3.14+ not yet supported for torch.compile")
elif sys.version_info >= (3, 13) and not sys._is_gil_enabled():
raise RuntimeError("Dynamo is not supported on Python with GIL disabled")
def is_dynamo_supported():