Skip to content

torch._dynamo.exc.InternalTorchDynamoError: TypeError: cannot create weak reference to 'torch.Event' object - #13

Draft
Stonepia wants to merge 1 commit into
mainfrom
agent/issue-1969
Draft

torch._dynamo.exc.InternalTorchDynamoError: TypeError: cannot create weak reference to 'torch.Event' object#13
Stonepia wants to merge 1 commit into
mainfrom
agent/issue-1969

Conversation

@Stonepia

Copy link
Copy Markdown
Collaborator

torch._dynamo.exc.InternalTorchDynamoError: TypeError: cannot create weak reference to 'torch.Event' object

Fixes intel/torch-xpu-ops#1969

Root Cause: torch.Event for XPU (THXPEvent) does not support weak references. The XPU PyTypeObject THXPEventType has tp_weaklistoffset set to 0, meaning Python's weakref module cannot create weak references to XPU Event objects. When Dynamo's register_user_object() tries to weakref-track a torch.Event (XPU) during tracing, it gets a TypeError which is surfaced as an InternalTorchDynamoError.

Failed Tests:

  • test/dynamo/test_ctx_manager.py::CtxManagerTests::test_gpu_event_across_graph_break

Diff stat:

torch/csrc/xpu/Event.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

torch._dynamo.exc.InternalTorchDynamoError: TypeError: cannot create weak reference to 'torch.Event' object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

torch._dynamo.exc.InternalTorchDynamoError: TypeError: cannot create weak reference to 'torch.Event' object

1 participant