pytorch - 💡(How to fix) Fix capture_scalar_outputs=True crashes 7/50 HuggingFace models with PendingUnbackedSymbolNotFound [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#180595Fetched 2026-04-17 08:26:08
View on GitHub
Comments
0
Participants
1
Timeline
21
Reactions
0
Author
Participants
Assignees
Timeline (top)
mentioned ×7subscribed ×7labeled ×4cross-referenced ×2

Setting torch._dynamo.config.capture_scalar_outputs = True causes PendingUnbackedSymbolNotFound crashes on 14% of tested models (7/50), while providing measurable benefit (fewer graph breaks) on only 6% (3/50). The crashes are concentrated in vision-language and audio models with complex data-dependent shapes.

Error Message

| Create error (model setup) | 1 | — | All crashes produce the same error: PendingUnbackedSymbolNotFound | Model | Baseline Graphs | Error |

Root Cause

The crash-to-benefit ratio is concerning for enabling this flag by default:

  • 2.3:1 crash-to-benefit ratio (7 crashes vs 3 benefits)
  • Benefits are modest: 1-2 fewer graph breaks per model
  • Crashes are total failures: the model cannot be compiled at all with this flag

The crashes all share the same root cause (PendingUnbackedSymbolNotFound), suggesting a single fix in the unbacked symbol tracking could resolve all 7 cases.

Code Example

import torch
import torch._dynamo

torch._dynamo.config.capture_scalar_outputs = True

# Example: GlmOcrVisionModel (smallest/fastest to reproduce)
from transformers import AutoModel
model = AutoModel.from_pretrained("THUDM/glm-4-9b-hf", trust_remote_code=True)
model = model.eval().cuda()

compiled = torch.compile(model, backend="eager")
with torch.no_grad():
    compiled(**inputs)  # Crashes with PendingUnbackedSymbolNotFound
RAW_BUFFERClick to expand / collapse

Summary

Setting torch._dynamo.config.capture_scalar_outputs = True causes PendingUnbackedSymbolNotFound crashes on 14% of tested models (7/50), while providing measurable benefit (fewer graph breaks) on only 6% (3/50). The crashes are concentrated in vision-language and audio models with complex data-dependent shapes.

Environment

  • PyTorch: 2.12.0.dev20260408+cu128 (nightly)
  • transformers: 5.5.0
  • GPU: NVIDIA PG509-210
  • CUDA: 12.8

Methodology

We tested a stratified random sample of 50 models drawn from 226 HuggingFace models that have graph breaks under torch.compile. The sample was stratified across 4 architecture types to ensure representative coverage:

StratumSample SizeFrom Population
VL/Multimodal1550
Decoder/LLM1533
Encoder-Decoder1058
Vision/Other1085

Each model was compiled 3 times using a lightweight counting backend:

  1. Baseline: no flags (default config)
  2. +capture_scalar_outputs: torch._dynamo.config.capture_scalar_outputs = True
  3. +capture_dynamic_output_shape_ops: (tested separately, reported in a separate issue)

We measured subgraph count per run and classified each flag's effect as: reduces_graphs, no_effect, increases_graphs, crashes, fixes_crash, both_crash, or create_error.

Why only graph_break models? Models that already pass fullgraph=True have no graph breaks, and fullgraph=True implicitly captures scalar outputs. These flags only matter for models that graph-break.

Results

EffectCount% of Testable*
No effect3777%
Crashes715%
Reduces graphs36%
Increases graphs12%
Both crash (baseline + flag)1
Create error (model setup)1

*Testable = excluding create_error and both_crash (48 models)

Models where capture_scalar_outputs helps (3 models)

ModelBaseline GraphsWith FlagReduction
AriaForConditionalGeneration2927-2
AriaTextForCausalLM1614-2
FlaubertModel21-1

Models where capture_scalar_outputs crashes (7 models)

All crashes produce the same error: PendingUnbackedSymbolNotFound

ModelBaseline GraphsError
Ernie4_5_VLMoeForConditionalGeneration18PendingUnbackedSymbolNotFound: Pending unbacked symbols {u6}
Ernie4_5_VL_MoeForConditionalGeneration18same
Glm46VForConditionalGeneration24same
Glm4vForConditionalGeneration24same
GlmOcrVisionModel9same
VideoLlama3VisionModel8PendingUnbackedSymbolNotFound: Pending unbacked symbols {u7}
MimiModel25PendingUnbackedSymbolNotFound: Pending unbacked symbols {u1, u0}

Pattern: All affected models are vision-language (Glm/Ernie family, VideoLlama3) or audio (Mimi) models with complex data-dependent tensor shapes. The common thread is dynamic shapes involving multiple unbacked symbols.

Model where capture_scalar_outputs increases graph count (1 model)

ModelBaseline GraphsWith Flag
Qwen3OmniMoeThinkerForConditionalGeneration2526

Reproduction

import torch
import torch._dynamo

torch._dynamo.config.capture_scalar_outputs = True

# Example: GlmOcrVisionModel (smallest/fastest to reproduce)
from transformers import AutoModel
model = AutoModel.from_pretrained("THUDM/glm-4-9b-hf", trust_remote_code=True)
model = model.eval().cuda()

compiled = torch.compile(model, backend="eager")
with torch.no_grad():
    compiled(**inputs)  # Crashes with PendingUnbackedSymbolNotFound

Analysis

The crash-to-benefit ratio is concerning for enabling this flag by default:

  • 2.3:1 crash-to-benefit ratio (7 crashes vs 3 benefits)
  • Benefits are modest: 1-2 fewer graph breaks per model
  • Crashes are total failures: the model cannot be compiled at all with this flag

The crashes all share the same root cause (PendingUnbackedSymbolNotFound), suggesting a single fix in the unbacked symbol tracking could resolve all 7 cases.

Data

Results from the OSS Model Graph Break Corpus — a systematic catalog of torch.compile graph breaks across 716 HuggingFace models.

cc @chauhang @ezyang @bobrenjc93 @aditvenk @laithsakka @williamwen42 @jansel

extent analysis

TL;DR

Disabling torch._dynamo.config.capture_scalar_outputs can prevent PendingUnbackedSymbolNotFound crashes in vision-language and audio models.

Guidance

  • Identify models that are prone to crashes with capture_scalar_outputs enabled, focusing on vision-language and audio models with complex data-dependent shapes.
  • Test disabling torch._dynamo.config.capture_scalar_outputs to prevent crashes, acknowledging the potential loss of benefits in reducing graph breaks for some models.
  • Investigate alternative solutions to reduce graph breaks, such as using capture_dynamic_output_shape_ops or other optimization techniques.
  • Consider contributing to the fix of the unbacked symbol tracking issue, which could resolve all 7 crash cases.

Example

import torch
import torch._dynamo

# Disable capture_scalar_outputs to prevent crashes
torch._dynamo.config.capture_scalar_outputs = False

# Example: GlmOcrVisionModel
from transformers import AutoModel
model = AutoModel.from_pretrained("THUDM/glm-4-9b-hf", trust_remote_code=True)
model = model.eval().cuda()

compiled = torch.compile(model, backend="eager")
with torch.no_grad():
    compiled(**inputs)  # Should not crash with PendingUnbackedSymbolNotFound

Notes

The provided solution is a workaround, and the root cause of the issue lies in the unbacked symbol tracking. A permanent fix would require addressing this underlying issue.

Recommendation

Apply workaround: disable torch._dynamo.config.capture_scalar_outputs to prevent crashes, as the benefits of enabling it are modest and the crash-to-benefit ratio is high.

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 - 💡(How to fix) Fix capture_scalar_outputs=True crashes 7/50 HuggingFace models with PendingUnbackedSymbolNotFound [1 participants]