Skip to content

Commit 9a742db

Browse files
committed
[GR-65186] Add patch for torch 2.7.0 etc.
PullRequest: graalpython/3804
2 parents e5cb4c9 + 2fb8b93 commit 9a742db

File tree

7 files changed

+873
-17
lines changed

7 files changed

+873
-17
lines changed

graalpython/lib-graalpython/patches/metadata.toml

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,14 @@ version = '>= 1.64.0'
152152
patch = 'grpcio-1.66.1.patch'
153153
license = 'Apache-2.0'
154154

155+
[[grpcio.rules]]
156+
# Force re-cythonize + other fixes
157+
# The rc version won't get matched by the version range above
158+
version = '== 1.72.0rc1'
159+
install-priority = 0
160+
patch = 'grpcio-1.66.1.patch'
161+
license = 'Apache-2.0'
162+
155163
[[h2o.rules]]
156164
patch = 'h2o.patch'
157165
license = 'Apache-2.0'
@@ -425,10 +433,19 @@ patch = 'prompt_toolkit.patch'
425433
license = 'BSD-3-Clause'
426434

427435
[[protobuf.rules]]
436+
patch = 'protobuf.patch'
437+
license = 'BSD-3-Clause'
438+
# There are 'none-any' wheels on pypi, this is only needed on sdists
439+
dist-type = 'sdist'
440+
install-priority = 0
441+
442+
[[protobuf.rules]]
443+
# msimacek: This version doesn't exist, but the patch file is referenced from the tensorflow patch which I'm afraid to touch
428444
version = '== 3.21.9'
429-
# Also referenced outside of pip from tensorflow patches
430445
patch = 'protobuf-3.21.9.patch'
431446
license = 'BSD-3-Clause'
447+
dist-type = 'sdist'
448+
install-priority = 0
432449

433450
[[psycopg2.rules]]
434451
version = '<= 2.9.9'
@@ -763,6 +780,12 @@ patch = 'torch-2.4.1.patch'
763780
license = 'BSD-3-Clause'
764781
dist-type = 'sdist'
765782

783+
[[torch.rules]]
784+
version = '== 2.7.0'
785+
patch = 'torch-2.7.0.patch'
786+
license = 'BSD-3-Clause'
787+
dist-type = 'sdist'
788+
766789
[[torch.add-sources]]
767790
version = '1.13.1'
768791
url = 'https://github.com/pytorch/pytorch/releases/download/v1.13.1/pytorch-v1.13.1.tar.gz'
@@ -775,9 +798,22 @@ url = 'https://github.com/pytorch/pytorch/releases/download/v2.2.1/pytorch-v2.2.
775798
version = '2.4.1'
776799
url = 'https://github.com/pytorch/pytorch/releases/download/v2.4.1/pytorch-v2.4.1.tar.gz'
777800

801+
[[torch.add-sources]]
802+
version = '2.7.0'
803+
url = 'https://github.com/pytorch/pytorch/releases/download/v2.7.0/pytorch-v2.7.0.tar.gz'
804+
805+
[[torchvision.rules]]
806+
version = '== 0.22.0'
807+
patch = 'torchvision-0.22.0.patch'
808+
license = 'BSD-3-Clause'
809+
810+
[[torchvision.add-sources]]
811+
version = '0.19.1'
812+
url = 'https://github.com/pytorch/vision/archive/refs/tags/v0.22.0.tar.gz'
813+
778814
[[torchvision.rules]]
779815
version = '== 0.19.1'
780-
patch = 'torchvision-1.19.1.patch'
816+
patch = 'torchvision-0.19.1.patch'
781817
license = 'BSD-3-Clause'
782818

783819
[[torchvision.add-sources]]
@@ -786,7 +822,7 @@ url = 'https://github.com/pytorch/vision/archive/refs/tags/v0.19.1.tar.gz'
786822

787823
[[torchvision.rules]]
788824
version = '== 0.17.1'
789-
patch = 'torchvision-1.17.1.patch'
825+
patch = 'torchvision-0.17.1.patch'
790826
license = 'BSD-3-Clause'
791827

792828
[[torchvision.add-sources]]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/google/protobuf/internal/api_implementation.py b/google/protobuf/internal/api_implementation.py
2+
index b40446b..48e684f 100644
3+
--- a/google/protobuf/internal/api_implementation.py
4+
+++ b/google/protobuf/internal/api_implementation.py
5+
@@ -70,8 +70,8 @@ if _implementation_type not in ('python', 'cpp', 'upb'):
6+
'supported. Please set to \'python\', \'cpp\' or '
7+
'\'upb\'.'.format(_implementation_type))
8+
9+
-if 'PyPy' in sys.version and _implementation_type == 'cpp':
10+
- warnings.warn('PyPy does not work yet with cpp protocol buffers. '
11+
+if sys.implementation.name in ('pypy', 'graalpy') and _implementation_type == 'cpp':
12+
+ warnings.warn('PyPy and GraalPy do not work yet with cpp protocol buffers. '
13+
'Falling back to the python implementation.')
14+
_implementation_type = 'python'
15+

graalpython/lib-graalpython/patches/torch-2.4.1.patch

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,19 @@ index f5fdbf155..d76176cb6 100644
178178

179179

180180
class TestWrapperSubclassAliasing(TestCase):
181+
diff --git a/third_party/fbgemm/CMakeLists.txt b/third_party/fbgemm/CMakeLists.txt
182+
index 134523e7d..a00538e3c 100644
183+
--- a/third_party/fbgemm/CMakeLists.txt
184+
+++ b/third_party/fbgemm/CMakeLists.txt
185+
@@ -10,6 +10,8 @@
186+
187+
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
188+
189+
+add_compile_options(-Wno-error=maybe-uninitialized -Wno-error=uninitialized -Wno-error=restrict)
190+
+
191+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
192+
193+
# Define function to extract filelists from defs.bzl file
181194
diff --git a/third_party/pybind11/include/pybind11/detail/common.h b/third_party/pybind11/include/pybind11/detail/common.h
182195
index 454e6061b..7feafc7d7 100644
183196
--- a/third_party/pybind11/include/pybind11/detail/common.h
@@ -537,20 +550,6 @@ index c301da982..a2668be20 100644
537550
+const int THP_PyOpcode_Caches_size = 0;
538551
+
539552
+#endif // GraalPy change
540-
diff --git a/torch/csrc/dynamo/extra_state.c b/torch/csrc/dynamo/extra_state.c
541-
index cbe9ab37a..18740a0d8 100644
542-
--- a/torch/csrc/dynamo/extra_state.c
543-
+++ b/torch/csrc/dynamo/extra_state.c
544-
@@ -100,9 +100,6 @@ void destroy_extra_state(void* obj) {
545-
}
546-
547-
void set_extra_state(PyCodeObject* code, ExtraState* extra_state) {
548-
- ExtraState* old_extra_state = get_extra_state(code);
549-
- CHECK(extra_state == nullptr || old_extra_state != extra_state);
550-
- _PyCode_SetExtra((PyObject*)code, extra_index, extra_state);
551-
}
552-
553-
ExtraState* init_and_set_extra_state(PyCodeObject* code) {
554553
diff --git a/torch/csrc/dynamo/eval_frame.c b/torch/csrc/dynamo/eval_frame.c
555554
index cbe9ab37a..18740a0d8 100644
556555
--- a/torch/csrc/dynamo/eval_frame.c
@@ -628,6 +627,24 @@ index cbe9ab37a..18740a0d8 100644
628627

629628
return module;
630629
}
630+
diff --git a/torch/csrc/dynamo/extra_state.cpp b/torch/csrc/dynamo/extra_state.cpp
631+
index 7c9b4be00..b8edbcfda 100644
632+
--- a/torch/csrc/dynamo/extra_state.cpp
633+
+++ b/torch/csrc/dynamo/extra_state.cpp
634+
@@ -65,11 +65,13 @@ void destroy_extra_state(void* obj) {
635+
}
636+
637+
void set_extra_state(PyCodeObject* code, ExtraState* extra_state) {
638+
+#if 0 // GraalPy change
639+
ExtraState* old_extra_state = get_extra_state(code);
640+
CHECK(
641+
old_extra_state == nullptr || old_extra_state == SKIP_CODE ||
642+
old_extra_state != extra_state);
643+
_PyCode_SetExtra((PyObject*)code, extra_index, extra_state);
644+
+#endif // GraalPy change
645+
}
646+
647+
ExtraState* init_and_set_extra_state(PyCodeObject* code) {
631648
diff --git a/torch/csrc/jit/python/python_tracer.cpp b/torch/csrc/jit/python/python_tracer.cpp
632649
index 92e6e2d3a..4d2ec0bfe 100644
633650
--- a/torch/csrc/jit/python/python_tracer.cpp

0 commit comments

Comments
 (0)