pytorch - 💡(How to fix) Fix [dynamo] Display tracked side effects on side-effect related issues [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#176912Fetched 2026-04-08 00:23:54
View on GitHub
Comments
0
Participants
1
Timeline
162
Reactions
0
Participants
Timeline (top)
mentioned ×75subscribed ×75labeled ×6referenced ×3
RAW_BUFFERClick to expand / collapse

Follow-up to https://github.com/pytorch/pytorch/issues/166943

Side effect related graph breaks/errors should log the current tracked side effects (logged to TORCH_LOGS="side_effects". Currently, side effects are logged at codegen, which happens after graph breaks. So side effects won't be logged, e.g. when fullgraph=True.

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

extent analysis

Problem Summary

Side effect logging breaks when graph breaks occur, especially with fullgraph=True.

Root Cause Analysis

The issue arises from logging side effects at codegen, which happens after graph breaks.

Fix Plan

To fix this issue, we need to log side effects before graph breaks occur. We can achieve this by modifying the logging mechanism to log side effects at the point where they are tracked.

Fix Implementation

import logging

# Set up logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

# Define a custom logger for side effects
side_effect_logger = logging.getLogger('side_effects')
side_effect_logger.setLevel(logging.INFO)

# Modify the code to log side effects at the tracking point
def track_side_effects(side_effects):
    # Log side effects
    side_effect_logger.info('Tracked side effects: %s', side_effects)
    # ... (rest of the codegen logic remains the same)

# Update the logging configuration to write to TORCH_LOGS
logging.config.dictConfig({
    'version': 1,
    'formatters': {
        'default': {
            'format': '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
        }
    },
    'handlers': {
        'console': {
            'class': 'logging.StreamHandler',
            'formatter': 'default',
            'stream': 'ext://sys.stdout'
        },
        'file': {
            'class': 'logging.FileHandler',
            'formatter': 'default',
            'filename': 'TORCH_LOGS="side_effects"'
        }
    },
    'root': {
        'level': 'INFO',
        'handlers': ['console', 'file']
    }
})

Verification

To verify that the fix worked, check the logs for side effects when graph breaks occur with fullgraph=True. The side effects should be logged before the graph break error.

Extra Tips

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 [dynamo] Display tracked side effects on side-effect related issues [1 participants]