Repository navigation
Commit 2224499
test(cuda.bindings): reuse worker-thread contexts under pytest-run-parallel (#3122)
* test(cuda.bindings): reuse worker-thread contexts under pytest-run-parallel
The pytest-run-parallel plugin in the bindings conftest made each worker
thread create and destroy a CUDA context around every test. The driver
serializes context creation, so with four threads every test paid about
0.75 s. On free-threaded rows that run the bindings tests, the step took
36 to 39 minutes and the jobs hit the 60-minute limit.
Keep one context per running thread, but reuse it. A pool hands each
worker an idle context or creates one; the worker pushes it, runs the
test, synchronizes, and pops it, so the previous current context is
restored. A context that reports an error at the sync is destroyed, not
reused. The plugin destroys the pooled contexts at each module boundary,
so a context lives no longer than the module-scoped ctx fixture does in
a run without threads.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* test(cuda.bindings): capture thread-locally in tests run on parallel threads
With pooled contexts the worker threads of a test start together; before,
serialized context creation kept them apart. Three tests begin a stream
capture in global mode, and in that mode a call such as cuGraphInstantiate
in one thread fails while another thread is capturing. The host-function
graph tests failed this way on the free-threaded rows. Capture in
thread-local mode instead; what the tests check does not depend on it.
Drop the synchronize at the end of each pooled test for the same reason:
it could break a global capture running in another thread. Pooled contexts
now behave like the module-scoped ctx fixture, which does not synchronize
between tests either.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---------
Co-authored-by: Claude Opus 5.5 <[email protected]>1 parent 4ac0f82 commit 2224499
3 files changed
Lines changed: 84 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
52 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
53 | 105 | | |
54 | 106 | | |
55 | 107 | | |
| |||
63 | 115 | | |
64 | 116 | | |
65 | 117 | | |
66 | | - | |
| 118 | + | |
67 | 119 | | |
68 | 120 | | |
69 | 121 | | |
| |||
103 | 155 | | |
104 | 156 | | |
105 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
106 | 165 | | |
107 | 166 | | |
108 | 167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
706 | 706 | | |
707 | 707 | | |
708 | 708 | | |
709 | | - | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
710 | 713 | | |
711 | 714 | | |
712 | 715 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
616 | 616 | | |
617 | 617 | | |
618 | 618 | | |
619 | | - | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
620 | 623 | | |
621 | 624 | | |
622 | 625 | | |
| |||
1469 | 1472 | | |
1470 | 1473 | | |
1471 | 1474 | | |
1472 | | - | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
1473 | 1479 | | |
1474 | 1480 | | |
1475 | 1481 | | |
| |||
0 commit comments