[dynamo] Weblink generation when unimplemented_v2() is called (#156033)

This PR includes the GBID weblink whenever a user encounters a graph break. I also had to include the JSON file in setup.py, so it can be part of the files that are packaged in during CI. It also fixes the issue of the hardcoded error messages stripping away one of the '/' in 'https'.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/156033
Approved by: https://github.com/williamwen42
This commit is contained in:
Sidharth
2025-06-22 00:55:29 -07:00
committed by PyTorch MergeBot
parent c95f7fa874
commit aeaf6b59e2
9 changed files with 101 additions and 9 deletions

View File

@ -1286,6 +1286,7 @@ def main():
"utils/model_dump/skeleton.html",
"utils/model_dump/code.js",
"utils/model_dump/*.mjs",
"_dynamo/graph_break_registry.json",
]
if not BUILD_LIBTORCH_WHL:

View File

@ -551,7 +551,8 @@ Unsupported Tensor.backward() call
Hint: This graph break is fundamental - it is unlikely that Dynamo will ever be able to trace through your code. Consider finding a workaround.
Developer debug context: call_method TensorVariable() backward () {}
""", # noqa: B950
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0123""", # noqa: B950
)
else:
self.assertGreater(len(counters["graph_break"]), 1)

View File

@ -59,6 +59,7 @@ Dynamic shape operator
Developer debug context: aten.nonzero.default
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0036
from user code:
File "test_error_messages.py", line N, in fn
@ -80,6 +81,7 @@ Dynamic shape operator (no meta kernel)
Developer debug context: aten.linalg_lstsq.default
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0037
from user code:
File "test_error_messages.py", line N, in fn
@ -102,6 +104,7 @@ Unsupported Tensor.item() call with capture_scalar_outputs=False
Developer debug context: call_method TensorVariable() item () {}
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0124
from user code:
File "test_error_messages.py", line N, in fn
@ -121,10 +124,11 @@ from user code:
"""\
Data dependent operator
Explanation: Operator `aten.equal.default` has a non-Tensor output whose value is dependent on the data of Tensor inputs.
Hint: Consider wrapping the operator into a PyTorch-understood custom operator (see https:/pytorch.org/tutorials/advanced/custom_ops_landing_page.html)
Hint: Consider wrapping the operator into a PyTorch-understood custom operator (see https://pytorch.org/tutorials/advanced/custom_ops_landing_page.html)
Developer debug context: aten.equal.default
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0033
from user code:
File "test_error_messages.py", line N, in fn
@ -152,6 +156,7 @@ sort with non-constant keys
Developer debug context: TensorVariable()
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0207
from user code:
File "test_error_messages.py", line N, in fn
@ -176,6 +181,7 @@ Unsupported method call
Developer debug context: call_method UserDefinedObjectVariable(zip) __iter__ () {}
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0156
from user code:
File "test_error_messages.py", line N, in fn
@ -203,6 +209,7 @@ Unsupported method call
Developer debug context: call_method UserDefinedObjectVariable(dict_items) __iter__ () {}
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0156
from user code:
File "test_error_messages.py", line N, in fn
@ -226,6 +233,7 @@ Unsupported function call
Developer debug context: call_function UserDefinedObjectVariable(zip) [] {}
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0147
from user code:
File "test_error_messages.py", line N, in fn
@ -249,6 +257,7 @@ Unsupported context manager
Developer debug context: Attempted SETUP_WITH/BEFORE_WITH on ConstantVariable(int: 3)
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0142
from user code:
File "test_error_messages.py", line N, in fn
@ -276,7 +285,10 @@ Backend compiler exception
Exception:test
Traceback:
File "test_error_messages.py", line N, in fn
return x + 1""",
return x + 1
For more details about this graph break, please visit: None""",
)
def test_unsupported_builtin(self):
@ -295,6 +307,7 @@ Failed to trace builtin operator
Developer debug context: builtin print [<class 'torch._dynamo.variables.constant.ConstantVariable'>] False
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0059
from user code:
File "test_error_messages.py", line N, in fn
@ -320,6 +333,7 @@ Attempted to call function marked as skipped
Developer debug context: module: unittest.case, qualname: skip, skip reason: <missing reason>
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0007
from user code:
File "test_error_messages.py", line N, in fn
@ -341,6 +355,7 @@ Attempted to call function marked as skipped
Developer debug context: module: torch._dynamo.decorators, qualname: disable, skip reason: <missing reason>
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0007
from user code:
File "test_error_messages.py", line N, in fn
@ -369,6 +384,7 @@ Attempted to inline function marked as skipped
Developer debug context: qualname: skip, name: skip, filename: `case.py`, skip reason: skipped according trace_rules.lookup unittest
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0008
from user code:
File "test_error_messages.py", line N, in fn
@ -390,6 +406,7 @@ Call to `torch._dynamo.graph_break()`
Developer debug context: Called `torch._dynamo.graph_break()` with args `[]`, kwargs `{}`
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0025
from user code:
File "test_error_messages.py", line N, in fn
@ -410,6 +427,7 @@ Call to `torch._dynamo.graph_break()`
Developer debug context: Called `torch._dynamo.graph_break()` with args `[]`, kwargs `{'msg': ConstantVariable(str: 'test graph break')}`
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0025
from user code:
File "test_error_messages.py", line N, in fn
@ -431,6 +449,7 @@ Attempted to call function marked as skipped
Developer debug context: module: _warnings, qualname: warn, skip reason: <missing reason>
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0007
from user code:
File "test_error_messages.py", line N, in fn
@ -458,7 +477,8 @@ Attempted to call function marked as skipped
Hint: Consider using torch.utils._pytree - https://github.com/pytorch/pytorch/blob/main/torch/utils/_pytree.py
Developer debug context: module: optree._C, qualname: PyCapsule.flatten, skip reason: <missing reason>
""",
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0007""",
)
@scoped_load_inline
@ -504,7 +524,8 @@ Attempted to call function marked as skipped
Hint: If it is a third-party C/C++ Python extension, please either wrap it into a PyTorch-understood custom operator (see https://pytorch.org/tutorials/advanced/custom_ops_landing_page.html for more details) or, if it is traceable, use `torch.compiler.allow_in_graph`.
Developer debug context: module: mylib, qualname: PyCapsule.foobar, skip reason: <missing reason>
""",
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0007""",
)
cpp_source = """
@ -556,6 +577,7 @@ Dynamic slicing with Tensor arguments
Developer debug context: SliceVariable start: ConstantVariable(NoneType: None), stop: TensorVariable(), step: ConstantVariable(NoneType: None)
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0038
from user code:
File "test_error_messages.py", line N, in fn
@ -577,6 +599,7 @@ Observed exception
Developer debug context: raised exception ExceptionVariable(<class 'RuntimeError'>)
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0088
from user code:
File "test_error_messages.py", line N, in fn
@ -602,6 +625,7 @@ Uninitialized nn.Module
Developer debug context: Foo
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0119
from user code:
File "test_error_messages.py", line N, in fn
@ -630,6 +654,7 @@ Unsupported nn.Module attribute type
Developer debug context: nn.Module subclass: Foo, name: attr, attribute type: module
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0161
from user code:
File "test_error_messages.py", line N, in fn
@ -659,6 +684,7 @@ Graph break under GenericContextWrappingVariable
Developer debug context: Active generic context managers: [GenericContextWrappingVariable(GenericCtxMgr), GenericContextWrappingVariable(GenericCtxMgr)]
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0066
from user code:
File "test_error_messages.py", line N, in fn
@ -673,7 +699,8 @@ Call to `torch._dynamo.graph_break()`
Hint: Remove the `torch._dynamo.graph_break()` call.
Developer debug context: Called `torch._dynamo.graph_break()` with args `[]`, kwargs `{}`
""",
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0025""",
)
def test_load_build_class(self):
@ -694,6 +721,7 @@ LOAD_BUILD_CLASS bytecode not supported
Developer debug context:
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0075
from user code:
File "test_error_messages.py", line N, in fn
@ -722,10 +750,11 @@ from user code:
"""\
Missing bytecode handler
Explanation: Dynamo does not know how to handle the bytecode instruction `GET_AITER`.
Hint: Do not trace code that produces the `GET_AITER` bytecode instruction (see https:/docs.python.org/3/library/dis.html for bytecode semantics).
Hint: Do not trace code that produces the `GET_AITER` bytecode instruction (see https://docs.python.org/3/library/dis.html for bytecode semantics).
Hint: It may be possible to write Dynamo tracing rules for this code. Please report an issue to PyTorch if you encounter this graph break often and it is causing performance issues.
Developer debug context: GET_AITER with args (<torch._dynamo.symbolic_convert.InstructionTranslator object at 0xmem_addr>, Instruction(GET_AITER)
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0082
from user code:
File "test_error_messages.py", line N, in fn
@ -756,6 +785,7 @@ Reconstruction failure
Developer debug context: UserMethodVariable(<function GraphBreakMessagesTest.test_reconstruction_failure.<locals>.Foo.meth at 0xmem_addr>, UserDefinedObjectVariable(Foo))
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0092
from user code:
File "test_error_messages.py", line N, in fn
@ -791,6 +821,7 @@ Graph Break Reason: Call to `torch._dynamo.graph_break()`
Developer debug context: Called `torch._dynamo.graph_break()` with args `[]`, kwargs `{}`
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0025
User code traceback:
File "test_error_messages.py", line N, in test_reconstruction_failure_gb
torch.compile(fn, backend="eager")()
@ -810,6 +841,7 @@ Reconstruction failure
Developer debug context: UserMethodVariable(<function GraphBreakMessagesTest.test_reconstruction_failure_gb.<locals>.Foo.meth at 0xmem_addr>, UserDefinedObjectVariable(Foo))
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0092
from user code:
File "test_error_messages.py", line N, in fn
@ -838,6 +870,7 @@ NotImplementedError/UnsupportedFakeTensorException when running FX node
Developer debug context:
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0087
from user code:
File "test_error_messages.py", line N, in fn
@ -861,6 +894,7 @@ Data-dependent branching
Developer debug context: attempted to jump with TensorVariable()
For more details about this graph break, please visit: None
from user code:
File "test_error_messages.py", line N, in fn
@ -927,6 +961,7 @@ Data-dependent assertion failed (cannot compile partial graph)
Developer debug context: value: ConstantVariable(bool: False)
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0034
from user code:
File "test_error_messages.py", line N, in fn
@ -970,6 +1005,7 @@ torch._dynamo.exc.Unsupported: Call to `torch._dynamo.graph_break()`
Developer debug context: Called `torch._dynamo.graph_break()` with args `[]`, kwargs `{}`
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0025
from user code:
File "test_error_messages.py", line N, in fn
@ -1022,6 +1058,7 @@ torch._dynamo.exc.Unsupported: Call to `torch._dynamo.graph_break()`
Developer debug context: Called `torch._dynamo.graph_break()` with args `[]`, kwargs `{}`
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0025
from user code:
File "test_error_messages.py", line N, in fn
@ -1057,6 +1094,7 @@ Graph Break Reason: Call to `torch._dynamo.graph_break()`
Developer debug context: Called `torch._dynamo.graph_break()` with args `[]`, kwargs `{}`
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0025
User code traceback:
File "test_error_messages.py", line N, in test_nested_compile_user_frames
torch.compile(fn, backend="eager")(torch.randn(3))
@ -1170,6 +1208,7 @@ Graph Break Reason: Call to `torch._dynamo.graph_break()`
Developer debug context: Called `torch._dynamo.graph_break()` with args `[]`, kwargs `{}`
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0025
User code traceback:
File "test_error_messages.py", line N, in test_graph_break_traceback_collapsed_resume_frames
f1(torch.randn(3))
@ -1204,6 +1243,7 @@ Skip calling `torch.compiler.disable()`d function
Developer debug context: <function GraphBreakMessagesTest.test_disable_message.<locals>.f at 0xmem_addr>
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0098
from user code:
File "test_error_messages.py", line N, in outer
@ -1225,6 +1265,7 @@ Skip calling `torch.compiler.disable()`d function
Developer debug context: <function GraphBreakMessagesTest.test_disable_message.<locals>.g at 0xmem_addr>
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0098
from user code:
File "test_error_messages.py", line N, in outer
@ -1250,6 +1291,7 @@ Unsupported function call (delayed)
Developer debug context: source: LocalSource(local_name='fn', is_input=True, dynamism=None, is_derefed_cell_contents=False)
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0148
from user code:
File "test_error_messages.py", line N, in outer

View File

@ -43,6 +43,7 @@ Call to `torch._dynamo.graph_break()`
Developer debug context: Called `torch._dynamo.graph_break()` with args `[]`, kwargs `{}`
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0025
from user code:
File "test_exc.py", line N, in fn001
@ -182,6 +183,7 @@ Graph Break Reason: Call to `torch._dynamo.graph_break()`
Developer debug context: Called `torch._dynamo.graph_break()` with args `[]`, kwargs `{}`
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0025
User code traceback:
File "test_exc.py", line N, in test_graph_break_log
torch.compile(fn001, backend="eager")(torch.randn(1))

View File

@ -210,7 +210,8 @@ Unsupported Tensor.item() call with capture_scalar_outputs=False
Hint: Set `torch._dynamo.config.capture_scalar_outputs = True` or `export TORCHDYNAMO_CAPTURE_SCALAR_OUTPUTS=1` to include these operations in the captured graph.
Developer debug context: call_method TensorVariable() item () {}
""", # noqa: B950
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0124""", # noqa: B950
)

View File

@ -1817,7 +1817,8 @@ Dynamic shape operator
Hint: Enable tracing of dynamic shape operators with `torch._dynamo.config.capture_dynamic_output_shape_ops = True`
Developer debug context: _torch_testing.numpy_nonzero.default
""",
For more details about this graph break, please visit: https://compile-graph-break-site.vercel.app/gb/GB0036""",
)
# pre-existing problem: torch.compile(dynamic=True) will, by default,

View File

@ -26,12 +26,15 @@ Error Formatting:
- Debugging utilities for error reporting
"""
import json
import logging
import os
import re
import textwrap
import typing
from enum import auto, Enum
from functools import lru_cache
from pathlib import Path
from traceback import extract_stack, format_exc, format_list, StackSummary
from typing import Any, NoReturn, Optional, TYPE_CHECKING
@ -494,6 +497,42 @@ def format_graph_break_message(
return msg
@lru_cache(maxsize=1)
def _load_graph_break_registry() -> dict[str, Any]:
"""
Loads the graph break registry from JSON file with caching.
"""
try:
script_dir = Path(__file__).resolve().parent
registry_path = script_dir / "graph_break_registry.json"
with registry_path.open() as f:
return json.load(f)
except (FileNotFoundError, json.JSONDecodeError) as e:
log.error("Error accessing the registry file: %s", e)
return {}
def get_gbid_documentation_link(gb_type: str) -> Optional[str]:
"""
Retrieves the GBID documentation link for a given graph break type.
Args:
gb_type: The graph break type to look up.
Returns:
A string containing the documentation URL if found, otherwise None.
"""
GRAPH_BREAK_SITE_URL = "https://compile-graph-break-site.vercel.app/gb/"
registry = _load_graph_break_registry()
for k, v in registry.items():
if v and v[0].get("Gb_type") == gb_type:
return f"{GRAPH_BREAK_SITE_URL}{k}"
return "None"
# TODO replace old unimplemented later
def unimplemented_v2(
gb_type: str,
@ -515,6 +554,10 @@ def unimplemented_v2(
"""
msg = format_graph_break_message(gb_type, context, explanation, hints)
documentation_link = get_gbid_documentation_link(gb_type)
msg += f"\n For more details about this graph break, please visit: {documentation_link}"
if log_warning:
log.warning(msg)
if from_exc is not _NOTHING:

View File

@ -5591,6 +5591,7 @@ def munge_exc(e, *, suppress_suffix=True, suppress_prefix=True, file=None, skip=
s = re.sub(r' File "([^"]+)", line \d+, in (.+)\n( .+\n( +[~^]+ *\n)?)+', repl_frame, s)
s = re.sub(r"line \d+", "line N", s)
s = re.sub(r".py:\d+", ".py:N", s)
s = re.sub(r'https:/([a-zA-Z0-9_.-]+)', r'https://\1', s)
s = re.sub(file, _as_posix_path(os.path.basename(file)), s)
s = re.sub(_as_posix_path(os.path.join(os.path.dirname(torch.__file__), "")), "", s)
if suppress_suffix: