-
Notifications
You must be signed in to change notification settings - Fork 45
Trace doesn't work with python 3.13 #43
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
Comments
@Ryan-Rong-24 can you paste an example code snippet, so I can reproduce the error? Thanks. Can you also let me know what you get as |
It seems the main cause is that starting from Python 3.13 (see here) f_locals is no longer a dict.
Our previous assumes it to be a dict. (f_locals is used to resolve the nonlocal namespace for bundle). Currently the quickest solution is to use Python <3.13. We will look into that more for a patch. |
This is our code for using Trace to play Pong. Also I'm not sure if I can show what
|
Trace seems to have some error with the bundle decorator when running on python 3.13. Downgrading to 3.12 does not have this error.
Traceback (most recent call last):
File "/Users/ryanrong/Documents/GitHub/cs224n_llm_agent/pong_LLM_agent.py", line 269, in
rewards = optimize_policy(
env_name="ALE/Pong-v5",
...<4 lines>...
model="gpt-4o-mini"
)
File "/Users/ryanrong/Documents/GitHub/cs224n_llm_agent/pong_LLM_agent.py", line 169, in optimize_policy
@trace.bundle(trainable=True)
~~~~^^^^^^^^^^^^^^^^
File "/Users/ryanrong/.pyenv/versions/3.13.1/lib/python3.13/site-packages/opto/trace/bundle.py", line 57, in decorator
fun_module = FunModule(
fun=fun,
...<7 lines>...
_ldict=prev_f_locals, # Get the locals of the calling function
)
File "/Users/ryanrong/.pyenv/versions/3.13.1/lib/python3.13/site-packages/opto/trace/bundle.py", line 114, in init
assert _ldict is None or isinstance(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ldict, dict
^^^^^^^^^^^^
), "_ldict must be a dictionary. or None"
^
AssertionError: _ldict must be a dictionary. or None
The text was updated successfully, but these errors were encountered: