GB0147

Graph-Break Type

Short name describing what triggered the graph break

Unsupported function call

Context

Values or code snippet captured at the break point

call_function {self} {args} {kwargs}

Explanation

Explanation of why the graph break was triggered

Dynamo does not know how to trace the function {self.debug_repr()}

Hints

Hints on how to resolve the graph break

Additional Information

Example code that causes the graph break is:

def fn(it):
    return [x + 1 for x in it()]
unsupported_callable = zip
compiled_fn = torch.compile(fn, backend="eager", fullgraph=True)
compiled_fn(lambda: unsupported_callable(range(5), range(10)))

A sample workaround around this is instead of passing the zip type, create the zip iterator instance and iterate over it correctly (without the extra () call). This avoids the unsupported function call entirely:

def fn_fixed(iterator):
    return [item[0] + item[1] for item in iterator]

# An instance of a zip iterator is created and passed as the argument.
iterator_instance = zip(range(5), range(10))

# This now compiles successfully
compiled_fn = torch.compile(fn_fixed, backend="eager", fullgraph=True)
result = compiled_fn(iterator_instance)

Click here to add Additional Info

Back to Registry