Search code examples
pythonmachine-learningpytorchlarge-language-model

python- pytorch.compile() giving runtime error saying Dynamo is not supported on python 3.12+


I'm trying to run this block of code in my local LLM.

if compile:
    print("compiling the model")
    unoptimized_model = model
    model = torch.compile(model)

And this is the error i get:

Pls help me fix this

Traceback (most recent call last):
File "c:\\Users\\abul4\\OneDrive\\Desktop\\LLM\\train.py", line 180, in \<module\>
model = torch.compile(model)
^^^^^^^^^^^^^^^^^^^^
File "C:\\Users\\abul4\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\torch\__init_\_.py", line 1801, in compile
raise RuntimeError("Dynamo is not supported on Python 3.12+")
RuntimeError: Dynamo is not supported on Python 3.12+

Solution

  • As of version 2.2.0, torch does not yet support compile with Python 3.12.

    Check pytorch/pytorch#120233 issue for more details.