Skip to content

Core zoo: restore a main-built Inductor cache - #19126

Merged
danielhanchen merged 3 commits into
mainfrom
ci-core-zoo-inductor-cache
Nov 24, 2026
Merged

danielhanchen merged 3 commits into
mainfrom
ci-core-zoo-inductor-cache

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Core zoo's three legs run the unsloth_zoo suite on CPU, and its compile tests rebuild every Inductor kernel with g++ on every run. On a recent staging run of main, the default leg hit its 50 minute job cap and the latest leg finished at the cap.

Change

  • consolidated-tests-ci.yml, consolidated-zoo: before the zoo pytest step, point TORCHINDUCTOR_CACHE_DIR at $RUNNER_TEMP/inductor-cache and restore it.
    • Key: zoo-inductor-v1-<leg>-<stack>-<pyproject hash>-<zoo SHA>. <stack> hashes the installed torch, triton and transformers versions, so a new compiler stack or new pins start a fresh cache instead of growing an old one.
    • Restore by prefix up to the pyproject hash, so a PR starts from the newest generation built for its leg and stack.
    • Save only on pushes to main, after a green suite, matching the pip cache gate (test_no_workflow_saves_a_cache_on_a_pull_request_ref). A workflow_dispatch never saves, since it can pin a candidate unsloth_zoo_ref.
  • cache-janitor.yml: a zoo-inductor-* family that strips the trailing 40-hex SHA and keeps one generation per prefix.

The latest leg is red on main today (2 Inkling2 tests), so it will not save until that is fixed; its PRs run cold until then.

Results

  • Same-runner A/B on the 25 heaviest zoo files, cold then warm then cold again in one job: Intel Xeon 6975P-C 994 s / 846 s / 983 s, AMD EPYC 7763 1625 s / 1365 s / 1580 s. That is about 14.5% less wall time warm, with the two cold arms within 1-3% of each other. Failed and skipped IDs were identical across all three arms on both runners.
  • Full suite, default leg, on one runner, cold then warm with every other cache (HF, XDG, Triton, TMPDIR) isolated per arm: AMD EPYC 7763 2672 s to 2377 s (-11.0%), AMD EPYC 9V74 2652 s to 2331 s (-12.1%). The same 20,336 IDs were collected, and the same single pre-existing failure (test_pypi_version_sync.py::test_pypi_version_is_not_ahead_of_main) appeared in both arms. The warm arm always ran second; with the other caches isolated, order alone was worth about 3% in earlier runs.
  • The cache is about 50-80 MB per leg.
  • On a PR the restore misses cleanly (Cache not found for input keys: zoo-inductor-v1-...) and the job continues.
  • Guard tests that read either workflow, plus test_cache_budget_discipline.py and test_pip_cache_naming.py: 303 passed, 4 skipped.

The zoo suite's CPU compile tests rebuild every Inductor kernel with g++ on
every run. A same-runner A/B of the 25 heaviest zoo files (cold, warm, cold
on Intel Xeon 6975P-C and AMD EPYC 7763) measured ~14.5% less wall time with
a warm cache and identical pass/skip/fail IDs. The cache is ~50-80 MB per leg.

Saved on main only, after a green suite, keyed by the zoo SHA; PRs restore the
newest generation for their leg by prefix. The janitor keeps one generation
per leg.
@chatgpt-codex-connector

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

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:37.604053Z
We couldn’t complete this review. Comment @codex review to try again.
d6e709d 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
danielhanchen merged commit 84a2252 into main Nov 24, 2026
@danielhanchen
danielhanchen deleted the ci-core-zoo-inductor-cache branch November 24, 2026 00:36
danielhanchen added a commit that referenced this pull request Nov 24, 2026
)

## Problem

Since #19126 added a restored Inductor cache to Core zoo, almost every
Core zoo leg on a PR has failed. Over the last day: 20 failed runs
against 33 green, with the failures starting right after #19126 merged.
In the failing jobs 12 to 17 pytest workers die inside compiled kernels:

```
free(): invalid pointer
Fatal Python error: Aborted
  File "/home/runner/work/_temp/inductor-cache/lu/clufi3ej....py", line 596 in call
  File ".../torch/_inductor/output_code.py", line 638 in __call__
```

(some legs show `*** buffer overflow detected ***` instead), and xdist
then ends the session with `INTERNALERROR ... KeyError:
<WorkerController gwN>`.

## Cause

- Every crashing job restored a `zoo-inductor-v1-*` cache. The four
failing jobs that ran without one (before the first save, or on a miss)
had no worker crash.
- The cache is good on the machine that built it. The main push that
saved `zoo-inductor-v1-t4576-trl0latest-...-a9f1c604...` at 16:04 ran
the suite green with it; #19286 restored that exact key a few minutes
later and lost 4 workers.
- Locally, the crashing files (`test_frozen_table_store.py`,
`test_tiling_inductor_short_tail.py`,
`test_moe_stacked_expert_lora_reaches_forward.py`,
`test_cpu_ce_compile.py`, `test_grpo_rollout_correction.py`,
`test_moe_swap_weights_restores_parameters.py`) run cold, warm and warm
again against one cache dir on one machine with 291 passed in all three
arms.

Inductor builds CPU kernels with `-march=native`, and its own cache key
does not name the CPU. GitHub's `ubuntu-24.04` pool mixes Intel Xeon and
AMD EPYC generations, so a cache saved on one model was being handed to
PRs on another. #19126's A/B ran cold and warm on the same runner, which
could not see this.

## Fix

- The `inductor-stack` hash now also covers `gcc -march=native -Q
--help=target`, the target gcc actually resolves for `-march=native`. A
cache is restored only on the CPU target that built it; another model
misses cleanly and runs cold. If gcc prints nothing the step fails
instead of keying without the CPU.
- The step prints the runner's CPU model and resolved `-march`, so a
future crash can be matched to the runner it came from.
- The key prefix moves from `zoo-inductor-v1-` to `zoo-inductor-v2-`, so
none of the existing entries are restored again.
- `cache-janitor.yml`: comment only; the `zoo-inductor-*` family rule
already strips just the trailing zoo SHA.

## Test

`tests/studio/test_zoo_inductor_cache_is_cpu_keyed.py`:

- the restore key, the restore prefix and the save key all carry the
stack hash, the save key equals the restore key, and no
`zoo-inductor-v1-` key remains;
- runs the real `inductor-stack` step in bash with a stub `gcc` and
`python`: two CPU targets give two different stack hashes, the same
target gives the same hash, and an empty `gcc` answer fails the step
without writing a key.

On the old workflow all three tests fail; with the change, 3 passed.
Every test that reads `consolidated-tests-ci.yml` or
`cache-janitor.yml`: 315 passed, 4 skipped.

## Follow up

This PR's own Core zoo legs run cold, since no v2 entry exists yet.
After it merges, main pushes save one v2 generation per CPU target as
they go green. If a PR leg still loses workers after restoring a v2
entry, the printed CPU line will show whether it matched the saver, and
the restore should then be dropped rather than keyed further.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant