Skip to content

Commit aff41e9

Browse files
Support python 3.14 (#599)
This PR vendors the relevant changes from upstream numba required to support python 3.14. Closes #595 --------- Co-authored-by: Phillip Cloud <417981+cpcloud@users.noreply.github.com>
1 parent 368a87c commit aff41e9

21 files changed

Lines changed: 4226 additions & 439 deletions

.github/workflows/build-wheel.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- "3.11"
3333
- "3.12"
3434
- "3.13"
35-
# - "3.14"
35+
- "3.14"
3636
# - "3.14t"
3737
name: py${{ matrix.python-version }}
3838
runs-on: ${{ (inputs.host-platform == 'linux-64' && 'linux-amd64-cpu8') ||

ci/test-matrix.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,18 @@
1212
{ "ARCH": "amd64", "PY_VER": "3.12", "CUDA_VER": "13.0.2", "LOCAL_CTK": "0", "GPU": "l4", "DRIVER": "latest" },
1313
{ "ARCH": "amd64", "PY_VER": "3.13", "CUDA_VER": "12.9.1", "LOCAL_CTK": "0", "GPU": "v100", "DRIVER": "latest" },
1414
{ "ARCH": "amd64", "PY_VER": "3.13", "CUDA_VER": "13.0.2", "LOCAL_CTK": "1", "GPU": "rtxpro6000", "DRIVER": "latest" },
15+
{ "ARCH": "amd64", "PY_VER": "3.14", "CUDA_VER": "12.9.1", "LOCAL_CTK": "0", "GPU": "v100", "DRIVER": "latest" },
16+
{ "ARCH": "amd64", "PY_VER": "3.14", "CUDA_VER": "13.0.2", "LOCAL_CTK": "1", "GPU": "rtxpro6000", "DRIVER": "latest" },
1517
{ "ARCH": "arm64", "PY_VER": "3.10", "CUDA_VER": "12.9.1", "LOCAL_CTK": "1", "GPU": "a100", "DRIVER": "latest" },
1618
{ "ARCH": "arm64", "PY_VER": "3.10", "CUDA_VER": "13.0.2", "LOCAL_CTK": "0", "GPU": "a100", "DRIVER": "latest" },
1719
{ "ARCH": "arm64", "PY_VER": "3.11", "CUDA_VER": "12.9.1", "LOCAL_CTK": "0", "GPU": "a100", "DRIVER": "latest" },
1820
{ "ARCH": "arm64", "PY_VER": "3.11", "CUDA_VER": "13.0.2", "LOCAL_CTK": "1", "GPU": "a100", "DRIVER": "latest" },
1921
{ "ARCH": "arm64", "PY_VER": "3.12", "CUDA_VER": "12.9.1", "LOCAL_CTK": "1", "GPU": "a100", "DRIVER": "latest" },
2022
{ "ARCH": "arm64", "PY_VER": "3.12", "CUDA_VER": "13.0.2", "LOCAL_CTK": "0", "GPU": "a100", "DRIVER": "latest" },
2123
{ "ARCH": "arm64", "PY_VER": "3.13", "CUDA_VER": "12.9.1", "LOCAL_CTK": "0", "GPU": "a100", "DRIVER": "latest" },
22-
{ "ARCH": "arm64", "PY_VER": "3.13", "CUDA_VER": "13.0.2", "LOCAL_CTK": "1", "GPU": "a100", "DRIVER": "latest" }
24+
{ "ARCH": "arm64", "PY_VER": "3.13", "CUDA_VER": "13.0.2", "LOCAL_CTK": "1", "GPU": "a100", "DRIVER": "latest" },
25+
{ "ARCH": "arm64", "PY_VER": "3.14", "CUDA_VER": "12.9.1", "LOCAL_CTK": "0", "GPU": "a100", "DRIVER": "latest" },
26+
{ "ARCH": "arm64", "PY_VER": "3.14", "CUDA_VER": "13.0.2", "LOCAL_CTK": "1", "GPU": "a100", "DRIVER": "latest" }
2327
],
2428
"nightly": [],
2529
"special_runners": {
@@ -37,7 +41,9 @@
3741
{ "ARCH": "amd64", "PY_VER": "3.12", "CUDA_VER": "12.9.1", "LOCAL_CTK": "0", "GPU": "l4", "DRIVER": "latest", "DRIVER_MODE": "MCDM" },
3842
{ "ARCH": "amd64", "PY_VER": "3.12", "CUDA_VER": "13.0.2", "LOCAL_CTK": "1", "GPU": "a100", "DRIVER": "latest", "DRIVER_MODE": "TCC" },
3943
{ "ARCH": "amd64", "PY_VER": "3.13", "CUDA_VER": "12.9.1", "LOCAL_CTK": "1", "GPU": "l4", "DRIVER": "latest", "DRIVER_MODE": "TCC" },
40-
{ "ARCH": "amd64", "PY_VER": "3.13", "CUDA_VER": "13.0.2", "LOCAL_CTK": "0", "GPU": "rtxpro6000", "DRIVER": "latest", "DRIVER_MODE": "MCDM" }
44+
{ "ARCH": "amd64", "PY_VER": "3.13", "CUDA_VER": "13.0.2", "LOCAL_CTK": "0", "GPU": "rtxpro6000", "DRIVER": "latest", "DRIVER_MODE": "MCDM" },
45+
{ "ARCH": "amd64", "PY_VER": "3.14", "CUDA_VER": "12.9.1", "LOCAL_CTK": "1", "GPU": "l4", "DRIVER": "latest", "DRIVER_MODE": "TCC" },
46+
{ "ARCH": "amd64", "PY_VER": "3.14", "CUDA_VER": "13.0.2", "LOCAL_CTK": "0", "GPU": "rtxpro6000", "DRIVER": "latest", "DRIVER_MODE": "MCDM" }
4147
],
4248
"nightly": []
4349
}

numba_cuda/numba/cuda/cext/_dispatcher.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*
3030
*/
3131

32-
#if (PY_MAJOR_VERSION >= 3) && ((PY_MINOR_VERSION == 12) || (PY_MINOR_VERSION == 13))
32+
#if (PY_MAJOR_VERSION >= 3) && ((PY_MINOR_VERSION == 12) || (PY_MINOR_VERSION == 13) || (PY_MINOR_VERSION == 14))
3333

3434
#ifndef Py_BUILD_CORE
3535
#define Py_BUILD_CORE 1
@@ -1004,12 +1004,18 @@ static PyTypeObject DispatcherType = {
10041004
0, /* tp_version_tag */
10051005
0, /* tp_finalize */
10061006
0, /* tp_vectorcall */
1007-
#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION == 12)
1007+
#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION >= 12)
10081008
/* This was introduced first in 3.12
10091009
* https://github.com/python/cpython/issues/91051
10101010
*/
10111011
0, /* tp_watched */
10121012
#endif
1013+
#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION >= 13)
1014+
/* This was introduced in 3.13
1015+
* https://github.com/python/cpython/pull/114900
1016+
*/
1017+
0, /* tp_versions_used */
1018+
#endif
10131019

10141020
/* WARNING: Do not remove this, only modify it! It is a version guard to
10151021
* act as a reminder to update this struct on Python version update! */

numba_cuda/numba/cuda/cext/_hashtable.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,12 @@ _Numba_hashtable_hash_int(const void *key)
110110
extern "C" Py_uhash_t
111111
_Numba_hashtable_hash_ptr(const void *key)
112112
{
113+
/* Use public API on Python 3.13+; _Py_HashPointer is deprecated on 3.14+ */
114+
#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION >= 13)
115+
return (Py_uhash_t)Py_HashPointer((void *)key);
116+
#else
113117
return (Py_uhash_t)_Py_HashPointer((void *)key);
118+
#endif
114119
}
115120

116121
extern "C" int

numba_cuda/numba/cuda/cext/_pymodule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
Py_DECREF(tmp); } while (0)
3434

3535

36-
#define NB_SUPPORTED_PYTHON_MINOR ((PY_MINOR_VERSION == 10) || (PY_MINOR_VERSION == 11) || (PY_MINOR_VERSION == 12) || (PY_MINOR_VERSION == 13))
36+
#define NB_SUPPORTED_PYTHON_MINOR ((PY_MINOR_VERSION == 10) || (PY_MINOR_VERSION == 11) || (PY_MINOR_VERSION == 12) || (PY_MINOR_VERSION == 13) || (PY_MINOR_VERSION == 14))
3737

3838
#endif /* NUMBA_PY_MODULE_H_ */

numba_cuda/numba/cuda/cext/_typeof.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <numpy/npy_2_compat.h>
1818
#endif
1919

20-
#if (PY_MAJOR_VERSION >= 3) && (PY_MINOR_VERSION == 13)
20+
#if (PY_MAJOR_VERSION >= 3) && ((PY_MINOR_VERSION == 13) || (PY_MINOR_VERSION == 14))
2121
#ifndef Py_BUILD_CORE
2222
#define Py_BUILD_CORE 1
2323
#endif

numba_cuda/numba/cuda/cext/mviewbuf.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,18 @@ static PyTypeObject MemAllocType = {
337337
0, /* tp_version_tag */
338338
0, /* tp_finalize */
339339
0, /* tp_vectorcall */
340-
#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION == 12)
340+
#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION >= 12)
341341
/* This was introduced first in 3.12
342342
* https://github.com/python/cpython/issues/91051
343343
*/
344344
0, /* tp_watched */
345345
#endif
346+
#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION >= 13)
347+
/* This was introduced in 3.13
348+
* https://github.com/python/cpython/pull/114900
349+
*/
350+
0, /* tp_versions_used */
351+
#endif
346352

347353
/* WARNING: Do not remove this, only modify it! It is a version guard to
348354
* act as a reminder to update this struct on Python version update! */

numba_cuda/numba/cuda/core/bytecode.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from numba.cuda.utils import PYVERSION
1515

1616

17-
if PYVERSION in ((3, 12), (3, 13)):
17+
if PYVERSION in ((3, 12), (3, 13), (3, 14)):
1818
from opcode import _inline_cache_entries
1919

2020
# Instruction/opcode length in bytes
@@ -112,7 +112,7 @@ def get_jump_target(self):
112112
# https://bugs.python.org/issue27129
113113
# https://github.com/python/cpython/pull/25069
114114
assert self.is_jump
115-
if PYVERSION in ((3, 13),):
115+
if PYVERSION in ((3, 13), (3, 14)):
116116
if self.opcode in (
117117
dis.opmap[k]
118118
for k in ["JUMP_BACKWARD", "JUMP_BACKWARD_NO_INTERRUPT"]
@@ -141,7 +141,7 @@ def get_jump_target(self):
141141
else:
142142
raise NotImplementedError(PYVERSION)
143143

144-
if PYVERSION in ((3, 10), (3, 11), (3, 12), (3, 13)):
144+
if PYVERSION in ((3, 10), (3, 11), (3, 12), (3, 13), (3, 14)):
145145
if self.opcode in JREL_OPS:
146146
return self.next + self.arg * 2
147147
else:
@@ -179,7 +179,7 @@ def block_effect(self):
179179
OPCODE_NOP = dis.opname.index("NOP")
180180

181181

182-
if PYVERSION in ((3, 13),):
182+
if PYVERSION in ((3, 13), (3, 14)):
183183

184184
def _unpack_opargs(code):
185185
buf = []
@@ -418,7 +418,7 @@ def get_used_globals(self):
418418

419419

420420
def _fix_LOAD_GLOBAL_arg(arg):
421-
if PYVERSION in ((3, 11), (3, 12), (3, 13)):
421+
if PYVERSION in ((3, 11), (3, 12), (3, 13), (3, 14)):
422422
return arg >> 1
423423
elif PYVERSION in (
424424
(3, 9),
@@ -592,7 +592,7 @@ def pop_and_merge_exceptions(
592592
if not next_inst.opname == "FOR_ITER":
593593
continue
594594

595-
if PYVERSION in ((3, 13),):
595+
if PYVERSION in ((3, 13), (3, 14)):
596596
# Check end of pattern, two instructions.
597597
# Check for the corresponding END_FOR, exception table end
598598
# is non-inclusive, so subtract one.
@@ -601,8 +601,14 @@ def pop_and_merge_exceptions(
601601
if not curr_inst.opname == "END_FOR":
602602
continue
603603
next_inst = self.table[self.ordered_offsets[index - 1]]
604-
if not next_inst.opname == "POP_TOP":
605-
continue
604+
if PYVERSION in ((3, 13),):
605+
if not next_inst.opname == "POP_TOP":
606+
continue
607+
elif PYVERSION in ((3, 14),):
608+
if not next_inst.opname == "POP_ITER":
609+
continue
610+
else:
611+
raise NotImplementedError(PYVERSION)
606612
# END_FOR must be followed by SWAP(2)
607613
next_inst = self.table[self.ordered_offsets[index]]
608614
if not next_inst.opname == "SWAP" and next_inst.arg == 2:
@@ -646,6 +652,7 @@ def pop_and_merge_exceptions(
646652
elif PYVERSION in (
647653
(3, 12),
648654
(3, 13),
655+
(3, 14),
649656
):
650657
ByteCode = ByteCodePy312
651658
elif PYVERSION < (3, 11):

0 commit comments

Comments
 (0)