Skip to content

Treat an all-deselected selection as success in cpu-torch-latest-v1-multirank - #9032

Merged
delock merged 3 commits into
deepspeedai:masterfrom
delock:ci/v1-multirank-empty-selection
Nov 8, 2026
Merged

delock merged 3 commits into
deepspeedai:masterfrom
delock:ci/v1-multirank-empty-selection

Conversation

@delock

@delock delock commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

cpu-torch-latest-v1-multirank fails red on any PR whose diff-selected tests/unit/v1 targets contain no multi-rank tests. DS_MULTIRANK_ONLY=1 deselects every single-rank test (see the pytest_collection_modifyitems hook in tests/conftest.py), pytest then reports no tests ran and exits with code 5, and the job fails — even though the run is a legitimate green no-op.

The workflow already guards the empty-selection case (No v1 tests selected; nothing to run. → exit 0) but not the all-deselected case. This PR treats pytest exit code 5 the same way: a green skip with a clear message. Every other exit code is passed through unchanged, so real test failures (1), usage errors (4), and internal errors (3) still fail the job.

Root cause

Observed on #8939 (run 42374006158): the diff-based selector (ci/tests_fetcher.py) correctly selected exactly one target, tests/unit/v1/test_hybrid_engine_rollout_v1.py, but all of its tests are plain single-process tests, not DistributedTest subclasses. The multirank filter deselected all of them:

### 1 pytest target(s) -> ci/.test_selection/test_list.txt ###
  tests/unit/v1/test_hybrid_engine_rollout_v1.py
...
============================ no tests ran in 4.02s =============================
##[error]Process completed with exit code 5.

Per pytest's documented exit-code convention, 5 means "no tests were collected" — a neutral "nothing to run" signal, not a failure. Any PR touching only non-distributed tests under tests/unit/v1 hits this.

Implementation

  • Capture the pytest exit code (set +e / set -e scoped to that one command).
  • Exit 0 with No multi-rank tests in the selection; nothing to run. when it is 5, mirroring the existing empty-selection guard one branch above.
  • exit "$pytest_exit" for everything else.

The nightly cpu-torch-multi-latest also sets DS_MULTIRANK_ONLY=1 but runs the whole unit/ tree (excluding v1/), which always contains multi-rank tests, so it cannot hit this edge and is not changed.

Validation

  • YAML parse check and bash -n on the extracted Unit tests script: pass.
  • Branch simulation of the new logic with a stub pytest: exit 5 → script exit 0 with the skip message; exit 1 → exit 1; exit 0 → exit 0.
  • pre-commit run --files .github/workflows/cpu-torch-latest-v1-multirank.yml: all hooks pass.
  • No hardware device is involved; the change is workflow-shell only. The live-workflow behavior cannot be executed locally — it will be validated by this PR's own CI run (this workflow triggers on the changed path).

Duplicate-work check

Searched open PRs and issues for multirank, no tests ran, and exit code 5; nothing addresses this.

AI assistance

This change was prepared with AI assistance (analysis of the failing CI run and drafting of the patch); every line was reviewed, and all listed validation was run, by the human submitter.

…ultirank

The workflow guards an empty test selection (exit 0) but not a selection
whose targets hold no multi-rank tests: DS_MULTIRANK_ONLY deselects every
single-rank test, pytest then reports "no tests ran" and exits 5, and the
job fails red. Any PR that only changes non-distributed tests under
tests/unit/v1 (e.g. deepspeedai#8939) hits this. Treat pytest exit code 5 as a green
skip, like the empty-selection case, and pass every other exit code
through.

Signed-off-by: Ma, Guokai <guokai.ma@intel.com>
@delock
delock requested a review from loadams as a code owner November 7, 2026 13:18
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 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-07T13:20:29.868684Z 30509ea 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.

@hwchen2017

hwchen2017 commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Exit 5 should be accepted in subset mode. In mode=all, an empty run can only mean the multi-rank selector broke.

…h-latest-v1-multirank

mode=all selects the whole v1 scope, so an empty run there can only mean the
selector or the multi-rank gate broke; keep that failure visible instead of
masking it. Plumb the selection mode from collect-tests into the test step so
the two cases can be told apart.

Signed-off-by: Guokai Ma <guokai.ma@intel.com>
@delock

delock commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author

Exit 5 should be accepted in subset mode. In mode=all, an empty run can only mean the multi-rank selector broke.

@hwchen2017 thanks for pointing this out. The latest commit guard this change in subset mode only. Thanks!

@delock
delock enabled auto-merge November 8, 2026 02:37
@delock
delock added this pull request to the merge queue Nov 8, 2026
Merged via the queue into deepspeedai:master with commit 57ec847 Nov 8, 2026
18 checks passed
@delock
delock deleted the ci/v1-multirank-empty-selection branch November 8, 2026 03:38
banxingmjj pushed a commit to openanolis/DeepSpeed that referenced this pull request Nov 11, 2026
…pspeedai#9053)

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>
Co-authored-by: Ma, Guokai <guokai.ma@gmail.com>
@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