Repository navigation
tests: pin the amd/huggingfacenotorch extras and name the audit failure - #7536
Conversation
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.
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
|
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: Also corrected the same over-attribution inside the test that I corrected in the extra itself. The While resolving that I took pre-commit.ci's reformat of the same assertion ( Still stacked on #7535 — retarget to 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 |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
|
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 afterBefore: After: the lookup raises a named So: real issue, and the right shape of fix. What I changed1. It guarded one extra out of five. Main now indexes 2. The test could not see the loop. Its regex only matched the literal 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 names3. Two tests added: that the extras the scan set is built from are still named in 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 anythingNo. This PR touches only What I could not answerWhether the |
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.
|
Follow-up: running the full
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 ( For the record, the same file has two failures that are already on main and are nothing to do with this PR:
Both reproduce on a clean |
|
@codex review |
|
@codex security review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
💡 Codex Reviewunsloth/tests/python/test_amd_extras_contract.py Lines 93 to 95 in 949fd65 If the AMD requirement is changed to something like ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
The security-audit workflow now passes end to end on this branch. Run 34821878451, every job green: Those On the red checks that remainThree They fail inside The same workflow is 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. |
There was a problem hiding this comment.
💡 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".
| @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] |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
|
Re-validated on current main (1e07231) with the branch merged. One comments-only commit pushed today. Before and afterBefore: After: the lookup raises a named Second pass: the guard test
EvidenceMutation: deleting Real hardware, self-hosted gfx1151 Linux, 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 ( 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. |
…the guard test for PR #7536
…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.
…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]>
…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.
Stacked on #7535 — base is
fix/main-amd-bnb-floor, so the bnb floor assertion is green. Retarget tomainonce that merges.What
A contract test for the
amd/huggingfacenotorchextras, plus a readable failure insecurity-audit.yml. Two files, +118/-2.Why
security-audit.ymlbuilds its hf-stack scan set by indexing[huggingfacenotorch]straight out ofpyproject.toml, at:231and:824, with no guard. Thepiprelease branch never carried that extra, soadvisory auditand the threepip scan-packagesjobs died on a bareKeyError: '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
KeyErrorin 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:amdpullsunsloth[huggingfacenotorch]huggingfacenotorchnames no torch distribution, which is the entire point of itbitsandbytesmarker line inamdexcludes 0.49.2 and admits 0.50.0 — parsed withpackaging, not string-matched, so a reworded specifier still gets checkedsecurity-audit.ymlindexes actually exists inpyproject.tomlThat last one is the generic form of the bug and the one I care most about. The workflow reaches into
pyproject.tomlby 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.
KeyErrorbecomes aSystemExitnaming the missing extra and what it broke. Verified against a stubpyproject.tomlwith 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:
upstream/main: the floor assertion fails, since>=0.49.1admits 0.49.2 on both marker linesupstream/pip: the existence assertions and the workflow-sync assertion fail, since neither extra is theresecurity-audit.ymlstill 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 onpipand not onmain. This PR targetsmainper the usual flow, sopippicks it up on the next main merge. If you would rather have the release branch covered immediately, this wants a companion PR againstpip— say the word and I will open it.