Skip to content

Clear the four main CI reds blocking every open PR - #8506

Merged
danielhanchen merged 6 commits into
mainfrom
fix/prequant-allowlist-tests
Aug 12, 2026
Merged

danielhanchen merged 6 commits into
mainfrom
fix/prequant-allowlist-tests

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Backend CI has been red on main all day. Every completed run since 16:04 UTC has failed, so every open PR is blocked on reds it did not cause. Two independent causes, one commit each.

The pre-quant allowlist tests need a torchao the CI image does not have

19 tests in studio/backend/tests/test_diffusion_prequant.py fail on assert None is not None, and one on this torch cannot register the pre-quant constructor allowlist.

The allowlist itself is fine. _register_prequant_safe_globals refuses unless _prequant_safe_globals can actually import torch.torch_version.TorchVersion plus at least one real torchao class. The Backend tests job installs torch 2.10.0+cpu and transformers and no torchao at all, so nothing resolves, every load refuses, and every assertion about the loader lands on the refusal instead. The tests also swap sys.modules["torch"] for a bare module while a load runs, so even torch.torch_version is unimportable at that moment, torchao or no torchao.

The file's own header already says these tests run "without CUDA, torchao, or a real diffusers model", so this restores what was intended. An autouse fixture stands in for the entries the host could not import and leaves the rest alone, so a host that does have torchao still tests the real classes.

Standing in everywhere would hide the thing being stood in for, so two tests keep the real gate under test:

  • test_the_registration_floor_needs_a_real_torchao asks the unpatched resolver and skips where there is no torchao to ask. AffineQuantizedTensor is already deprecated upstream (Migrating from AffineQuantizedTensor + Layouts to new structure of tensor subclasses pytorch/ao#2752), so a release that retires it should fail here rather than pass against a fabricated class.
  • test_the_registration_refuses_when_nothing_resolves pins the CI image's own situation: an install that cannot express the allowlist gets a raise and a dense fallback, never a torch.load with the restriction dropped.

One auto-switch test still expects the behaviour #8389 deliberately changed

test_an_expired_positive_hit_refreshes_before_switching passes at 77e29f4~1 and fails at 77e29f4, in isolation as well as in a full run.

#8389 made unsloth/ and -GGUF ids concrete references, which is the point of it: a wrong model name is refused rather than answered by whatever happens to be loaded. This test's scenario is exactly that shape. The index holds a stale positive for unsloth/B-GGUF, the refresh proves it is gone, the request names it anyway. A 404 is now correct and the test's "the hook returns" expectation is the stale part.

What the test is about is unchanged and still asserted: one rescan, then a re-resolve that does not rescan, no load attempted, resident model left alone. The refusal is asserted alongside those rather than the test being loosened to swallow it. The third resolve call now expected is the refusal wording asking what the resident model is, and it passes allow_scan = False, which is why the rescan count is still one.

Verification

  • tests/test_diffusion_prequant.py with torchao installed: 83 passed.
  • Same file with torchao made unimportable by a ModuleNotFoundError-raising meta_path finder, which reproduces the CI failure exactly on the merge base (19 failed): 82 passed, 1 skipped.
  • test_openai_auto_switch.py + test_stt_sidecar.py + test_diffusion_prequant.py together: 630 passed.
  • Full studio/backend/tests run in progress.

test_stt_sidecar.py::test_pending_load_can_be_cancelled_without_waiting_for_model_lock also failed in that CI run. It passes here both alone and in a full run, so I am treating it as a timing flake rather than touching it.

danielhanchen and others added 3 commits August 11, 2026 21:56
Backend CI has been red on main since the pre-quant allowlist landed. 19 tests
in studio/backend/tests/test_diffusion_prequant.py fail with

  assert None is not None

and one with "this torch cannot register the pre-quant constructor allowlist".

The cause is not the allowlist. _register_prequant_safe_globals refuses unless
_prequant_safe_globals resolves torch.torch_version.TorchVersion plus at least
one real torchao class, by actual import. The Backend tests job installs torch
2.10.0+cpu and transformers and no torchao at all, so nothing resolves, every
load refuses, and every assertion about the loader lands on the refusal instead.
The tests also swap sys.modules["torch"] for a bare module while a load runs, so
even torch.torch_version is unimportable at that moment, torchao or no torchao.

The file's own header says these tests run "without CUDA, torchao, or a real
diffusers model", so this restores what was intended rather than changing it. An
autouse fixture stands in for the entries the host could NOT import and leaves
the rest alone, so a host that has torchao still tests the real classes.

Standing in everywhere would have hidden the thing the stand-in is standing in
for, so two tests keep the real gate under test:

  test_the_registration_floor_needs_a_real_torchao asks the unpatched resolver
  and skips where there is no torchao to ask. AffineQuantizedTensor is already
  deprecated upstream (pytorch/ao#2752), so a release that retires it should
  fail here rather than pass on a fabricated class.

  test_the_registration_refuses_when_nothing_resolves pins the CI image's own
  situation: an install that cannot express the allowlist gets a raise and a
  dense fallback, never a torch.load with the restriction dropped.

Verified both ways. With torchao installed: 83 passed. With torchao made
unimportable by a ModuleNotFoundError-raising meta_path finder, which reproduces
the CI failure exactly on this branch's parent (19 failed): 82 passed, 1 skipped.
…d away

test_an_expired_positive_hit_refreshes_before_switching has failed on main since
the mistyped-GGUF-id fix landed. It passes at that commit's parent and fails at
the commit, in isolation as well as in a full run, so it is not a flake or an
ordering effect.

That fix made unsloth/ and -GGUF ids concrete references, which is the point of
it: a wrong model name is refused instead of being answered by whatever happens
to be loaded. This test's scenario is exactly that shape. The index holds a
stale positive for unsloth/B-GGUF, the refresh proves it is gone, and the
request names it anyway, so a 404 is now the correct outcome and the test's
"the hook returns" expectation is the stale part.

What the test is actually about is unchanged and still asserted: one rescan,
then a re-resolve that does not rescan, no load attempted, and the resident
model left alone. The refusal is asserted alongside those rather than the test
being loosened to swallow it. The third resolve call now expected is the
refusal wording asking what the resident model is; it passes allow_scan = False,
which is why the rescan count is still one.

Verified: tests/test_openai_auto_switch.py, tests/test_stt_sidecar.py and
tests/test_diffusion_prequant.py together, 630 passed.

@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: 3eb2dbda93

ℹ️ 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.importorskip("torchao")
resolved = {name for _obj, name in real_prequant_safe_globals()}
assert "torch.torch_version.TorchVersion" in resolved
assert [name for name in resolved if name.startswith("torchao.")], (

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 Check required constructors for each supported scheme

When a torchao release removes one required constructor but retains another—for example, dropping AffineQuantizedTensor while keeping Float8Tensor—this assertion still passes because it only requires any torchao.* name. In that situation restricted_prequant_load_supported("int8") returns false and hosted int8 pre-quantization becomes unusable, although this test was added specifically to detect constructor retirement; compare the real resolved names against the required set for each scheme expected to work.

Useful? React with 👍 / 👎.

The sentence-transformers pinned-symbol matrix is red on main:

  FAILED test_st_models_re_exports[master]
  master: ST 5.4+ layout: class Normalize not found in any of
  ['sentence_transformers/sentence_transformer/modules/normalize.py',
   'sentence_transformers/sentence_transformer/Normalize.py']

Upstream moved it to sentence_transformers/base/modules/normalize.py, which is
where the reorg has been heading: Transformer in the same table already lists
its base/modules path first.

Checked per ref rather than assumed. On master, base/modules/normalize.py has
the class and sentence_transformer/modules/normalize.py is gone; on v5.6.0 and
v5.4.1 it is the other way round. Both spellings therefore stay listed, and
every tag in ST_TAGS resolves.

Pooling is left alone. It has not moved, and listing a path that does not exist
anywhere would weaken the check rather than future-proof it.

Verified: 40 passed.
@danielhanchen danielhanchen changed the title Clear the two Backend CI reds blocking every open PR Clear the three main CI reds blocking every open PR Aug 11, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

Third red added: the sentence-transformers pinned-symbol matrix.

FAILED test_st_models_re_exports[master]
master: ST 5.4+ layout: class Normalize not found in any of
['sentence_transformers/sentence_transformer/modules/normalize.py',
 'sentence_transformers/sentence_transformer/Normalize.py']

Upstream moved it to sentence_transformers/base/modules/normalize.py, which is where the reorg has been heading -- Transformer in the same table already lists its base/modules path first. Checked per ref rather than assumed: on master base/modules/normalize.py has the class and sentence_transformer/modules/normalize.py is gone; on v5.6.0 and v5.4.1 it is the other way round. Both spellings stay listed so every tag in ST_TAGS resolves. Pooling is left alone -- it has not moved, and listing a path that exists nowhere would weaken the check rather than future-proof it. 40 passed.

One more repo-wide red is NOT in this PR because it lives in the other repository: Core (HF=latest + TRL=latest) fails on unsloth_zoo's test_real_gemma4_image_and_video_merges_still_cast_dtype. transformers reshaped the Gemma4 image merge to image_features = torch.cat(image_features, dim=0).to(inputs_embeds.device, inputs_embeds.dtype), which still casts, so the guard's substring search fired at a correct file. Fixed in unslothai/unsloth-zoo#1046.

Still unexamined, and also failing on other open PRs rather than being caused by them: Chat UI, API and Update Tests, Repo tests (CPU), pip scan-packages :: hf-stack.

@danielhanchen

Copy link
Copy Markdown
Member Author

Full studio/backend/tests run on the branch, and the identical run on merge base 4acc36b10, so the comparison is a FAILED-set diff rather than an absolute number.

failed passed errors
merge base 90 21925 89
this branch 72 21945 89

Tests failing only on this branch: none. Failing only on the merge base: 18, and they are exactly the ones this PR is about -- 17 in test_diffusion_prequant.py plus test_an_expired_positive_hit_refreshes_before_switching.

The remaining 72 are identical on both sides and are this host missing dependencies the CI image has (24 in test_diffusion_h3_trainer.py, 13 in test_rag_ingestion.py, 9 in test_dataset_check_format_missing.py, and so on). None of them are touched here, and I am drawing no conclusion from the absolute count.

One thing the diff surfaced that the isolated runs did not. This host HAS torchao, so test_diffusion_prequant.py passes on the merge base when run alone -- but 17 of its tests still fail on the merge base inside a full run. _SAFE_GLOBALS_REGISTERED is a process-global memo, so whichever test first triggers registration while sys.modules["torch"] is stubbed memoises False for every test that runs after it. The per-test reset in the new fixture fixes that ordering hazard as well as the missing-torchao case. That is why CI failed even where a targeted rerun looked clean.

test_stt_sidecar.py::test_pending_load_can_be_cancelled_without_waiting_for_model_lock, which failed in the CI run I started from, is absent from both sides here -- consistent with the timing flake I called it, and still not touched.

Repo tests (CPU) is red on main and on every open PR: 4 failed, 6084 passed.
Reproduced locally on the merge base, same four. All four are source-string
contracts that a refactor moved out from under, and in each case the behaviour
they exist to protect is intact -- checked by reading the new code, not
assumed.

settleLostGeneration: the proof that a lost POST reached the backend was an
inline knownIds set with !knownIds.has(image.id). It is now a baseline handed
to hasUnknownRecord in lib/gallery-flags.ts. Same proof through a named helper,
so the assertion follows it and also pins that the helper exists.

The GGUF footprint dedupe: effectiveRecommended went from a single quant to a
SET of them, so "is this the recommended one" is membership rather than
equality. The contract is unchanged -- the recommended quant represents its own
group when it has one -- and both halves are asserted in the new spelling. The
stale negated half is dropped rather than reworded, because
!effectiveRecommended.has(current.quant) already says it.

The provider backfill: a literal Promise.allSettled(backfillTasks) became
settleTasksIfCurrent(backfillTasks, isCurrent) in
features/credentials/reconciliation.ts, which allSettles them AND drops the
result when the auth session has moved on. The assertion follows the call and
then checks the helper still allSettles, so "one failing task must not sink the
rest" is still under test rather than taken on the function's name.

test_chat_page_hydrates_connections_on_startup is renamed to
test_connections_are_hydrated_on_startup. The sync moved out of chat-page.tsx
into features/credentials/bootstrap.ts, which the ROOT route calls -- a wider
guarantee, not a narrower one, since connections now hydrate on any entry into
the app rather than only on the chat page. Asserting the old location would
fail on a change that improved the thing being asserted. Both halves are
pinned: the bootstrap wires the sync, and something actually runs the
bootstrap.

189 passed.
@danielhanchen danielhanchen changed the title Clear the three main CI reds blocking every open PR Clear the four main CI reds blocking every open PR Aug 11, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

Fourth red added: Repo tests (CPU), which was 4 failed / 6084 passed on main. Reproduced on the merge base, same four.

All four are source-string contracts that a refactor moved out from under, and in each case the behaviour they protect is intact -- checked by reading the new code rather than assumed.

contract moved to
settleLostGeneration proving a lost POST landed inline knownIds set -> hasUnknownRecord(baseline, ...) in lib/gallery-flags.ts
GGUF footprint dedupe representative variant.quant === effectiveRecommended -> effectiveRecommended.has(variant.quant), a Set now
provider backfill batching Promise.allSettled(backfillTasks) -> settleTasksIfCurrent(...) in features/credentials/reconciliation.ts
connection hydration on startup chat-page.tsx -> features/credentials/bootstrap.ts, called from the root route

The last one is renamed rather than repointed. test_chat_page_hydrates_connections_on_startup asserted the chat page does it; the sync now runs from the ROOT route, so connections hydrate on any entry into the app rather than only on the chat page. That is a wider guarantee, and asserting the old location would fail on a change that improved the thing being asserted. It is now test_connections_are_hydrated_on_startup and pins both halves: the bootstrap wires the sync, and something actually runs the bootstrap.

The backfill one keeps its teeth the same way: the assertion follows the call, then checks settleTasksIfCurrent still allSettles, so "one failing task must not sink the rest" stays under test instead of being taken on the helper's name.

189 passed.

Two of the reds I listed earlier are still unexamined: Chat UI, API and Update Tests and pip scan-packages :: hf-stack. Both return no failing-step output from the API, so they need a different approach than reading --log-failed.

@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: 5dc526c3b0

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

assert "settleTasksIfCurrent(backfillTasks" in source
helper = (FRONTEND / "features/credentials/reconciliation.ts").read_text(encoding = "utf-8")
assert "export async function settleTasksIfCurrent" in helper
assert "allSettled" in helper, "the batch must still settle rather than reject on the first failure"

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 Scope the allSettled check to the backfill helper

This assertion searches all of reconciliation.ts, which also contains an unrelated Promise.allSettled inside runCredentialBootstrap. If settleTasksIfCurrent regresses to Promise.all and starts abandoning later provider backfills after one rejection, this contract still passes because of that second occurrence. Extract the settleTasksIfCurrent body before checking for allSettled so the stated per-backfill failure isolation remains covered.

Useful? React with 👍 / 👎.

# to hasUnknownRecord in lib/gallery-flags.ts. Same proof, named helper, so
# the assertion follows it rather than pinning the old spelling.
assert "hasUnknownRecord(" in fn
assert "baseline" in fn

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 checking that the gallery baseline precedes the POST

The replacement assertions only verify that settleLostGeneration receives something named baseline; they no longer inspect the caller that creates it. If a later refactor builds newRecordProbeBaseline after generateImage rejects, this test stays green even though records observed during the request can enter the baseline and a completed generation may be reported as never reaching the server. Preserve an ordering assertion that the baseline snapshot is created before the POST.

Useful? React with 👍 / 👎.

Comment on lines +3377 to +3378
assert "effectiveRecommended.has(variant.quant)" in group
assert "!effectiveRecommended.has(current.quant)" in group

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 Index footprint recommendations by dependency group

These replacement assertions bless membership in the flattened effectiveRecommended set, but that set loses the dependency-group association this contract is meant to protect. When group A recommends Q4 and group B recommends Q8, a Q4 current row in group B is treated as already recommended because Q4 appears in group A, so group B never replaces it with its own Q8 representative and its footprint request is made for the wrong variant. The condition and contract should consult effectiveRecommendedByGroup.get(key) rather than global quant membership.

Useful? React with 👍 / 👎.

# lists its base/modules path first. Released 5.4 through 5.6 still keep
# it under sentence_transformer/modules, so both spellings stay listed
# and every tag in ST_TAGS resolves.
"sentence_transformers/base/modules/normalize.py",

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 Verify Normalize remains exported from the models namespace

Adding the new internal file path only proves that a Normalize class exists somewhere on sentence-transformers master, while Unsloth actually executes from sentence_transformers.models import ... Normalize in unsloth/models/sentence_transformer.py. The separate check merely finds any setup_deprecated_module_imports call, which may configure unrelated compatibility aliases and does not prove that the moved class is exposed through sentence_transformers.models; if upstream moves the class without updating that alias, this test now passes while Unsloth raises ImportError. Inspect the shim's mapping for Normalize or otherwise verify the public re-export rather than accepting the internal definition alone.

Useful? React with 👍 / 👎.

@danielhanchen
danielhanchen merged commit a23951b into main Aug 12, 2026
42 of 51 checks passed
@danielhanchen
danielhanchen deleted the fix/prequant-allowlist-tests branch August 12, 2026 11:41
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Aug 12, 2026
…ai#8554)

* Studio: finish the backend CI cleanup unslothai#8506 started

unslothai#8506 fixed the pre-quant allowlist tests but left test_diffusion_convrot.py on the
same footing, and set the STT cancel timeout aside as a flake. Both are addressed here.

The allowlist stand-in moves to conftest so the two files that load through the same
registration share it instead of one carrying a private copy.

The STT cancel path collected twice in a row while holding the model lock that
wait_for_load_to_settle waits on. A long-lived backend reaches millions of tracked
objects, where one pass costs about a second, so the join(timeout = 2) sat on a cliff.
The release already collects and nothing becomes garbage after it, so the second call
keeps its cache sweep and skips the collection.

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

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

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
danielhanchen pushed a commit that referenced this pull request Aug 13, 2026
Three conflicts, all of them main and this branch repairing the same
contract drift independently.

tests/studio/test_remote_connection_models_contract.py, both hunks: main
(#8506) already followed the sync backfill to settleTasksIfCurrent and
renamed the hydration test, so the branch's version of that work is
redundant. Kept main's naming, docstring and the robust "allSettled" in
helper check, and folded in the one thing the branch had that main did
not: the assertions match CALL sites rather than bare names.
"bootstrapPersistedCredentials" alone is satisfied by the import on line
23 of __root.tsx, so main's assertion passes on a root that imports the
bootstrap and never runs it; "bootstrapPersistedCredentials()" pins the
call on line 108, and "<CredentialBootstrapGate>" pins that the gate
wrapping it is actually rendered. Same for the bootstrap's own call,
"syncExternalProvidersFromBackend(providers".

tests/studio/test_model_picker_contracts.py, the lost-generate-POST
test: main followed the proof into hasUnknownRecord loosely ("baseline"
in fn, the export exists); this branch pinned the data flow instead --
the baseline is built BEFORE the POST and the probe refuses to judge an
inconclusive listing. Those are different guarantees, so both are kept;
the branch's local name for the helper file was dropped in favour of
main's.

tests/studio/test_model_picker_contracts.py, the footprint-group test:
main tracked the source through effectiveRecommended becoming a Set and
asserted membership in it. That set is flattened across dependency
groups, which is the bug this branch fixes in pickers.tsx, so main's
assertions describe the behaviour being removed. Took the branch's
keyed-lookup assertions.

One resolution beyond the marked conflicts: main moved the row badge off
the flattened effectiveRecommended set (effectiveRecommendedByGroup.get
(group.key) === v.quant) and this branch moves the footprint
representative off it, so after the merge the memo has no readers left.
Deleted it, along with the comment that named the footprint
representative as its reason for existing. biome runs correctness rules
with "all": true, so leaving it would fail lint.
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