Skip to content

Backend CI: run test_diffusion* in its own pytest shard - #17723

Merged
danielhanchen merged 1 commit into
mainfrom
backend-ci-diffusion-shard
Nov 14, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
backend-ci-diffusion-shard

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

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.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 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-14T03:03:21.966751Z 97c777f 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. Bravo.

Reviewed commit: 97c777f399

ℹ️ 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 aab5ae5 into main Nov 14, 2026
@danielhanchen
danielhanchen deleted the backend-ci-diffusion-shard branch November 14, 2026 03:09
danielhanchen added a commit that referenced this pull request Nov 14, 2026
…nt the diffusion shard (#17736)

## Summary

Follow-up to #17723, which moved `test_diffusion*` into its own `(Python
3.13, diffusion)` backend shard. Two things went red once that shard ran
(seen on a staging run against current main):

1. `Repo tests (CPU, studio)` and `workflow-trigger lint`:

   ```

tests/studio/test_backend_ci_parallel_isolation.py::test_the_command_scan_sees_the_parallel_run_and_the_serial_steps
AssertionError: expected fourteen parallel pytest runs, four shards of
the backend matrix and ten of repo-cpu-tests ... assert 15 == 14
   ```

That test pins the number of parallel pytest runs on purpose, so a new
shard has to be stated there. #17723 updated
`test_ci_backend_pytest_shards.py` but missed this one. My mistake.

2. `(Python 3.13, diffusion)`: five tests in
`studio/backend/tests/test_diffusion_lm_studio.py` fail with
`PackageNotFoundError: No package metadata was found for unsloth_zoo`:
   - `test_frame_relay_throttles_and_never_raises_into_the_sampler`
- `test_frame_relay_sends_zero_based_steps_and_honours_stop_sequences`
   - `test_frame_relay_cuts_frames_at_the_first_eos`
   - `test_diffusion_eos_ids_match_the_sampler_cut`
-
`test_chat_diffusion_load_refuses_an_unmarked_model_and_keeps_the_token_boundary`

They import `core.inference.inference`, which imports `unsloth`, and the
backend job installs neither `unsloth_zoo` nor `trl`. They only passed
in the old a-f shard because an earlier file on the same worker
(`test_audio_chat_load.py`, `test_chat_prompt_bos.py`) had already
imported that module with its own `unsloth` stubs and left it cached. In
a shard of only `test_diffusion*` files that never happens. So these
tests have depended on xdist scheduling since #13593; the split only
made it deterministic.

## Change

- `tests/studio/test_backend_ci_parallel_isolation.py`: 15 parallel
runs, 5 backend shards.
- `studio/backend/tests/test_diffusion_lm_studio.py`: a small
`inference_mod` fixture the five tests now take.
- When `unsloth_zoo` is installed, or the module is already imported, it
returns the real module. Nothing changes there.
- Otherwise it stubs `unsloth` and `unsloth.chat_templates` (the same
two names the other backend tests stub) through `monkeypatch`, and also
drops the freshly imported `core.inference.inference`. So no later test
inherits a module bound to these stubs.
- The tests keep running in the backend job instead of being skipped
there.

## Testing

- Locally, with `diffusers`, `unsloth_zoo` and `trl` hidden from import
(the backend job's environment): `test_diffusion_lm_studio.py`,
`test_diffusion_int8_attention.py` and
`test_diffusion_rocm_tag_detect.py` on their own. The five tests fail on
main with the same error and pass here. They also pass with the real
packages installed.
- The same files in one process, before and after
`test_audio_chat_load.py` and `test_chat_prompt_bos.py`: 78 passed, 33
skipped in both orders.
- Every test that reads `studio-backend-ci.yml` (15 files): 341 passed,
3 skipped. The isolation test fails on main.
- `test_backend_tests_stub_heavy_imports.py` and
`test_sibling_imported_tests_import_their_helpers_top_level.py`: pass.

The other failures on the new shard come from #17718 and are fixed in
#17737.
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