Skip to content

tests: skip two version_compat suites where the daily sweep has no torch - #12274

Merged
danielhanchen merged 3 commits into
unslothai:mainfrom
Sletch:fix/version-compat-sweep-skips-without-torch
Oct 5, 2026
Merged

danielhanchen merged 3 commits into
unslothai:mainfrom
Sletch:fix/version-compat-sweep-skips-without-torch

Conversation

@Sletch

@Sletch Sletch commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Follows up #12069 and #12088.

The failure

Version Compat CI's daily fresh-fetch sweep (cron only) has failed on every scheduled run since #12069 merged (2026-09-27 05:15 UTC). It passed every day from 09-20 to 09-26.

scheduled run commit sweep
09-26 06:56 UTC f442c7abf success
09-27 06:58 UTC 08f3dff19, the first with #12069 failure, exit 1; its log has expired
09-28 07:13 UTC 8fb2fa34d 43 failed, 1867 passed, 239 skipped
09-29 07:03 UTC 6c20f0fac 43 failed, 1867 passed, 240 skipped

All 43 are in two files, 41 in test_trl_config_defaults_contract.py and 2 in test_pref_max_length_clamp.py, and each one stops at the same line:

unsloth/__init__.py:1607: in <module>
    from ._gpu_init import *
unsloth/_gpu_init.py:15: in <module>
    import numpy as np
E   ModuleNotFoundError: No module named 'numpy'

Why

The sweep installs nothing but pytest, then runs the whole directory:

      - name: Install pytest
        run: pip install 'pytest>=8'
      ...
          PYTHONPATH=. python -m pytest \
            tests/vllm_compat/test_vllm_pinned_symbols.py \
            tests/version_compat/ \

The other suites there that need torch skip in that job, eight of them on a module-scope find_spec("torch") guard. Two carry the reason beside it (test_trl_loss_normalization_contract.py:43):

# daily-fresh-fetch collects this directory with only pytest installed.
if importlib.util.find_spec("torch") is None:
    pytest.skip("torch not installed", allow_module_level = True)

The two files #12069 added, and #12088 extended, have no guard. They are wired into grpo-fake-run, which installs torch and TRL, and they pass there: on 6c20f0fac the contract file ran 39 passed and 2 skipped, and the clamp file 9 passed, in each TRL step. The sweep collects them too, and there every import unsloth fails.

The change

  • test_trl_config_defaults_contract.py: every test imports unsloth, so the file takes its neighbours' guard at module scope.
  • test_pref_max_length_clamp.py: seven of its tests read rl.py as text and pass in the sweep today, so only test_patched_trainer_carries_the_clamp, which imports unsloth and trl, is guarded.
  • tests/studio/test_version_compat_bundle.py: one test, so that this class fails on the pull request that introduces it rather than on the next morning's cron.

Nothing under unsloth/ or .github/ changes.

Tests

test pins fails without the change
test_the_daily_sweep_skips_what_it_cannot_import every suite the sweep collects outside the pinned-symbol bundle skips or passes with torch, numpy, transformers, trl, peft, accelerate and unsloth_zoo hidden. A None entry in sys.modules makes import raise and find_spec answer None, as they do in the sweep yes, with the sweep's 43 failures inside it

It sits beside the other assertions about this workflow. workflow-trigger-lint.yml runs that file on every pull request, with no path filter and nothing installed but pytest, PyYAML, xdist and vermin. The bundle's own suites are left out: they install nothing by construction, already run on every pull request, and fetch from the network.

Verified

Each row was run on main 2033855cd and on this branch.

run main this branch
daily-fresh-fetch, reproduced: Python 3.12.14, pip install 'pytest>=8' (pytest 9.1.1), then its pytest line 43 failed, 1867 passed, 240 skipped: the same 43 test ids as CI's run on 6c20f0fac 0 failed, 1867 passed, 243 skipped. The passed set is identical by id; the new skips are the contract module and the two clamp tests
grpo-fake-run, reproduced: its install lines (CPU torch 2.10.0, TRL 1.14.0 as CI resolved on 09-29, unsloth-zoo main), its env and its pytest line 263 passed, 2 skipped the same, identical by id. The two files still run 39 passed + 2 skipped, and 9 passed
test_version_compat_bundle.py, -n 4, workflow-trigger-lint's install 1 failed, 5 passed 6 passed
the same file with torch and TRL installed (Linux and Windows) 1 failed, 5 passed 6 passed
workflow-trigger-lint's whole guard step, its install 1 failed, 2789 passed, 164 skipped 1 failed, 2790 passed, 164 skipped. The one failure is the same test on both: test_release_desktop_appimage.py::test_apprun_falls_back_to_the_shipped_font_policy_when_it_cannot_write
ruff check 0.15.18 and scripts/run_ruff_format.py on the three files clean, no bytes changed

One consequence worth naming

The new test starts a second pytest, so it adds about 2 s wherever this file runs: 2.0 s measured in workflow-trigger-lint's environment, 1.8 s with torch installed.

Not in scope

  • CRON_ONLY in test_version_compat_bundle.py says its two suites are "checked daily rather than never". In the sweep neither runs its real check: test_trl_vllm_generation_lora_patch.py skips at module scope (torch not installed; this test drives the real patch), and test_importing_the_cpu_modules_leaves_torch_globals_alone skips (torch not installed; there is no global state to protect). No other job names either file, so today both checks run nowhere. Where they should run is a CI decision, so this leaves them alone.
  • The three suites Lift the transformers ceiling to 5.17.0 and align the mirrored CI caps #11016 adds to this directory were run without torch: its two import-guarded suites skip (needs unsloth: No module named 'numpy'), and its dtype-kwarg check imports only ast, pathlib and pytest. None of them would fail the new test for want of torch.

daily-fresh-fetch in version-compat-ci.yml runs all of tests/version_compat/
after installing nothing but pytest. The other suites there that need torch
skip in that job, eight of them on a module-scope find_spec("torch") guard, and
two of those say why: "daily-fresh-fetch collects this directory with only
pytest installed." test_trl_config_defaults_contract.py (unslothai#12069, unslothai#12088) and
test_pref_max_length_clamp.py (unslothai#12069) have no guard. They pass in
grpo-fake-run, which installs torch, and in the sweep every `import unsloth`
stops at unsloth/_gpu_init.py's `import numpy`.

The sweep passed daily up to 2026-09-26 and has failed daily since unslothai#12069
merged: 43 failed on 09-28 and 09-29, all 43 in these two files on that
ModuleNotFoundError. The 09-27 run exited 1 and its log has expired.

The defaults contract imports unsloth in every test, so it takes its
neighbours' guard at module scope. In the clamp file seven tests read rl.py as
text and still run in the sweep, so only test_patched_trainer_carries_the_clamp,
which imports unsloth and trl, is guarded.

test_the_daily_sweep_skips_what_it_cannot_import runs every suite the sweep
collects outside the pip-free bundle in a subprocess with torch, numpy,
transformers, trl, peft, accelerate and unsloth_zoo hidden, and fails on any
test that fails rather than skips. workflow-trigger-lint runs that file on
every pull request with no torch installed, so a suite added without the guard
now fails its own pull request instead of the next morning's cron. It fails on
main with the sweep's 43 tests and passes here.

One consequence worth naming: the new test adds about 2 s to
workflow-trigger-lint on every pull request, measured in that job's environment.
@danielhanchen danielhanchen self-assigned this Oct 5, 2026
@danielhanchen

Copy link
Copy Markdown
Member

Review record for #12274, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#412.

Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found.

Round 1: reviewed mirror df63b53e4b (this PR's 22030733c)

chatgpt-codex-connector[bot] (on the mirror)

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: df63b53e4b

No triage reaction was recorded on the mirror

Verdict

The round converged at mirror df63b53e4b (this PR's 22030733c).

This is the review as it stood at that commit. Anything pushed to this PR afterwards was not part of it.

@danielhanchen
danielhanchen merged commit 735b9e4 into unslothai:main Oct 5, 2026
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.

2 participants