Commit 4cea0a1
authored
Standardize internal version checks in cuda.core (#1825)
* Cythonize _graph/_graph_builder (move from pure Python to .pyx)
Move the GraphBuilder/Graph/GraphCompleteOptions/GraphDebugPrintOptions
implementation out of _graph/__init__.py into _graph/_graph_builder.pyx
so it is compiled by Cython. A thin __init__.py re-exports the public
names so all existing import sites continue to work unchanged.
Cython compatibility adjustments:
- Remove `from __future__ import annotations` (unsupported by Cython)
- Remove TYPE_CHECKING guard; quote annotations that reference Stream
(circular import), forward-reference GraphBuilder/Graph, or use
X | None union syntax
- Update _graphdef.pyx lazy imports to point directly at _graph_builder
No build_hooks.py changes needed — the build system auto-discovers .pyx
files via glob.
Ref: #1076
Made-with: Cursor
* Remove _lazy_init from _graph_builder; add cached get_driver_version
Replace the per-module _lazy_init / _inited / _driver_ver / _py_major_minor
pattern in _graph_builder.pyx with direct calls to centralized cached
functions in cuda_utils:
- Add get_driver_version() with @functools.cache alongside get_binding_version
- Switch get_binding_version from @functools.lru_cache to @functools.cache
(cleaner for nullary functions)
- Fix split() to return tuple(result) — Cython enforces return type
annotations unlike pure Python
- Fix _cond_with_params annotation from -> GraphBuilder to -> tuple
to match actual return value
Made-with: Cursor
* Add CPU callbacks for stream capture (GraphBuilder.callback)
Implements #1328: host callbacks during stream capture via
cuLaunchHostFunc, mirroring the existing GraphDef.callback API.
Extracts shared callback infrastructure (_attach_user_object,
_attach_host_callback_to_graph, trampoline/destructor) into a new
_graph/_utils.pyx module to avoid circular imports between
_graph_builder and _graphdef.
Made-with: Cursor
* Standardize internal version checks in cuda.core
Move binding and driver version queries into a dedicated
cuda/core/_utils/version.{pyx,pxd} module, providing both Python
(binding_version, driver_version) and Cython (cy_binding_version,
cy_driver_version) entry points. All functions return version tuples
((major, minor, patch)) and are cached—Python via @functools.cache,
Cython via module-level globals.
Remove get_binding_version / get_driver_version from cuda_utils.pyx
and update all internal call sites and tests to import from the new
module. Remove version checks for CUDA < 12.0 (now the minimum) and
eliminate dead code exposed by the migration: _lazy_init / _use_ex /
_kernel_ctypes / _is_cukernel_get_library_supported machinery in
_module.pyx, _launcher.pyx, and _launch_config.pyx.
The public NVML-based system.get_driver_version API is unrelated and
left unchanged.
Made-with: Cursor
* Fix unused imports after merge with main
Remove unused imports flagged by cython-lint and ruff after
resolving merge conflicts with origin/main.
Made-with: Cursor
* Replace _reduce_3_tuple with math.prod in _launcher.pyx
Remove the now-dead _reduce_3_tuple helper from cuda_utils.pyx.
Made-with: Cursor
* Remove _driver_ver from _linker.pyx; use _use_nvjitlink_backend as guard
Initialize _use_nvjitlink_backend to None so it can serve as its own
"already decided" sentinel, eliminating the redundant _driver_ver variable
and the driver_version() call that was only used to set it.
Made-with: Cursor
* Add return type annotations to version.pyx; fix minor arithmetic
Add -> tuple[int, int, int] annotations to binding_version and
driver_version. Align driver_version arithmetic with _system.pyx.
Made-with: Cursor1 parent ad7c96b commit 4cea0a1
File tree
17 files changed
+128
-328
lines changed- cuda_core
- cuda/core
- _graph
- _memory
- _utils
- tests
- graph
17 files changed
+128
-328
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | | - | |
17 | | - | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
| 172 | + | |
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| |||
449 | 449 | | |
450 | 450 | | |
451 | 451 | | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
| |||
522 | 522 | | |
523 | 523 | | |
524 | 524 | | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
529 | 529 | | |
530 | 530 | | |
531 | 531 | | |
| |||
553 | 553 | | |
554 | 554 | | |
555 | 555 | | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
560 | 560 | | |
561 | 561 | | |
562 | 562 | | |
| |||
587 | 587 | | |
588 | 588 | | |
589 | 589 | | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | | - | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
594 | 594 | | |
595 | 595 | | |
596 | 596 | | |
| |||
618 | 618 | | |
619 | 619 | | |
620 | 620 | | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
625 | 625 | | |
626 | 626 | | |
627 | 627 | | |
| |||
649 | 649 | | |
650 | 650 | | |
651 | 651 | | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | 652 | | |
659 | 653 | | |
660 | 654 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
98 | | - | |
| 97 | + | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | 7 | | |
14 | 8 | | |
15 | 9 | | |
16 | 10 | | |
17 | 11 | | |
18 | | - | |
19 | 12 | | |
20 | 13 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | 14 | | |
28 | 15 | | |
29 | 16 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | 17 | | |
51 | 18 | | |
52 | 19 | | |
| |||
99 | 66 | | |
100 | 67 | | |
101 | 68 | | |
102 | | - | |
103 | | - | |
104 | 69 | | |
105 | 70 | | |
106 | 71 | | |
| |||
110 | 75 | | |
111 | 76 | | |
112 | 77 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | 78 | | |
118 | 79 | | |
119 | 80 | | |
| |||
153 | 114 | | |
154 | 115 | | |
155 | 116 | | |
156 | | - | |
157 | 117 | | |
158 | 118 | | |
159 | 119 | | |
| |||
201 | 161 | | |
202 | 162 | | |
203 | 163 | | |
204 | | - | |
205 | | - | |
206 | 164 | | |
207 | 165 | | |
208 | 166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | 18 | | |
22 | 19 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
| 20 | + | |
51 | 21 | | |
52 | 22 | | |
53 | 23 | | |
| |||
70 | 40 | | |
71 | 41 | | |
72 | 42 | | |
73 | | - | |
74 | 43 | | |
75 | 44 | | |
76 | 45 | | |
77 | 46 | | |
78 | 47 | | |
79 | 48 | | |
80 | 49 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | 50 | | |
85 | 51 | | |
86 | 52 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
107 | 59 | | |
108 | 60 | | |
109 | 61 | | |
110 | 62 | | |
111 | 63 | | |
112 | 64 | | |
113 | | - | |
| 65 | + | |
114 | 66 | | |
115 | | - | |
| 67 | + | |
116 | 68 | | |
117 | 69 | | |
118 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | 40 | | |
42 | 41 | | |
43 | 42 | | |
| |||
620 | 619 | | |
621 | 620 | | |
622 | 621 | | |
623 | | - | |
624 | 622 | | |
625 | | - | |
| 623 | + | |
626 | 624 | | |
627 | 625 | | |
628 | 626 | | |
| |||
637 | 635 | | |
638 | 636 | | |
639 | 637 | | |
640 | | - | |
641 | | - | |
| 638 | + | |
| 639 | + | |
642 | 640 | | |
643 | 641 | | |
644 | | - | |
645 | | - | |
646 | | - | |
647 | 642 | | |
648 | 643 | | |
649 | 644 | | |
| |||
668 | 663 | | |
669 | 664 | | |
670 | 665 | | |
| 666 | + | |
671 | 667 | | |
672 | 668 | | |
673 | 669 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
103 | | - | |
| 102 | + | |
104 | 103 | | |
105 | 104 | | |
106 | 105 | | |
| |||
0 commit comments