Skip to content

Handle crashes and timeouts in torchci reports - #200942

Closed
jathu wants to merge 5 commits into
mainfrom
jathu/issue-9103
Closed

jathu wants to merge 5 commits into
mainfrom
jathu/issue-9103

Conversation

@jathu

@jathu jathu commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

BC-breaking

Only run_test.py's logging: every test-file timeout now surfaces as exit code 124, see the exit code note under Agent details.

Summary

Handle crashes and timeouts for torchci-reports.

Test Plan

Create intentional errors in this PR (fcc6012), and check ClickHouse.

Agent details

The notes below were written with Claude.

Exit code change. wait_for_process now re-raises the timeout even when pytest exits during the 5 s SIGINT grace period, so retry_shell returns 124 for every timeout instead of pytest's own exit code (usually 2). Retries are unchanged: both codes were already treated as failures. The --subprocess parent logs "Command took >15min, retrying" instead of "Got exit code 2, retrying", and an import-time hang interrupted by SIGINT is reported as 124 instead of "Received signal: SIGINT". The report format change is additive: two new outcome values, crashed and timed_out, which the ingestion lambda already accepts.

Authored with Claude

@pytorch-bot

pytorch-bot Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/200942

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 8e934bb with merge base 8cd072a (image):
💚 Looks good so far! There are no failures yet. 💚

🟡 GREEN LIGHT - PR requires human review:

  • Triviality
    • New feature, not a trivial class: plugin.py publishes report_inflight and run_test.py gains finish_torchci_report to record crashes and timeouts
    • Edits test/conftest.py and test/run_test.py, the runner and fixture files that steer every test run
  • CI behavior change
    • wait_for_process in common_utils.py now re-raises TimeoutExpired even when pytest exits within the SIGINT grace period
    • So retry_shell now returns 124, prints the classifier-matched Command took >Nmin line, and retries where it once returned pytest's exit code
  • Socialization
    • Adds crashed and timed_out outcomes to the torchci report schema in README.md, which ClickHouse and HUD consumers read

reason: not_trivial
Reviewed commit: 8e934bb

Inference job

🐛 Report a wrong verdict

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@jathu jathu changed the title Handle crashes and timeouts Handle crashes and timeouts in torchci reports Oct 14, 2026
@jathu jathu added topic: not user facing topic category ciflow/trunk Trigger trunk jobs on your pull request keep-going Don't stop on first failure, keep running tests until the end labels Oct 14, 2026
@jathu
jathu requested review from georgehong and huydhn October 15, 2026 02:44
@jathu
jathu marked this pull request as ready for review October 15, 2026 02:45
@jathu
jathu requested a review from a team as a code owner October 15, 2026 02:45
Comment thread torch/testing/_internal/common_utils.py Resolved
@@ -1259,17 +1259,13 @@ def wait_for_process(p, timeout=None):
except subprocess.TimeoutExpired:
# send SIGINT to give pytest a chance to make xml
p.send_signal(signal.SIGINT)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My agent flagged that on Windows, p.send_signal(signal.SIGINT) raises ValueError, so the timeout never kills the child or returns 124, and timed_out never gets recorded. This is pre-existing (it shows up in CI as <file> failed! Unsupported signal: 2), so not blocking. But it'd be great to have a follow-up so Windows timeouts show up in the tables too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's follow up: pytorch/test-infra#9133

@jathu

jathu commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

pytorchmergebot pushed a commit that referenced this pull request Oct 16, 2026
**Summary:**
A pytest session that never starts a test, such as run_test.py's serial pass over a file without serial tests, now removes its report when it ends. Such a report holds only the report line, so it adds no rows, but each one is still uploaded and ingested; removing them cuts that ingest traffic.

The report is kept whenever a test started, so the crash and timeout handling from #200942 is unaffected: run_test.py only appends a run the writer published when its test started. A session whose writer turned itself off, or a process that dies before its first test, still leaves its report.

Not `session.testscollected == 0`: under xdist it's the last worker's count, so if a crashed worker's replacement collects nothing, it could delete a report that already has runs.

**Test Plan:**
```
CUDA_VISIBLE_DEVICES= python test/torchci/test_testing.py -v
python test/run_test.py --cpp -i cpp/c10_typeid_test --save-torchci-reports <dir>
```
`test_session_without_tests_leaves_no_report` covers sessions that start no test, with and without xdist; the existing `TestReportCrashes` tests cover the reports that must be kept. The C++ launch now leaves one report instead of two.

Authored with the help of an AI assistant (Claude).
Pull Request resolved: #201118
Approved by: https://github.com/jathu
majing921201 pushed a commit to majing921201/pytorch that referenced this pull request Nov 16, 2026
…#201118)

**Summary:**
A pytest session that never starts a test, such as run_test.py's serial pass over a file without serial tests, now removes its report when it ends. Such a report holds only the report line, so it adds no rows, but each one is still uploaded and ingested; removing them cuts that ingest traffic.

The report is kept whenever a test started, so the crash and timeout handling from pytorch#200942 is unaffected: run_test.py only appends a run the writer published when its test started. A session whose writer turned itself off, or a process that dies before its first test, still leaves its report.

Not `session.testscollected == 0`: under xdist it's the last worker's count, so if a crashed worker's replacement collects nothing, it could delete a report that already has runs.

**Test Plan:**
```
CUDA_VISIBLE_DEVICES= python test/torchci/test_testing.py -v
python test/run_test.py --cpp -i cpp/c10_typeid_test --save-torchci-reports <dir>
```
`test_session_without_tests_leaves_no_report` covers sessions that start no test, with and without xdist; the existing `TestReportCrashes` tests cover the reports that must be kept. The C++ launch now leaves one report instead of two.

Authored with the help of an AI assistant (Claude).
Pull Request resolved: pytorch#201118
Approved by: https://github.com/jathu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request keep-going Don't stop on first failure, keep running tests until the end Merged topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants