pytorch - ✅(Solved) Fix [dynamo] fullgraph=True error on eager fallback has bad interaction with "eager_on_recompile" stance [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
pytorch/pytorch#181817Fetched 2026-04-29 06:10:50
View on GitHub
Comments
0
Participants
1
Timeline
70
Reactions
0
Participants
Assignees
Timeline (top)
mentioned ×32subscribed ×32labeled ×4assigned ×1

Error Message

When fullgraph=True and the eager_on_recompile stance is active, recompile attempts cause the "torch.compile with fullgraph=True found no compiled frames." error. This is not good behavior since in this stance, the user likely wants to allow fallbacks to eager. fn(torch.ones(3), 2) # fullgraph=True causes error

  1. Warn instead of error for the 2.12 release.
  2. Do not do the fallback-to-eager error if a non-default stance is active.

Fix Action

Fixed

PR fix notes

PR #181818: [dynamo] warn instead of error on fullgraph=True fallback to eager for 2.12

Description (problem / solution / changelog)

Stack from ghstack (oldest at bottom):

  • -> #181818

Step 1. of https://github.com/pytorch/pytorch/issues/181817 for the 2.12 release.

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

Changed files

  • test/dynamo/test_compile.py (modified, +4/-4)
  • test/dynamo/test_misc.py (modified, +1/-1)
  • torch/_dynamo/eval_frame.py (modified, +3/-2)

Code Example

import torch

@torch.compile(fullgraph=True, backend="eager", dynamic=False)
def fn(x, n):
  return x + n

fn(torch.ones(3), 1)
with torch.compiler.set_stance("eager_on_recompile"):
  fn(torch.ones(3), 2)  # fullgraph=True causes error
RAW_BUFFERClick to expand / collapse

When fullgraph=True and the eager_on_recompile stance is active, recompile attempts cause the "torch.compile with fullgraph=True found no compiled frames." error. This is not good behavior since in this stance, the user likely wants to allow fallbacks to eager.

Example:

import torch

@torch.compile(fullgraph=True, backend="eager", dynamic=False)
def fn(x, n):
  return x + n

fn(torch.ones(3), 1)
with torch.compiler.set_stance("eager_on_recompile"):
  fn(torch.ones(3), 2)  # fullgraph=True causes error

The fixes are:

  1. Warn instead of error for the 2.12 release.
  2. Log skip reasons comprehensively - Dynamo does not always log why we skip tracing.
  3. Do not do the fallback-to-eager error if a non-default stance is active.

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

extent analysis

TL;DR

Modify the torch.compile behavior to warn instead of error when fullgraph=True and eager_on_recompile stance is active.

Guidance

  • Identify the torch.compile function calls with fullgraph=True and adjust the error handling to warn instead of error when eager_on_recompile stance is active.
  • Verify that the fallback to eager mode works as expected by checking the logs for skip reasons.
  • Consider implementing a comprehensive logging system to track why tracing is skipped.
  • Review the code for any instances where the fallback-to-eager error is triggered when a non-default stance is active and modify the behavior accordingly.

Example

import torch

@torch.compile(fullgraph=True, backend="eager", dynamic=False)
def fn(x, n):
  try:
    return x + n
  except torch.errors.CompileError as e:
    # Handle the error or warn instead
    print(f"Warning: {e}")

Notes

The provided solution assumes that the torch.compile function and eager_on_recompile stance are correctly implemented and configured. The example code snippet is a minimal illustration and may require adjustments based on the actual codebase.

Recommendation

Apply workaround: Modify the torch.compile behavior to warn instead of error when fullgraph=True and eager_on_recompile stance is active, as this allows for fallbacks to eager mode and provides a more robust error handling mechanism.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

pytorch - ✅(Solved) Fix [dynamo] fullgraph=True error on eager fallback has bad interaction with "eager_on_recompile" stance [1 pull requests, 1 participants]