Skip to content

Backend CI: split the g-r pytest shard into g-l and m-r - #17187

Merged
danielhanchen merged 5 commits into
mainfrom
ci/backend-split-g-r-shard
Nov 9, 2026
Merged

danielhanchen merged 5 commits into
mainfrom
ci/backend-split-g-r-shard

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

The Backend CI (Python 3.13, g-r) shard is running into its timeout --signal=INT --kill-after=60 1500 backstop. Its parallel pytest step took 955 s and 1433 s on the two most recent green main runs, and on 2026-11-09 two staging runs of unrelated PRs were killed with exit 124 (one after 36333 passed ... in 1509.28s, one during xdist teardown).

This splits g-r into g-l and m-r, the same way a-k / l-r became a-f / g-r on 2026-10-23. The timeout is left alone, since it is a hang backstop and not a budget.

How the split point was chosen

The -q progress lines in the job logs carry timestamps, and xdist hands out tests roughly in collection order. So I mapped each line's cumulative test count onto the per-file collection order and read off the elapsed time at each letter boundary. Across four g-r logs (two main, two staging):

boundary share of g-r time
through k 0.20 to 0.26
through l 0.36 to 0.42
through m 0.64 to 0.68

test_m* alone is about 30% of the shard, so g-l / m-r (about 40 / 60) is the most even split on a first letter. g-m / n-r would be about 67 / 33.

Changes

  • .github/workflows/studio-backend-ci.yml: the g-r matrix entry becomes g-l (--ignore-glob=tests/test_[!g-l]*.py) and m-r (--ignore-glob=tests/test_[!m-r]*.py). rest keeps --ignore-glob=tests/test_[a-r]*.py, so it is still the remainder and new files still land in exactly one shard. The comment records the history.
  • tests/test_ci_backend_pytest_shards.py: the new-file examples now cover both new ranges, and a new parametrized test checks that every lowercase first letter is claimed by exactly one shard.

The serial and decision-training steps stay pinned to a-f. No required status check names the old g-r shard.

Testing

  • pytest tests/test_ci_backend_pytest_shards.py: 54 passed. Changing g-l to g-k makes 3 tests fail (the l files are dropped), so the guard still catches gaps.
  • pytest --collect-only with the CI selection: g-r collects 37225 tests, g-l 14324 and m-r 22901. The union of g-l and m-r is identical to g-r's node IDs.
  • Staging run: results to follow in a comment.

g-r's parallel step took 955-1433 s on main and hit the 1500 s backstop
on staging runs on 2026-11-09. Per-letter progress timestamps from four
g-r logs put about 40% of its time in g-l and 60% in m-r. rest stays the
remainder, and the shard test now checks every first letter maps to
exactly one shard.
@danielhanchen danielhanchen self-assigned this Nov 9, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 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-09T04:01:43.075050Z dd3e717 Manual request
ℹ️ 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

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: a23d33b713

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

In the new g-l shard no earlier file in the worker stubs unsloth, so the
real package is imported and raises ImportError (not ModuleNotFoundError)
for the missing unsloth_zoo. pytest 9 importorskip only skips
ModuleNotFoundError by default, so pass exc_type=ImportError.

[skip ci]
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: e9baeff343

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

The g-r split adds a fourth backend pytest shard, so the command scan now sees fourteen parallel runs (four backend shards and ten repo-cpu shards).
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: dd3e7173bc

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 20cbf1b into main Nov 9, 2026
@danielhanchen
danielhanchen deleted the ci/backend-split-g-r-shard branch November 9, 2026 05:26
danielhanchen added a commit that referenced this pull request Nov 14, 2026
## Summary

The Backend CI `(Python 3.13, a-f)` shard is now running into its
`timeout --signal=INT --kill-after=60 1500` backstop. On #17694 (a
Studio download-registry change) the parallel step was killed with exit
124 after `30296 passed ... in 1509.42s`, before it finished. Its other
recent runs took 1000 to 1340 s, so any slower runner tips it over.

This is the same situation as a-k on 2026-10-23 and g-r on 2026-11-09,
and it gets the same fix: split the shard, leave the timeout alone (it
is a hang backstop, not a budget).

## How the split point was chosen

Same method as #17187: the `-q` progress lines carry timestamps, and
xdist hands out tests roughly in collection order, so I mapped the
progress percentage onto the per-file collection order of a-f. Across
five a-f logs (four complete, one killed):

| boundary | share of a-f time |
| --- | --- |
| through `test_c*` | 0.26 to 0.29 |
| `test_diffusion*` starts | 0.32 to 0.38 |
| `test_diffusion*` ends | 0.93 to 0.94 |

`test_d*` alone is about 65% of the shard and nearly all of it is
`test_diffusion*` (about 60%). No first letter split comes close to
even, so `test_diffusion*` gets its own shard: roughly 40% stays in a-f
and 60% moves.

## Changes

- `.github/workflows/studio-backend-ci.yml`:
  - `a-f` also ignores `tests/test_diffusion*.py`.
- New `diffusion` shard, rooted at `tests/` like the others (so the
shared `--ignore=` list still applies). It excludes everything but
`test_diffusion*` one letter at a time, so `test_diffusers*` (and any
other `test_d*` file) stays in `a-f`.
  - `rest` is unchanged and still the remainder.
- The serial and decision-training steps stay pinned to `a-f`. The
`(Python 3.13, a-f)` check keeps its name.
- `tests/test_ci_backend_pytest_shards.py`: new-file examples for the
boundary (`test_dog`, `test_diffusers_new`, `test_diffuse` land in
`a-f`; `test_diffusion_new`, `test_diffusion` land in `diffusion`).

## Testing

- `pytest tests/test_ci_backend_pytest_shards.py`: 59 passed.
- Sabotage: without the `test_diffusion*` ignore on `a-f`, 3 tests fail
(files run twice). Without the `test_diffus[!i]*` step, the same 3 fail
(`test_diffusers*` would run in both shards).
- `pytest --collect-only` with the CI selection and shared ignores: old
a-f collects 38267 tests, new a-f 16230 and diffusion 22037. The two are
disjoint and their union is identical to the old a-f node IDs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant