Skip to content

Make tests/utils runnable again and cover test_packing.py in CI - #7642

Merged
danielhanchen merged 2 commits into
mainfrom
fix/tests-utils-fake-config-to-dict
Jul 30, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
fix/tests-utils-fake-config-to-dict

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

tests/utils/test_packing.py and test_qat.py are not run by any workflow, and both had drifted to the point where they fail on a correctly provisioned checkout. This makes them pass again and wires the packing suite into CI so it cannot drift back.

Before, on a clean main with the deps CI installs: 25 failed, 99 passed. After: 121 passed, 4 skipped.

Fake configs need to_dict(). get_transformers_model_type() resolves the config through to_dict(), which SimpleNamespace does not have, so 19 tests died on TypeError: Unsloth: Cannot determine model type for config file: namespace(...). There was already a local _WarnConfig subclass in this file working around exactly this for two tests. Promoted it to a shared _FakeConfig used by all nine fake configs and removed the duplicate.

torchao is optional, so skip rather than fail. The module caught ImportError, printed a hint, and then every one of the 4 tests failed on the missing name. Replaced with pytest.importorskip("torchao.quantization.qat").

Two tests need an accelerator. test_enable_sample_packing_trl_collator and test_packing_sdpa build a real model and raise RuntimeError: No CUDA GPUs are available on a CPU runner, so they get a skipif. Verified both ways: CPU-only gives 49 passed / 2 skipped, with GPUs 51 passed.

CI. Added tests/utils/test_packing.py to the Bucket-A CPU job and the collection sanity check. That job already installs bitsandbytes>=0.45, which is what the suite needs. test_qat.py is left out on purpose since torchao is not installed there and it would only ever report skips.

No production code changes: tests/ and one workflow list.

@danielhanchen
danielhanchen merged commit 5017a61 into main Jul 30, 2026
13 of 15 checks passed
@danielhanchen
danielhanchen deleted the fix/tests-utils-fake-config-to-dict branch July 30, 2026 10:16

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b6cb15419f

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

Comment on lines +985 to +987
@pytest.mark.skipif(
not torch.cuda.is_available(), reason = "builds a real 4bit model on an accelerator"
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep accelerator packing tests enabled on XPU

On an Intel XPU host, torch.cuda.is_available() is false, so pytest skips this test before its explicit torch.xpu.is_available() branch can select the XPU device; the identical decorator on test_packing_sdpa has the same problem. This removes both packing checks from XPU validation even though the setup supports XPU, so the skip condition should require that neither CUDA nor XPU is available.

Useful? React with 👍 / 👎.

Comment thread tests/utils/test_qat.py
Comment on lines +10 to +13
pytest.importorskip(
"torchao.quantization.qat",
reason = "install or upgrade with: pip install 'torchao>=0.15.0'",
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip QAT tests only when TorchAO is absent

With the workflow-pinned pytest 9.0.3, importorskip catches any ImportError raised while importing this installed submodule, not just a missing TorchAO package. If an installed TorchAO build is incompatible with the current PyTorch version or has a broken dependency, the entire QAT suite is therefore reported as skipped instead of exposing the compatibility failure; check that the optional package is absent first, then import the QAT API normally so failures from an installed package remain test failures.

Useful? React with 👍 / 👎.

danielhanchen added a commit that referenced this pull request Jul 30, 2026
…lpers (#7645)

#7188 added three bare exits to studio/setup.sh and three to studio/setup.ps1
for the explicit-Vulkan paths. Bare exits skip setup_fail / Exit-SetupFailure,
so the [TAURI:ERROR] line that #7529 added never reaches Studio desktop and a
Vulkan install failure shows up there with no actionable context.

tests/sh/test_tauri_retry_failure_context.sh already asserts that each setup
script has exactly one explicit exit and that it lives inside the helper. That
assertion was failing, but the failure was invisible: Backend CI skips the
Shell installer tests step whenever the auto-discovered pytest step fails
first, and it had been failing on an unrelated encoding assertion until #7642.

Exit codes are unchanged: setup_fail 1 and Exit-SetupFailure both exit 1, and
the Tauri line is still emitted only when UNSLOTH_TAURI_MODE is set.
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