Skip to content

Studio: stop two backend tests from asking the host what the answer is - #8022

Merged
danielhanchen merged 1 commit into
mainfrom
fix/host-independent-backend-tests
Aug 6, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix/host-independent-backend-tests

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Aug 6, 2026 •

Copy link
Copy Markdown
Member

Two tests in studio/backend/tests/ pass on a GPU-less CI runner with no Studio running and fail on a developer box that has either. Neither is testing the machine.

test_hf_xet_fallback.py::test_a_worker_spawned_during_the_gpu_init_retry_does_not_inherit_the_override

It asserts the shim makes two unsloth_zoo import attempts, the second under UNSLOTH_ZOO_DISABLE_GPU_INIT, and that neither spawned child inherits the flag.

df5f139ba gated that retry on _gpu_present(): the flag makes unsloth_zoo take its MLX/CPU path and stub triton and bitsandbytes for the whole process, which would turn a healthy GPU into 500s. On a machine with an accelerator there is therefore one attempt, not two, and the test fails with assert 1 == 2.

The two neighbouring tests in the same file already pin _gpu_present for exactly this reason (monkeypatch.setattr(degraded, "_gpu_present", lambda: False), with the comment "The retry only applies to a host with no accelerator"). This one was missed. Same idiom applied.

test_text_io_encoding.py::test_a_corrupt_pid_file_does_not_abort_shutdown

Its last assertion is that _remove_pid_file() unlinks a record holding this process's own PID. _legacy_heir() scans the real Studio root and hands studio.pid to a live sibling rather than deleting it, so with any Studio server running on the machine the file is rewritten and assert not pid_file.exists() fails:

pre-fix assertion "not pid_file.exists()" would see exists = True
file now holds: 4242

Pinned to "no heir", which is the case that assertion is about.

test_the_legacy_pid_record_is_handed_to_a_live_sibling pins the branch that broke the test above, rather than only working around it. Correction to the commit message, which claims the handoff had no coverage: tests/test_studio_pid_files.py::test_the_legacy_pointer_moves_to_a_live_sibling already covers it against the real _legacy_heir under an isolated root. I found that only after pushing -- my search was for the symbol name, and that test exercises the behaviour through _remove_pid_file without naming it. The new test is narrower (it stubs _legacy_heir, so it covers the two-line branch in _remove_pid_file) and is kept because it is what makes the stub in the test above self-evidently safe.

Verification

tests/test_hf_xet_fallback.py     17 passed, 2 skipped   (was 1 failed, 16 passed, 2 skipped)
tests/test_text_io_encoding.py    381 passed             (380 before, +1 new test)

Run on a 8x B200 host with a Studio server up, i.e. the environment that reproduced both failures. No production code changes.

Both pass on a GPU-less CI runner with no Studio running, and fail on a developer box that
has either. Neither is testing the machine.

test_a_worker_spawned_during_the_gpu_init_retry_does_not_inherit_the_override asserts the shim
makes two import attempts, the second under UNSLOTH_ZOO_DISABLE_GPU_INIT. df5f139 gated that
retry on _gpu_present(), because the flag makes unsloth_zoo stub triton and bitsandbytes for the
whole process and that would turn a healthy GPU into 500s. So on a machine with an accelerator
there is one attempt, not two. Its two neighbours in the same file already pin _gpu_present for
exactly this reason; this one was missed.

test_a_corrupt_pid_file_does_not_abort_shutdown ends by asserting _remove_pid_file unlinks a
record holding its own PID. _legacy_heir scans the real Studio root and hands studio.pid to a
live sibling instead of deleting it, so with any server running on the machine the file is
rewritten and the assertion fails. Pinned to no heir, which is the case that assertion is about.

The handoff had no coverage of its own, so it has one now: the branch that broke the test above
is worth pinning rather than only working around.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 639ef6ee0b

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

@danielhanchen
danielhanchen merged commit 7222cdb into main Aug 6, 2026
36 of 37 checks passed
@danielhanchen
danielhanchen deleted the fix/host-independent-backend-tests branch August 6, 2026 14:04
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