pymc-devs / pymc-devs/pytensor

IncSubtensor causes graph break in pytorch backend

Open
#1,154 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

torch
Dominant language
Python
Stars
644
Forks
208
Avg merge
2d 14h
Merged PRs (30d)
16

Description

Description
import pytensor
import pytensor.tensor as pt
import torch

x = pt.vector('x')
y = x[-1].inc(1)
f = pytensor.function(inputs=[x], outputs=y, mode="PYTORCH")

torch._dynamo.explain(f.vm.jit_fn._fn)(torch.zeros(2)).break_reasons

WIll produce: [GraphCompileReason(reason='data dependent operator: aten._local_scalar_dense.default; to enable, set torch._dynamo.config.capture_scalar_outputs = True', user_stack=[<FrameSummary file [/Users/ch0ronomato/dev/pytensor/pytensor/link/pytorch/dispatch/subtensor.py](https://file+.vscode-resource.vscode-cdn.net/Users/ch0ronomato/dev/pytensor/pytensor/link/pytorch/dispatch/subtensor.py), line 99 in inc_subtensor>], graph_break=True)]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the PyTensor/PyTorch reproducer from the issue and inspect pytensor/link/pytorch/dispatch/subtensor.py around line 99 in inc_subtensor. Use torch._dynamo.explain on the compiled function to verify the graph break and trace the relevant dispatch behavior. Done means the reproducer no longer reports this graph break.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
backend, machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.