Skip to content

[dynamo] Incompatibility with sys.monitoring #158164

@williamwen42

Description

@williamwen42

The following code results in a graph break:

import sys

import torch


def callback(*args, **kwargs):
    torch._dynamo.graph_break()


sys.monitoring.use_tool_id(0, "test")
sys.monitoring.register_callback(0, sys.monitoring.events.PY_START, callback)
sys.monitoring.set_events(0, sys.monitoring.events.PY_START)


@torch.compile(backend="eager", fullgraph=True)
def fn(x):
    return x + 1


fn(torch.ones(3))

Internal context: fdb is not compatible with torch.compile on Python 3.12+. pdb may be switching to sys.monitoring for Python 3.14, so we need Dynamo to be able to interact with sys.monitoring more gracefully fairly soon.

cc @chauhang @penguinwu @voznesenskym @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @amjames

Metadata

Metadata

Assignees

Labels

module: dynamomodule: python versionIssues related to specific Python versionsoncall: pt2triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions