Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

[dynamo][Mutation Detector] Does not work with torch.inference_mode #1768

@anijain2305

Description

@anijain2305

Repro

import torch
import torchdynamo


@torch.inference_mode()
def func(x):
  return x * x


x = torch.randn(4)
opt_func = torchdynamo.optimize("inductor")(func)
opt_func(x)

Error

  File "/scratch/anijain/work/torchdynamo/torchdynamo/symbolic_convert.py", line 1488, in RETURN_VALUE
    self.output.compile_subgraph(self)
  File "/scratch/anijain/work/torchdynamo/torchdynamo/output_graph.py", line 332, in compile_subgraph
    self.compile_and_call_fx_graph(tx, list(reversed(stack_values)), root)
  File "/scratch/anijain/work/torchdynamo/torchdynamo/output_graph.py", line 400, in compile_and_call_fx_graph
    compiled_fn = self.call_user_compiler(gm)
  File "/scratch/anijain/work/torchdynamo/torchdynamo/output_graph.py", line 436, in call_user_compiler
    raise BackendCompilerFailed(self.compiler_fn, e) from e
torchdynamo.exc.BackendCompilerFailed: compile_fx raised RuntimeError: Inference tensors do not track version counter.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtriaged

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions