Skip to content

Treat an empty subset selection as success in modal-torch-latest - #9053

Merged
delock merged 2 commits into
deepspeedai:masterfrom
GuCarpenter:fix/modal-torch-latest-empty-selection-exit5
Nov 11, 2026
Merged

delock merged 2 commits into
deepspeedai:masterfrom
GuCarpenter:fix/modal-torch-latest-empty-selection-exit5

Conversation

@GuCarpenter

Copy link
Copy Markdown
Contributor

The modal-torch-latest GPU controller (ci/torch_latest.py) runs pytest remotely in a Modal sandbox / AWS instance and treats any nonzero pytest exit as a candidate failure. A diff-selected (subset) run whose only targets skip on the runner collects nothing, so pytest exits 5 ("no tests collected") and the job fails red even though the run is a legitimate green no-op.

Observed on run 42921207259 (merge_group for #8867): the selector picked only tests/unit/v1/accelerator/test_klxpu_accelerator.py, which is module-level skipped on NVIDIA runners, so pytest reported "4 workers [0 items]" / "1 skipped" and the controller raised RemoteCommandError: run pytest failed with exit code 5.

This mirrors the merged sibling fix for cpu-torch-latest-v1-multirank (#9032), which maps pytest exit 5 to a green skip for subset selections. That fix only touched the CPU workflow's shell step; the GPU controller delegates all run/classify logic to ci/torch_latest.py, so the equivalent guard belongs there and must cover both the Modal and AWS backends.

  • Add EXIT_NO_TESTS = 5 and a shared EMPTY_SELECTION_MESSAGE.
  • run_controller (Modal): a "run pytest" failure with code 5 in subset mode returns 0 with the message instead of raising.
  • run_aws_controller (AWS): same guard on test_code.
  • Gate on selection_mode == "subset"; mode=all runs the whole tests/unit/v1 scope, where an empty collection means the selector or a collection guard broke and must still fail. Other exit codes (1, 124) are unchanged.
  • Add controller/AWS tests for the subset no-op and the mode=all guard.

AI assistance was used to analyze the failing run and draft this patch.

The modal-torch-latest GPU controller (ci/torch_latest.py) runs pytest
remotely in a Modal sandbox / AWS instance and treats any nonzero pytest
exit as a candidate failure. A diff-selected (subset) run whose only
targets skip on the runner collects nothing, so pytest exits 5 ("no tests
collected") and the job fails red even though the run is a legitimate
green no-op.

Observed on run 42921207259 (merge_group for deepspeedai#8867): the selector picked
only tests/unit/v1/accelerator/test_klxpu_accelerator.py, which is
module-level skipped on NVIDIA runners, so pytest reported
"4 workers [0 items]" / "1 skipped" and the controller raised
RemoteCommandError: run pytest failed with exit code 5.

This mirrors the merged sibling fix for cpu-torch-latest-v1-multirank
(deepspeedai#9032), which maps pytest exit 5 to a green skip for subset selections.
That fix only touched the CPU workflow's shell step; the GPU controller
delegates all run/classify logic to ci/torch_latest.py, so the equivalent
guard belongs there and must cover both the Modal and AWS backends.

- Add EXIT_NO_TESTS = 5 and a shared EMPTY_SELECTION_MESSAGE.
- run_controller (Modal): a "run pytest" failure with code 5 in subset
  mode returns 0 with the message instead of raising.
- run_aws_controller (AWS): same guard on test_code.
- Gate on selection_mode == "subset"; mode=all runs the whole
  tests/unit/v1 scope, where an empty collection means the selector or a
  collection guard broke and must still fail. Other exit codes (1, 124)
  are unchanged.
- Add controller/AWS tests for the subset no-op and the mode=all guard.

AI assistance was used to analyze the failing run and draft this patch.

Signed-off-by: guhangsong <guhangsong@outlook.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T08:15:57.364620Z 43d0fa2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 43d0fa27f9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread ci/torch_latest.py
Comment on lines +1766 to +1767
return (isinstance(error, RemoteCommandError) and error.label == "run pytest"
and error.return_code == EXIT_NO_TESTS and inputs.selection_mode == "subset")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Require proof of skips before accepting exit 5

When a subset-selected test_*.py accidentally stops exposing pytest items (for example, its test functions are renamed or removed), pytest returns 5 even though nothing was skipped; pytest's official exit-code contract defines 5 only as “No tests were collected.” Both this predicate and the analogous run_aws_controller branch check only that code and the mode, so the required merge-queue check turns that collection regression into success and can merge candidate code with zero selected coverage while printing a misleading skip message. Preserve the intended module-level-skip no-op, but require evidence that the no-collection result actually contained skips before returning 0.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

Comment thread ci/torch_latest.py
if primary_error is not None:
if _is_empty_pytest_selection(primary_error, inputs):
print(EMPTY_SELECTION_MESSAGE, flush=True)
return 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Document the exit-5 exception to failure guarantees

This new success path changes an explicitly documented safety guarantee: .github/workflows/TEST_SELECTION.md still states at lines 466-467 that every nonzero test status fails and at lines 509-511 that any failed pytest command fails the controller. For subset exit 5 neither statement is now true, so the operator/security documentation used to reason about this trusted controller is misleading; update the failure-mode section to spell out the narrowly allowed no-tests exception for both Modal and AWS.

Useful? React with 👍 / 👎.

@delock
delock self-requested a review November 11, 2026 08:23
@delock
delock enabled auto-merge November 11, 2026 08:41
@delock
delock added this pull request to the merge queue Nov 11, 2026
Merged via the queue into deepspeedai:master with commit b9100c5 Nov 11, 2026
18 checks passed
@auto-pr-labeler-with-jev auto-pr-labeler-with-jev Bot added the skip-gpu-test Requires positive evidence that every changed behavior can be validated without a GPU. label Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-gpu-test Requires positive evidence that every changed behavior can be validated without a GPU.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants