Skip to content

[dynamo] KeyError in resume function creation in Python 3.11+ #162313

@williamwen42

Description

@williamwen42

Minimal repro:

import torch

flag = True


@torch.compile(backend="eager")
def fn(x):
    x = x + 1
    torch._dynamo.graph_break()
    x = x + 2
    if flag:
        with torch.no_grad():
            torch._dynamo.graph_break()
    else:
        with torch.no_grad():
            torch._dynamo.graph_break()
    return x + 4


fn(torch.ones(3))
flag = False
fn(torch.ones(3))

This is because we're incorrectly using meta.block_target_offset_remap in resume_execution.py.

Internal xref: T236677438

cc @chauhang @penguinwu @voznesenskym @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @amjames @Lucaskabela

Metadata

Metadata

Assignees

Labels

module: dynamomodule: python versionIssues related to specific Python versionsoncall: pt2triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions