@@ -645,6 +645,46 @@ index 7c9b4be00..b8edbcfda 100644
645645 }
646646
647647 ExtraState* init_and_set_extra_state(PyCodeObject* code) {
648+ diff --git a/torch/csrc/dynamo/guards.cpp b/torch/csrc/dynamo/guards.cpp
649+ index b7fde50a9..712e3613b 100644
650+ --- a/torch/csrc/dynamo/guards.cpp
651+ +++ b/torch/csrc/dynamo/guards.cpp
652+ @@ -26,7 +26,7 @@
653+ // https://github.com/python/cpython/blob/9afc6d102d16080535325f645849cd84eb04d57d/Objects/tupleobject.c#L1058-L1062
654+ // To handle this, we manually copy the struct here and manually cast it to this
655+ // new struct. From 3.12, the struct is included in the header file.
656+ - #if IS_PYTHON_3_12_PLUS
657+ + #if 0 // GraalPy change
658+
659+ #define Py_BUILD_CORE
660+ // Bring _PyTupleIterObject from the header file
661+ @@ -596,7 +596,7 @@ static PyObject* check_obj_id(PyObject* dummy, PyObject* args) {
662+ }
663+ }
664+
665+ - #if IS_PYTHON_3_12_PLUS
666+ + #if 0 // GraalPy change
667+
668+ static std::unordered_map<PyObject*, uint64_t> dict_version_map;
669+ static int dict_version_watcher_id;
670+ @@ -617,7 +617,7 @@ static int dict_version_watch_callback(
671+ #endif
672+
673+ static uint64_t get_dict_version_unchecked(PyObject* dict) {
674+ - #if IS_PYTHON_3_12_PLUS
675+ + #if 0 // GraalPy change
676+
677+ if (PyDict_Watch(dict_version_watcher_id, dict)) {
678+ throw std::runtime_error("failed to add version watcher to dict!");
679+ @@ -4013,7 +4013,7 @@ PyObject* torch_c_dynamo_guards_init() {
680+ "install_no_tensor_aliasing_guard", install_no_tensor_aliasing_guard);
681+
682+ // initialize dict_version_map watcher for 3.12
683+ - #if IS_PYTHON_3_12_PLUS
684+ + #if 0 // GraalPy change
685+
686+ dict_version_watcher_id = PyDict_AddWatcher(dict_version_watch_callback);
687+ if (dict_version_watcher_id == -1) {
648688diff --git a/torch/csrc/jit/python/python_tracer.cpp b/torch/csrc/jit/python/python_tracer.cpp
649689index 92e6e2d3a..4d2ec0bfe 100644
650690--- a/torch/csrc/jit/python/python_tracer.cpp
0 commit comments