Short name describing what triggered the graph break
Tensor.random_ op
Values or code snippet captured at the break point
Tensor.{name}(args={args}, kwargs={kwargs})
Explanation of why the graph break was triggered
This is currently not supported.
Hints on how to resolve the graph break
This graph break happens when the in-place Tensor.random_() method is called
inside a compiled region. random_() is not currently supported by Dynamo, in
part because it decomposes to an aten op whose name collides with a Python
keyword.
Example code that causes the graph break is:
import torch
@torch.compile(fullgraph=True)
def fn(x):
noise = torch.zeros_like(x)
noise.random_(0, 10)
return x + noise
fn(torch.randn(4))
Use an out-of-place factory function that returns a new random tensor instead of
filling one in place. torch.randint_like covers the integer case that
random_ is normally used for:
import torch
@torch.compile(fullgraph=True)
def fn(x):
noise = torch.randint_like(x, 0, 10)
return x + noise
fn(torch.randn(4))
This break is specific to Tensor.random_; other in-place RNG methods such as
Tensor.uniform_ and Tensor.normal_ are supported and do not need to be
rewritten.
If this is causing problems for you, please comment on https://github.com/pytorch/pytorch/issues/156614