Skip to content

Add tests for disk_utils fallback when unsloth_zoo lacks disk_utils - #17933

Merged
danielhanchen merged 4 commits into
unslothai:mainfrom
zubincarvalho:zubin/disk-utils-fallback-tests
Nov 16, 2026
Merged

danielhanchen merged 4 commits into
unslothai:mainfrom
zubincarvalho:zubin/disk-utils-fallback-tests

Conversation

@zubincarvalho

Copy link
Copy Markdown
Contributor

Closes #17931

Adds tests/test_disk_utils_fallback.py, which loads unsloth/disk_utils.py with unsloth_zoo blocked so the fallback branch runs, then covers:

  • UNSLOTH_IS_KAGGLE override, including that a false override wins over real Kaggle env vars
  • Kaggle detection needing both KAGGLE_KERNEL_RUN_TYPE and /kaggle/working, and treating an isdir error as not Kaggle
  • Colab detection from any COLAB_ variable
  • free_bytes walking up to the nearest existing parent and returning None when disk_usage fails
  • logical_numel never raising
  • the sizing stubs returning 0, so the disk guard never blocks, and kaggle_tmp_redirect being a no-op

Tests only, no library changes. No torch or GPU needed.

Testing: pytest tests/test_disk_utils_fallback.py passes 17/17. Dropping .strip() from the override check makes 1 test fail, and making the stubs return 1 makes 2 fail.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T08:25:28.002893Z 2de2f54 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: Didn't find any major issues. Delightful!

Reviewed commit: 2de2f545ec

ℹ️ 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 added a commit that referenced this pull request Nov 16, 2026
…rest-2 red on main) (#17955)

## Summary

`Repo tests (CPU, rest-2)` is red on main (seen on the staging run of
#17933):

```
tests/test_ulysses_gemma4.py::test_gemma4_generic_route_gates
E   Failed: DID NOT RAISE NotImplementedError
```

Bisected to #17930 (the test passes on its parent, fails on it). #17930
deliberately stopped Gemma-4's vision and audio towers from deciding the
context parallel route: CP batches are text only, so attention modules
under a media tower are skipped by the route checks and get no Ulysses
hooks. The test still expected `attach_attention_hooks` on a multimodal
Gemma 4 to refuse with "Gemma4VisionAttention is bidirectional", which
is exactly the refusal #17930 removed. The test is what is out of date.

## Change

Test only,
`tests/test_ulysses_gemma4.py::test_gemma4_generic_route_gates`: on the
tiny multimodal Gemma 4, `attach_attention_hooks` now has to succeed,
the model must actually have media tower attention, and the set of
hooked `self_attn` modules must equal the text-stack ones exactly (no
tower module hooked, no text module missed). That keeps the property the
old refusal protected (bidirectional vision attention never runs through
the causal Ulysses path) in the form #17930 implements it.

## Testing

- `tests/test_ulysses_gemma4.py`: 24 passed (CPU, gloo). On main the
test fails as above.
- Sabotage: dropping the media tower check from the hook loop in
`unsloth/context_parallel.py` makes the new assertion fail
(`model.vision_tower.encoder.layers.0.self_attn` hooked).
danielhanchen added a commit that referenced this pull request Nov 16, 2026
…(rest red on main) (#17956)

## Summary

`(Python 3.13, rest)` is red on main (seen on the staging run of
#17933):

```
studio/backend/tests/multi_account/test_alice_bob_matrix.py::test_object_route_factory_completeness
E   AssertionError: ['routes.auth:PATCH:/api-keys/{key_id}']
```

#17833 added `PATCH /api/auth/api-keys/{key_id}` (switch a key between
full and inference access). The account isolation matrix requires every
object route to have a factory, so it is exercised as owner / right user
/ wrong user / unauthenticated / deactivated, or to be listed as skipped
with a reason. The new route had neither. The route itself is scoped
correctly (`set_api_key_access` filters by the caller's key scope); it
was only missing from the matrix.

## Change

Test only: `studio/backend/tests/multi_account/factories.py` adds a
factory for the route next to the existing `DELETE /api-keys/{key_id}`
one: seed one of alice's keys, PATCH it to `{"access": "inference"}`,
and expect the response to show `inference` for alice and a 404 for
everyone else, with alice's data unchanged on every rejected call.

## Testing

- The matrix rows for both api-key routes plus the completeness /
skipped / factory checks: 15 passed. On main the completeness check
fails as above.
- Sabotage: with the key scope removed from `set_api_key_access` (any
user can change any key), the new `[owner]` and `[wrong]` rows fail.
@danielhanchen
danielhanchen merged commit f56bf47 into unslothai:main Nov 16, 2026
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.

Add unit tests for the disk_utils fallback used when unsloth_zoo lacks disk_utils

2 participants