Skip to content

CI: run the multi-rank Repo tests shards only when what they import changes - #19127

Merged
danielhanchen merged 3 commits into
mainfrom
ci-distributed-cpu-split
Nov 24, 2026
Merged

danielhanchen merged 3 commits into
mainfrom
ci-distributed-cpu-split

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Backend CI's seven multi-rank Repo tests shards (fsdp2, fsdp2-native, gloo, gloo-tp-env, gloo-cp, gloo-tp, gloo-pp) are about 342k of the roughly 1.77M runner minutes in the last Actions usage export, and each queues for about two hours first. They run on almost every PR because Backend CI's path list is broad. But they import only unsloth.*, torch and sibling test helpers: of 5,593 non-merge commits on main since 2026-10-01, 98.8% trigger Backend CI and 22.9% touch anything these tests read.

Change

  • New .github/workflows/distributed-cpu-ci.yml: the seven shards moved verbatim. That includes selections, workers: 2 on gloo-cp, check names (Repo tests (CPU, <shard>)), install and ruff steps, the pytest step, timeouts, runner, concurrency group and cancel rule. It borrows repo-cpu-tests' pip cache read-only.
    • Its pull_request and push paths are what those tests import: unsloth/**, the multi-rank test files and the five sibling modules they import, tests/_*.py, tests/_shared/**, tests/conftest.py, pyproject.toml, studio/backend/requirements/**, the install inputs, the two local actions it uses and the workflow itself.
    • It also runs nightly and on dispatch, because unsloth_zoo is installed from git main and no path filter can see that.
  • studio-backend-ci.yml keeps studio-install, studio, rest and rest-2, and lists the new workflow in its paths so the shard-layout guards run when it changes.
  • Guards:
    • tests/test_ci_repo_cpu_shards.py reads both matrices and checks that the moved steps stay identical, that every test file the moved shards import matches a path, that push and PR paths agree, and that the schedule exists.
    • test_backend_ci_parallel_isolation.py scans both workflows, so its 16 parallel and 11 repo-root counts are unchanged.
    • test_pip_cache_naming.py and test_cache_budget_discipline.py list the new read-only borrower.

main has no required status checks, so a skipped workflow blocks nothing.

Results

  • Collected node IDs, with each shard's selection expanded as the workflow does, on current main: no shard loses an ID (old 11 shards 46,740, new 4 + 7 shards 46,763). The 23 extra IDs are this PR's 6 new guards and workflow-scanning tests that gain one parametrized case for the new workflow file.
  • Staging run of this branch: Distributed CPU CI passed all seven shards. Backend CI's only failures were in tests this PR does not touch (two chat-only Mac MLX model-picker tests and a frontend-source assertion in the studio shard, and a subprocess timeout in a gloo test in the Python 3.13 diffusion shard).
  • Mutation checks: dropping tests/_shared/** and tests/test_tp_*.py from the paths fails 2 guard tests, deleting the gloo-pp shard fails the dropped-file test, and removing a shard from the new workflow fails the isolation guard.
  • About 7,500 workflow guard tests pass. The only failures fail identically on base: test_cached_paths_hold_no_credentials, 2 in test_save_mtp_head_stitch.py, and a collection error in test_rocm_support.py.
  • Expected saving: about 255-265k runner minutes and about 17k job starts per export period, and 7 fewer queued jobs on a Studio-only PR. This is an estimate from the commit history, not a measurement.

…hanges

The seven fsdp2 / gloo shards of Backend CI's Repo tests (CPU) import unsloth, torch and
sibling test modules, not studio, but Backend CI's path list matched 98.8% of main's commits
since 2026-10-01, so every Studio PR queued and ran them. They move unchanged into
distributed-cpu-ci.yml, whose paths are their import closure (unsloth/**, the multi-rank test
files and the siblings they import, tests/_*.py, tests/_shared/**, the conftest, pyproject,
the requirements and install inputs): 22.9% of those commits. A nightly run keeps catching
unsloth_zoo main drift, which no path can see.

Same check names, steps, install, timeouts and concurrency contract. The pip cache is
borrowed read-only from Backend CI's repo-cpu-tests entry. The union of collected node IDs
over all shards is unchanged (46,711, identical per shard). The shard guard reads both
matrices and now also checks that the new workflow's paths cover every tests/ file its shards
import, that push and PR paths match, and that the moved step and install are identical.
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-23T18:32:45.590573Z
We couldn’t complete this review. Comment @codex review to try again.
dfc1546 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.

danielhanchen added a commit that referenced this pull request Nov 23, 2026
…19135)

## Problem


`tests/test_runtime_text_encoding.py::test_shipping_code_names_an_encoding`
is red on `main` in `Repo tests (CPU, rest)`, for example on #19122 and
#19127:

```
4 text read/write call sites in shipping code let the operator's locale decide the encoding
  'unsloth/models/inkling2.py:364: open()'
  'unsloth/models/inkling2.py:532: open()'
  'unsloth/models/inkling2.py:537: open()'
  'unsloth/models/inkling2.py:545: open()'
```

## Cause

The guard is right; the new code is wrong.

#19016 (Inkling 2 merged 16-bit save and GGUF export) added four
text-mode `open()` calls with no encoding:

- reading `model.safetensors.index.json` (`index_path`);
- writing the merged index;
- reading `config.json`;
- writing `config.json`.

On Windows, Python uses the locale code page there. A config or index
with a non-ASCII byte then fails to load, or is written in a codec the
next reader does not expect. The guard has been in the repo since
October; the lines all come from `c69ffd79be`.

## Fix

Pass `encoding = "utf-8"` on all four calls in
`unsloth/models/inkling2.py`. Nothing else changes: the JSON written is
the same on a UTF-8 host.

## Verification

- `tests/test_runtime_text_encoding.py`: 9 passed (`main`: 1 failed,
listing exactly these four sites).
- `tests/test_inkling2_support.py` on transformers 5.24.0, including the
merged-save tests: 42 passed.
@danielhanchen
danielhanchen merged commit b7737bf into main Nov 24, 2026
@danielhanchen
danielhanchen deleted the ci-distributed-cpu-split branch November 24, 2026 00:36
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