Skip to content

tests: pin the amd/huggingfacenotorch extras and name the audit failure - #7536

Merged
danielhanchen merged 19 commits into
mainfrom
fix/main-extras-guard
Sep 15, 2026
Merged

danielhanchen merged 19 commits into
mainfrom
fix/main-extras-guard

Conversation

@LeoBorcherding

Copy link
Copy Markdown
Collaborator

Stacked on #7535 — base is fix/main-amd-bnb-floor, so the bnb floor assertion is green. Retarget to main once that merges.

What

A contract test for the amd / huggingfacenotorch extras, plus a readable failure in security-audit.yml. Two files, +118/-2.

Why

security-audit.yml builds its hf-stack scan set by indexing [huggingfacenotorch] straight out of pyproject.toml, at :231 and :824, with no guard. The pip release branch never carried that extra, so advisory audit and the three pip scan-packages jobs died on a bare KeyError: 'huggingfacenotorch' before scanning anything — confirmed on runs 28951127835 (2026-07-08), 29998087676 (07-23) and 30272147669 (07-27), four jobs each, same traceback.

Three weeks of no supply-chain scanning on the release branch, and nothing caught it. Not because the job was silent — it was red the whole time — but because a bare KeyError in an inline heredoc reads as a generic Python crash rather than "an extra is missing". #7278 fixed it by side effect, as a consequence of adding the extra for unrelated reasons.

The test

tests/python/test_amd_extras_contract.py:

  • both extras exist, and amd pulls unsloth[huggingfacenotorch]
  • huggingfacenotorch names no torch distribution, which is the entire point of it
  • every bitsandbytes marker line in amd excludes 0.49.2 and admits 0.50.0 — parsed with packaging, not string-matched, so a reworded specifier still gets checked
  • every extra security-audit.yml indexes actually exists in pyproject.toml

That last one is the generic form of the bug and the one I care most about. The workflow reaches into pyproject.toml by name, so any rename or omission takes out the scan jobs, and the test now fails on the branch that caused it rather than in a security job three weeks later.

The workflow change

Same exit code, better message. KeyError becomes a SystemExit naming the missing extra and what it broke. Verified against a stub pyproject.toml with no such extra: prints the message, exits 1, writes nothing to stdout, so no partial requirements file is generated.

Verification

7 passed on this branch. I also checked the tests actually bite rather than assuming they do:

  • against upstream/main: the floor assertion fails, since >=0.49.1 admits 0.49.2 on both marker lines
  • against upstream/pip: the existence assertions and the workflow-sync assertion fail, since neither extra is there

security-audit.yml still parses as YAML after the edit.

Note on branch placement

The closest precedent for this kind of test, tests/studio/install/test_studio_extra_matches_requirements.py, currently lives only on pip and not on main. This PR targets main per the usual flow, so pip picks it up on the next main merge. If you would rather have the release branch covered immediately, this wants a companion PR against pip — say the word and I will open it.

bnb <= 0.49.2 NaNs at decode shape on every AMD GPU. The ROCm 4-bit GEMV
fix (bnb PR #1887) first ships in 0.50.0, on PyPI since 2026-07-24, so the
old >=0.49.1 floor could still resolve the broken range.

Mirrors the same change made on the pip release branch in #7278.
security-audit.yml builds its hf-stack scan set by indexing
[huggingfacenotorch] out of pyproject.toml with no guard. The pip release
branch never had that extra, so advisory audit and the three pip
scan-packages jobs died on a bare KeyError from at least 2026-07-08 to
2026-07-27 without anyone reading it as a missing extra.

Add a contract test for both extras (existence, torch-free, bnb floor
excludes the NaN-at-decode range) plus a check that every extra the
workflow indexes actually exists, and give the workflow a message that
names the problem instead of a raw traceback.
pre-commit-ci Bot and others added 5 commits July 28, 2026 05:44
The comment credited bnb PR #1887 as "the ROCm 4-bit GEMV fix" for every
AMD GPU. #1887 decouples blocksize from warp size and fixes a hardcoded
warp size of 32 in kgemm_4bit_inference_naive, which is a CDNA problem by
construction. The RDNA-side work is #1979 (fused 4-bit SIMT GEMM) and
#2012 (RDNA3/4 workgroup resonance). All three first ship in 0.50.0, so
the >=0.50.0 floor is unchanged; only the justification was wrong.
Drops the unverified "NaNs on every AMD GPU" phrasing and the single-PR
attribution from the test's comments and assertion message. The floor
itself is unchanged.
# Conflicts:
#	tests/python/test_amd_extras_contract.py
@LeoBorcherding

LeoBorcherding commented Jul 28, 2026 •

Copy link
Copy Markdown
Collaborator Author

Two housekeeping commits, no change to what this PR asserts.

Merged the updated base in, so the corrected bnb floor comment arrives from #7535 rather than appearing as a reverse diff here. The diff against base is unchanged in substance: .github/workflows/security-audit.yml and tests/python/test_amd_extras_contract.py.

Also corrected the same over-attribution inside the test that I corrected in the extra itself. The BNB_MIN comment, the TestAmdBitsandbytesFloor docstring, and the assertion message all said bnb <=0.49.2 "NaNs at decode shape on every AMD GPU" and credited bitsandbytes#1887 as the fix. bitsandbytes#1887 is CDNA-oriented — it fixes a hardcoded warp size of 32 in kgemm_4bit_inference_naive, which is wrong on CDNA (warp=64) and correct on RDNA (warp=32). The RDNA work in 0.50.0 is bitsandbytes#1979 and bitsandbytes#2012. All three first ship in 0.50.0, so BNB_MIN is unchanged; only the justification was wrong. I also never verified the "every AMD GPU" claim myself, so the wording no longer makes it.

While resolving that I took pre-commit.ci's reformat of the same assertion (54147dd) and kept its layout with the corrected message.

Still stacked on #7535 — retarget to main once that merges.

On sourcing, since bare numbers were the wrong way to cite this: all three are AMD's own ROCm work in bitsandbytes, authored by sstamenk, and the 0.50.0 release notes say it plainly: "Stability and performance improvements bring AMD ROCm support out of preview; it is now considered stable." That page is the citation I should have led with.

Edited: the bnb references above were bare #NNNN, which GitHub autolinked to unrelated unslothai/unsloth issues rather than the bitsandbytes PRs. Now full URLs.

Base automatically changed from fix/main-amd-bnb-floor to main July 29, 2026 01:12
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: df00cb05c1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@LeoBorcherding LeoBorcherding self-assigned this Jul 31, 2026
@danielhanchen

Copy link
Copy Markdown
Member

Reviewed this with the other open AMD PRs. Real issue, and I have pushed a commit that resolves the conflict with main and widens the fix, because as written it covered one of five cases. Details below.

Before and after

Before: .github/workflows/security-audit.yml indexes pyproject.toml's optional dependency groups by literal name. When a group gets renamed or removed, the lookup raises a bare KeyError inside a workflow step. Four pip scan-packages jobs died with a traceback that says nothing about the actual cause. That is not hypothetical, it is what the red CI on this PR is.

After: the lookup raises a named SystemExit that says which extra went missing and where to fix it, plus contract tests that fail in the repo's own suite before CI ever gets a chance to.

So: real issue, and the right shape of fix.

What I changed

1. It guarded one extra out of five. Main now indexes huggingfacenotorch, audio-torch211, and then audio-torch210, audio-torch290 and audio-torch280 through a dynamic for extra in ...; do loop. The PR guarded only the first. I generalised the guard into a local extra(name) helper used by both literal lookups, and wrapped the loop body's dynamic index in try/except KeyError. Coverage goes from 1 extra to all 5.

2. The test could not see the loop. Its regex only matched the literal optional-dependencies"]["NAME"] form, so the three extras named in the for loop were invisible to it, and after my refactor it matched nothing at all and its own non-vacuity assert fired. Rewrote it to find all three index shapes:

def _extras_referenced_by_the_audit_workflow() -> set[str]:
    source = SECURITY_AUDIT.read_text(encoding = "utf-8")
    names = set(re.findall(r'optional-dependencies"\]\["([^"]+)"\]', source))
    names |= set(re.findall(r'\bextra\("([^"]+)"\)', source))
    for listed in re.findall(r"^\s*for extra in ([^;]+); do\s*$", source, re.MULTILINE):
        names |= {word for word in listed.split() if word}
    return names

3. Two tests added: that the extras the scan set is built from are still named in pyproject.toml, and that every lookup in the workflow is guarded (allowlisting only the two deliberately guarded lines, so a new unguarded lookup fails the suite).

7 tests to 10, all passing. I then mutated the fix back four ways (drop the guard, rename an extra, remove a loop entry, unguard one line) and all four were caught. A test that passes on the mutant proves nothing, so that check mattered here.

Does it break anything

No. This PR touches only .github/workflows/security-audit.yml and its test. Nothing in the installer, the runtime, or Studio. For completeness I still ran it through the 49-cell [Linux, Windows, WSL, macOS] x [NVIDIA, AMD, CPU, XPU, MLX] installer matrix: output identical to main in all 49 cells, as expected for a CI-only change.

What I could not answer

Whether the pip scan-packages jobs go green is only observable once this lands and CI runs against main's current pyproject.toml. The contract tests will now say so locally instead of failing opaquely in a workflow, which is the actual improvement.

test_security_audit_covers_every_installable_torchcodec_line asserts that both
halves of security-audit.yml index the audio-torch211 extra, by counting the
literal subscript. Routing the lookups through the guarded extra() helper drops
that count to zero and fails a test that is really about coverage, not spelling.

Count either shape. A lookup that names a group the workflow no longer indexes
still fails the assertion, which is what it is there to catch.
@danielhanchen

Copy link
Copy Markdown
Member

Follow-up: running the full tests/python suite on a tree with all the mergeable AMD PRs applied turned up one regression caused by my own commit above, and I have pushed the fix in c13f35b.

tests/python/test_torchcodec_torch_compat.py::test_security_audit_covers_every_installable_torchcodec_line asserts that both halves of security-audit.yml index the audio-torch211 extra, and it does that by counting the literal subscript optional-dependencies"]["audio-torch211"]. Routing those lookups through the guarded extra(name) helper drops that count from 2 to 0, so the test failed on a change it should not care about: it is asserting coverage, not spelling.

The fix counts either shape:

    indexed = text.count('optional-dependencies"]["audio-torch211"]') \
        + text.count('extra("audio-torch211")')
    assert indexed == 2, f"both halves must index audio-torch211, found {indexed}"

I checked it is still a real assertion rather than a weakened one: pointing one lookup at a group that does not exist (audio-torch999) fails it, and restoring it passes.

For the record, the same file has two failures that are already on main and are nothing to do with this PR:

  • test_a_mismatched_accelerator_build_is_named_when_the_codec_cannot_load
  • test_the_provenance_hint_reads_a_codec_it_cannot_import

Both reproduce on a clean main checkout at 289e0df. With the repair above, this branch's result on that file is identical to main's: the same 2 failures, 94 passed. I have not touched them here since they belong with the torchcodec work, but they should be looked at separately.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@danielhanchen

Copy link
Copy Markdown
Member

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-15T13:35:41.011342Z 8794081 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

assert not allowed.contains(
Version("0.49.2")
), f"{requirement} still admits bnb 0.49.2, which predates the ROCm 4-bit fixes"

P2 Badge Enforce the entire broken bitsandbytes range

If the AMD requirement is changed to something like bitsandbytes>=0.49.1,!=0.49.2, this test still passes because 0.49.2 is rejected and 0.50.0 is admitted, even though the requirement continues to admit the unsupported 0.49.1 release. Since the stated contract is that every pre-0.50.0 version is excluded, validate the effective lower bound against BNB_MIN rather than testing only one representative version.

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

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 14, 2026
@danielhanchen

Copy link
Copy Markdown
Member

The security-audit workflow now passes end to end on this branch. Run 34821878451, every job green:

success  advisory audit (pip + npm + cargo)
success  npm provenance + new install-script diff
success  npm scan-packages (Unsloth frontend tarballs)
success  pip scan-packages :: audio-torch280
success  pip scan-packages :: audio-torch290
success  pip scan-packages :: extras
success  pip scan-packages :: hf-stack
success  pip scan-packages :: studio

Those pip scan-packages legs are the ones that were dying on the bare KeyError, so this is the claim confirmed rather than argued.

On the red checks that remain

Three Core jobs are failing and they are not this PR:

Core (HF=4.57.6 + TRL<1)
Core (HF=default + TRL=default)
Core (HF=latest + TRL=latest)

They fail inside unsloth_zoo @ main - full pytest (CPU), on allocator configuration:

assert conf["PYTORCH_CUDA_ALLOC_CONF"] is not None
E  AssertionError: {'PYTORCH_ALLOC_CONF': None, 'PYTORCH_CUDA_ALLOC_CONF': None, 'PYTORCH_HIP_ALLOC_CONF': None}

The same workflow is failure on main itself (run 34820611889), and this PR touches only .github/workflows/security-audit.yml plus two test files, so it cannot reach unsloth_zoo's allocator handling. Pre-existing and unrelated, worth a separate look but not a blocker here.

For completeness on the non-AMD question I raised in the earlier comment: this branch is byte-identical to main in all 57 cells of the installer matrix ([Linux, Windows, WSL, macOS] x [NVIDIA, AMD, CPU-only, Intel XPU, Apple MLX] x [normal, absent, fails, empty, hangs]), which is what you would expect from a CI-only change, and is the control that says so rather than assuming it.

@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: 10b5035363

ℹ️ 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 +78 to +80
@pytest.mark.parametrize("banned", ["torch", "torchvision"])
def test_no_torch_distribution(self, banned: str):
named = [s for s in _extras()["huggingfacenotorch"] if _project_name(s) == banned]

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 Include torchaudio in the no-torch ban

When huggingfacenotorch is later given a direct torchaudio requirement—particularly a pre-2.11 range whose metadata pulls in torch—this test still passes even though installing the purported no-torch extra can resolve PyTorch. The repository's installer logic consistently treats torch, torchvision, and torchaudio as the companion trio, so the contract should ban torchaudio alongside the other two.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not taking this one. huggingfacenotorch has never listed torchaudio and the audio extras carry it on purpose; the ban covers what the extra's name promises, and widening it to a package that is not there is coverage for its own sake.

danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 15, 2026
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 15, 2026
danielhanchen added a commit to Datta0/unsloth-staging-3 that referenced this pull request Sep 15, 2026
@danielhanchen

Copy link
Copy Markdown
Member

Re-validated on current main (1e07231) with the branch merged. One comments-only commit pushed today.

Before and after

Before: .github/workflows/security-audit.yml indexes pyproject.toml's optional dependency groups by literal name, so a renamed or removed extra dies on a bare KeyError inside a workflow step, which is how four pip scan-packages jobs stayed red without saying why.

After: the lookup raises a named SystemExit that says which extra is missing, for all five extras the workflow indexes, plus contract tests that fail in the repository's own suite before CI gets a chance to.

Second pass: the guard test

test_every_lookup_is_guarded allowlisted the two guarded statements by their text, so deleting the try/except around either of them still passed. It now parses every python <<'PY' heredoc in the workflow and requires each optional-dependencies subscript to sit inside a try node; removing the guard around the per-extra loop lookup fails it with the offending expression named. A second pass caught that the extraction only matched the quoted <<'PY' form and missed the two unquoted <<PY blocks; it now takes both, nine blocks in all. The extra-name extractor walks the same AST, so a lookup keyed with single quotes is found too, and .github/workflows/security-audit.yml is now in Backend CI's pull_request path filter, so a PR that edits only the audit workflow runs this contract before merge instead of after.

Evidence

Mutation: deleting huggingfacenotorch or audio-torch211 from a copy of pyproject.toml and running the workflow's inline Python produces pyproject.toml has no [<name>] extra, so the hf-stack scan set cannot be built and exit 1, rather than a traceback.

Real hardware, self-hosted gfx1151 Linux, tests/python/test_amd_extras_contract.py and test_torchcodec_torch_compat.py, base versus head: NO_REGRESSION. The two failures at both states (test_a_mismatched_accelerator_build_is_named_when_the_codec_cannot_load, test_the_provenance_hint_reads_a_codec_it_cannot_import) pre-date this branch and belong with the torchcodec work.

Re-run on the final head with the AST-based test: base 94 passed and 2 failed, head 104 passed and 2 failed, the same two, NO_REGRESSION. Hosted runners (ubuntu-latest, macos-15, windows-latest): STAGING_R2_7536.

The branch changes no installer or runtime file: the installer matrix is byte-identical to main in all 183 cells, and the local shell, install and python suites have the same failing-ID sets as main. The security-audit workflow itself runs green on this branch.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 15, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 15, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 15, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 15, 2026
@unslothai unslothai deleted a comment from LeoBorcherding Sep 15, 2026
@danielhanchen
danielhanchen merged commit d601e5c into main Sep 15, 2026
24 of 26 checks passed
@danielhanchen
danielhanchen deleted the fix/main-extras-guard branch September 15, 2026 13:54
danielhanchen added a commit to Etherll/unsloth that referenced this pull request Sep 15, 2026
…ain (unslothai#11019)

main is not formatted the way its own pre-commit hook formats. Running
scripts/run_ruff_format.py with the pinned ruff 0.6.9 over every file the hook
selects changes three files on 52fb7b0:

    studio/backend/tests/test_diffusers_prewarm.py   (unslothai#10989)
    studio/backend/utils/torch_warmup.py             (unslothai#10989)
    tests/python/test_amd_extras_contract.py         (unslothai#7536)

Both of those PRs merged in the last hour with `pre-commit.ci - pr` in ERROR.

That is not only a tidiness problem, because it takes pre-commit.ci's autofix
down for every OTHER pull request. The hook runs against the PR merged with
main, so every PR's tree now contains these three files needing reformatting;
the autofix patch is computed over them and then cannot be applied to a head
that does not carry main's copy. Three PRs are red on exactly that, each with a
one-or-two-line formatting delta it cannot self-heal, all reporting:

    a conflict occurred when applying fixes to the pr.
    try pulling the upstream branch

So this is self-sustaining: unformatted code on main disables the autofix, and
PRs then merge red because nothing can push the fix for them.

The formatter, not the code, is the thing to trust here: it is pinned in
.pre-commit-config.yaml, and it is idempotent. Running it again over these files
changes nothing on the second or third pass, so this is a fixed point rather
than one step of a moving target. One hunk expands a short signature, which
looks wrong until you see why: the hook rewrites `path=None` to `path = None`
first, and the longer line then no longer fits.

Nothing but whitespace: comment_tools.py check --strict-ext reports 3/3 OK, so
every AST is unchanged. test_diffusers_prewarm.py 28 passed,
test_amd_extras_contract.py 10 passed. Re-running the hook over the whole tree
afterwards touches these three files and nothing else.
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…re (unslothai#7536)

* amd: require bitsandbytes>=0.50.0 in the amd extra

bnb <= 0.49.2 NaNs at decode shape on every AMD GPU. The ROCm 4-bit GEMV
fix (bnb PR unslothai#1887) first ships in 0.50.0, on PyPI since 2026-07-24, so the
old >=0.49.1 floor could still resolve the broken range.

Mirrors the same change made on the pip release branch in unslothai#7278.

* tests: pin the amd/huggingfacenotorch extras and name the audit failure

security-audit.yml builds its hf-stack scan set by indexing
[huggingfacenotorch] out of pyproject.toml with no guard. The pip release
branch never had that extra, so advisory audit and the three pip
scan-packages jobs died on a bare KeyError from at least 2026-07-08 to
2026-07-27 without anyone reading it as a missing extra.

Add a contract test for both extras (existence, torch-free, bnb floor
excludes the NaN-at-decode range) plus a check that every extra the
workflow indexes actually exists, and give the workflow a message that
names the problem instead of a raw traceback.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* amd: cite the 0.50.0 ROCm work accurately in the bnb floor comment

The comment credited bnb PR unslothai#1887 as "the ROCm 4-bit GEMV fix" for every
AMD GPU. unslothai#1887 decouples blocksize from warp size and fixes a hardcoded
warp size of 32 in kgemm_4bit_inference_naive, which is a CDNA problem by
construction. The RDNA-side work is unslothai#1979 (fused 4-bit SIMT GEMM) and
unslothai#2012 (RDNA3/4 workgroup resonance). All three first ship in 0.50.0, so
the >=0.50.0 floor is unchanged; only the justification was wrong.

* tests: match the corrected bnb 0.50.0 justification

Drops the unverified "NaNs on every AMD GPU" phrasing and the single-PR
attribution from the test's comments and assertion message. The floor
itself is unchanged.

* Let the torchcodec audit contract read the guarded extra lookup

test_security_audit_covers_every_installable_torchcodec_line asserts that both
halves of security-audit.yml index the audio-torch211 extra, by counting the
literal subscript. Routing the lookups through the guarded extra() helper drops
that count to zero and fails a test that is really about coverage, not spelling.

Count either shape. A lookup that names a group the workflow no longer indexes
still fails the assertion, which is what it is there to catch.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Tighten the comments this change adds for PR unslothai#7536

* Check the extras guards structurally with an AST walk for PR unslothai#7536

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Parse the unquoted python heredocs in the guard test too for PR unslothai#7536

* Read extra names structurally and run the contract when the audit workflow changes for PR unslothai#7536

* Check the whole bitsandbytes floor and require a KeyError handler in the guard test for PR unslothai#7536

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: danielhanchen <[email protected]>
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…ain (unslothai#11019)

main is not formatted the way its own pre-commit hook formats. Running
scripts/run_ruff_format.py with the pinned ruff 0.6.9 over every file the hook
selects changes three files on 52fb7b0:

    studio/backend/tests/test_diffusers_prewarm.py   (unslothai#10989)
    studio/backend/utils/torch_warmup.py             (unslothai#10989)
    tests/python/test_amd_extras_contract.py         (unslothai#7536)

Both of those PRs merged in the last hour with `pre-commit.ci - pr` in ERROR.

That is not only a tidiness problem, because it takes pre-commit.ci's autofix
down for every OTHER pull request. The hook runs against the PR merged with
main, so every PR's tree now contains these three files needing reformatting;
the autofix patch is computed over them and then cannot be applied to a head
that does not carry main's copy. Three PRs are red on exactly that, each with a
one-or-two-line formatting delta it cannot self-heal, all reporting:

    a conflict occurred when applying fixes to the pr.
    try pulling the upstream branch

So this is self-sustaining: unformatted code on main disables the autofix, and
PRs then merge red because nothing can push the fix for them.

The formatter, not the code, is the thing to trust here: it is pinned in
.pre-commit-config.yaml, and it is idempotent. Running it again over these files
changes nothing on the second or third pass, so this is a fixed point rather
than one step of a moving target. One hunk expands a short signature, which
looks wrong until you see why: the hook rewrites `path=None` to `path = None`
first, and the longer line then no longer fits.

Nothing but whitespace: comment_tools.py check --strict-ext reports 3/3 OK, so
every AST is unchanged. test_diffusers_prewarm.py 28 passed,
test_amd_extras_contract.py 10 passed. Re-running the hook over the whole tree
afterwards touches these three files and nothing else.
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.

3 participants