Skip to content

Fix three CI failures that were not the PRs they failed on - #10896

Merged
danielhanchen merged 2 commits into
mainfrom
ci/hidden-progress-shape-and-spoofed-device
Sep 14, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
ci/hidden-progress-shape-and-spoofed-device

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

What this is

Three separate CI failures that have been reddening PRs whose diffs touch none of the code involved, plus one that fires on main. Found while going through the last 40 PRs in this repo and in unsloth-zoo to see which red checks were real.

None of the three belongs to the branch it failed on.

1. /video/generate-progress answers a shape it does not declare

Backend CI's (Python 3.13) leg has failed intermittently on main (run 34789895058, commit 9360dcce) and on PRs #10858, #10847, #10837, #10830 and #10864 with:

tests/test_video_shape_validation.py:359: KeyError: 'active'

routes/video.py declares response_model = VideoGenerateProgressResponse (active: bool = False, phase: Optional[str] = None), but two early returns answer account_access.hidden_resident_response(), which is JSONResponse({"loaded": True, "yours": False}). FastAPI does not validate a returned Response, so the declared model is bypassed and active is simply absent. A poller that reads it gets a KeyError rather than "nothing is running", which is what it is entitled to learn either way. /images/generate-progress has the same hazard at three returns.

The fix adds hidden_generate_progress_response() next to the existing hidden_chat_status_response(), which is already there because the chat status shape differs in exactly this way. It returns the response model's own defaults plus the hidden markers, so the shape reveals nothing that the loaded / yours pair did not.

What made the gate fire is routes.video._generation_account, a module global written by _note_generation_account() and never reset. A multi-account test leaves a foreign id in it, and the next test's poll reads as a hidden resident. Six test files reset it by hand; every other file in the suite was exposed. It is now reset once in the backend conftest, read out of sys.modules rather than imported, so no test pays a routes.video import it does not need.

Reproduces on main and passes here:

pytest studio/backend/tests/multi_account studio/backend/tests/test_video_shape_validation.py

2. test_save_lora_without_vllm.py loaded an adapter onto a spoofed CUDA

Repo tests (CPU) on #10864:

NotImplementedError: Could not run 'aten::empty_strided' with arguments from the 'CUDA' backend

The call at tests/test_save_lora_without_vllm.py:212 let PEFT resolve the device. PeftModel.load_adapter falls back to peft.utils.other.infer_device(), which answers "cuda" for anything torch.cuda.is_available() says yes to, and on a CPU-only runner that is True because tests/_zoo_aggressive_cuda_spoof.py sets it so deliberately. The safetensors read then dispatches to a CUDA backend that is not there, and the message names neither PEFT nor the spoof.

#10864 rewired 20 skipif guards that read the same probe. This is the other half of the hazard, where library code reads it at runtime rather than at import. The device is now named at the call site, here and at the one other instance in tests/kaggle/, and test_accelerator_skip_guards.py gains a scan for the shape so the next one fails there instead of in safetensors.

3. test_rl_config_pickling.py reported an accelerator error instead of its own assertion

On #10848, a Studio logging PR:

ValueError: Your setup doesn't support bf16/gpu. You need to assign use_cpu ...
AssertionError: assert 'TrainingArguments' == 'SFTConfig'

The underlying cause was fixed on main by #10854: a # noqa comment added in unsloth-zoo #1192 broke a literal source anchor, _patch_trl_rl_trainers swallowed the RuntimeError into a warning and returned, and trl.SFTConfig was never patched.

What is left is that the file described that badly. The config sweep was the only construction in it that bypassed its own _make() helper, so TRL's bf16 = None resolved to True and transformers raised before the assertion about pickling ran. The sweep now goes through _make(), filtered against each config's declared fields since it is handed every trl.*Config there is, and the subclass test is fronted with an explicit check that the patch applied, so the next fallback names _patch_trl_rl_trainers rather than the pristine class's base. Same treatment _fake_sft_self() already gives the packing tests.

Verification

Backend suite run the way studio-backend-ci.yml runs it, against main and against this branch:

failed passed
main 331 41447
this branch 331 41448

Identical failure set (all pre-existing local dependency gaps, sqlite-vec and fastmcp), plus one new passing test: the hidden path must still answer the declared shape.

Repo tests (CPU) selection: the three failures on this branch's tree are two pre-existing torchcodec ones that also fail on main.

Lint gates run locally: ruff check, lint_exec_literals.py, lint_duplicate_definitions.py, verify_import_hoist.py --self-test.

UI evidence

The route change only touches the account-HIDDEN early returns, so a single-account session never
reaches them and the Images composer must render exactly as it did before. Shot on the PR merge base
and on this branch, same scene, same model (unsloth/Z-Image-Turbo-GGUF, z-image-turbo-Q4_K_M.gguf),
polling /images/generate-progress throughout.

Mid-generation: the live Stop control in place of Generate, on both sides.

Images composer mid-generation, merge base vs this branch

Just after Stop: the green Generate back, on both sides.

Images composer after Stop, merge base vs this branch

Read off the same servers that were photographed, the polled facts agree on both sides: active=true
mid-run, active=false once settled, and the same button text at each shot. No value moved.

Backend CI's (Python 3.13) leg has been failing intermittently on main and on
five open PRs with `KeyError: 'active'` out of
test_video_shape_validation.py, and Repo tests (CPU) has been failing on PRs
whose diffs touch none of the code involved. Three separate causes, all real,
none of them belonging to the branches that went red.

/video/generate-progress declares VideoGenerateProgressResponse but can return
account_access.hidden_resident_response(), which is {"loaded", "yours"} and has
no `active` at all. FastAPI does not validate a returned Response, so the
declared model is bypassed and a poller reading `active` gets a KeyError rather
than "nothing is running". /images/generate-progress has the same three early
returns. Add hidden_generate_progress_response(), beside the existing
hidden_chat_status_response() that already exists for exactly this reason, and
use it on both progress routes: the response model's own defaults are idle, so
the shape costs no privacy.

What made it fire is routes.video._generation_account, a module global written
by _note_generation_account() and never reset. A multi-account test leaves a
foreign id in it and the next test's poll reads as hidden. Six test files reset
it by hand; every other file was exposed. Reset it once in the backend
conftest, off sys.modules so no test pays an import for it.

Reproduces before this change and passes after:

    pytest studio/backend/tests/multi_account \
           studio/backend/tests/test_video_shape_validation.py

test_save_lora_without_vllm.py let peft resolve the load device. peft's
infer_device() answers "cuda" whenever torch.cuda.is_available() does, and on a
CPU-only runner that is True because tests/_zoo_aggressive_cuda_spoof.py sets it
so deliberately. The safetensors read then dispatches to a CUDA backend that is
not there and the test dies on aten::empty_strided, naming neither peft nor the
spoof. #10864 fixed the skip guards that read the same probe; this is the other
half, where the library reads it at runtime. Pin the device at the call site,
here and at the one other instance in tests/kaggle, and extend
test_accelerator_skip_guards.py so it scans for the shape rather than only for
skipif decorators.

test_rl_config_pickling.py's config sweep was the only construction in that file
that bypassed its own _make() helper, so on a CPU runner TRL's bf16=None resolved
to True and transformers raised before the assertion about pickling ran. That
error is what the sweep reported when the RL patch fell back, which is the thing
the file is actually about. Route it through _make(), filtered against each
config's declared fields, and front the subclass test with an explicit check that
the patch applied, so a fallback reports the patcher instead of
`assert 'TrainingArguments' == 'SFTConfig'`.

Verified against the full backend suite run the way CI runs it: identical
failure set to main, plus one new passing regression test.
@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-14T03:56:17.341053Z 00b77b7 Manual request
🔒 Security Review ✅ Completed 2026-09-14T03:57:19.196005Z 00b77b7 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.

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 14, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 00b77b7957

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

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: 00b77b7957

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@danielhanchen
danielhanchen merged commit ec3dd7f into main Sep 14, 2026
48 of 51 checks passed
@danielhanchen
danielhanchen deleted the ci/hidden-progress-shape-and-spoofed-device branch September 14, 2026 05:01
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