Skip to content

Commit 5fd1d41

Browse files
Revert "[user-streams] Make device-agnostic streams weakref compatible (pytorch#164304)"
This reverts commit bfc2050. Reverted pytorch#164304 on behalf of https://github.com/atalman due to Breaks periodic: test/dynamo/test_streams.py::TestStreams::test_stream_weakref [GH job link](https://github.com/pytorch/pytorch/actions/runs/18909552619/job/53979171605) [HUD commit link](https://hud.pytorch.org/pytorch/pytorch/commit/cde81e92b95eee9af2879c9c75f7b03699ca72ad) ([comment](pytorch#164304 (comment)))
1 parent c594950 commit 5fd1d41

File tree

3 files changed

+1
-10
lines changed

3 files changed

+1
-10
lines changed

test/dynamo/test_streams.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Owner(s): ["module: dynamo"]
2-
import weakref
32

43
import torch
54
import torch._dynamo.test_case
@@ -16,10 +15,6 @@ def setUpClass(cls):
1615
def tearDownClass(cls):
1716
super().tearDownClass()
1817

19-
def test_stream_weakref(self):
20-
s = torch.Stream()
21-
weakref.ref(s)
22-
2318
@requires_cuda
2419
def test_run_opcheck(self):
2520
from torch._dynamo.variables.streams import fork_stream, join_stream

torch/csrc/Stream.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ static PyObject* THPStream_pynew(
9595
self->device_index = static_cast<int64_t>(stream_opt->device_index());
9696
self->device_type = static_cast<int64_t>(stream_opt->device_type());
9797
self->context = nullptr;
98-
self->weakreflist = nullptr;
9998

10099
return static_cast<PyObject*>(ptr.release());
101100
END_HANDLE_TH_ERRORS
@@ -115,13 +114,11 @@ PyObject* THPStream_Wrap(const c10::Stream& stream) {
115114
self->device_index = static_cast<int64_t>(stream.device_index());
116115
self->device_type = static_cast<int64_t>(stream.device_type());
117116
self->context = nullptr;
118-
self->weakreflist = nullptr;
119117
return ptr.release();
120118
END_HANDLE_TH_ERRORS
121119
}
122120

123121
static void THPStream_dealloc(THPStream* self) {
124-
PyObject_ClearWeakRefs((PyObject*)self);
125122
Py_TYPE(self)->tp_free(reinterpret_cast<PyObject*>(self));
126123
}
127124

@@ -447,7 +444,7 @@ static PyTypeObject THPStreamType = {
447444
nullptr, /* tp_traverse */
448445
nullptr, /* tp_clear */
449446
THPStream_richcompare, /* tp_richcompare */
450-
offsetof(THPStream, weakreflist), /* tp_weaklistoffset */
447+
0, /* tp_weaklistoffset */
451448
nullptr, /* tp_iter */
452449
nullptr, /* tp_iternext */
453450
// NOLINTNEXTLINE(*const-cast)

torch/csrc/Stream.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ struct THPStream {
1313
int64_t device_index;
1414
// Used to switch stream context management, initialized lazily.
1515
PyObject* context;
16-
PyObject* weakreflist;
1716
};
1817
extern TORCH_API PyTypeObject* THPStreamClass;
1918

0 commit comments

Comments
 (0)