Skip to content

Studio CLI tests: keep the --secure re-exec tests off the cloudflared download - #17129

Merged
danielhanchen merged 2 commits into
mainfrom
studio-cli-tests-no-cloudflared-download
Nov 8, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
studio-cli-tests-no-cloudflared-download

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Problem

The --secure re-exec tests in unsloth_cli/tests/test_studio_secure_flag.py and test_studio_cloudflare_flag.py reach the real _tunnel_binary_confirmed_unavailable() check. On a runner with no cached cloudflared, that check downloads the binary from GitHub releases.

When the download fails, the check reports cloudflared as unavailable and run --secure correctly refuses to start. No re-exec happens, so these six tests fail with assert 0 == 1:

  • test_run_reexec_forwards_secure_polarity[--secure-...]
  • test_run_secure_forces_localhost_in_reexec
  • test_run_not_secure_alias_respects_last_wins[argv_order1-...]
  • test_run_secure_resolves_tools_against_loopback
  • test_run_secure_enable_tools_no_auto_yes
  • test_run_reexec_forwards_cloudflare_polarity[extra_flags3-...]

This happened on a CPU rest shard today. The log showed HTTP Error 504: Gateway Time-out on cloudflared-linux-amd64 before each of these failures. The PR under test did not touch the CLI.

Fix

An autouse fixture in both files stubs _tunnel_binary_confirmed_unavailable to False. These tests only check the re-exec argv.

The real check stays covered by test_studio_password_prompt.py, which already stubs it per test where needed and tests the function itself directly. The change is test-only.

Tests

The two files plus test_studio_password_prompt.py, run with an empty UNSLOTH_STUDIO_HOME and the network blocked (HTTPS_PROXY pointed at a closed port):

tree result
main (ba22bb2051) 6 failed, 214 passed in 40.1 s
this branch 220 passed in 4.0 s

With the network and a cached binary, the two files pass on both trees (47 passed).

@danielhanchen danielhanchen self-assigned this Nov 8, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 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-08T09:17:43.019291Z 510b23d 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. 👍

Reviewed commit: 510b23d151

ℹ️ 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 8, 2026
…ichever rank fails first (#17151)

## Summary

`Repo tests (CPU, rest)` fails on some PRs at a test #15880 added
yesterday. Today that includes #17129 and #17132, neither of which
touches context parallelism:

```
tests/test_remote_moe_shims.py:920: in test_without_context_parallelism_idle_experts_stall_ddp
E   AssertionError: Regex pattern did not match.
E     Expected regex: 'not close|finished reduction|did not receive grad'
E     Actual message: '-- Process 1 terminated with the following error:
      ...
      File "tests/test_remote_moe_shims.py", line 895, in _moe_ddp_worker
        assert got.grad is not None, name  # a zero gradient, never None, for DDP
    AssertionError: experts.0.gate_proj.weight
```

The test is a negative control. With context parallelism off, each rank
leaves the experts its peer routes to with a `None` gradient, so DDP
without `find_unused_parameters` never reduces that bucket. The test
expects the run to fail, and it does, every time. Which error the test
sees depends on which of the two spawned ranks fails first:

- the rank that **used** an expert holds an unreduced local gradient,
and `assert_close` fails with `not close`, which the regex accepts;
- the rank that left the **same** expert idle reaches `assert got.grad
is not None` first, and that assertion's message is just the parameter
name, which the regex does not accept.

`torch.multiprocessing.spawn` reports whichever process dies first. So
the test passes or fails on scheduling, while the product behaviour it
checks is identical either way. Context parallelism itself is correct.
The positive test next to it, with context parallelism on, passes.

## Change

`tests/test_remote_moe_shims.py`, test only:

- The worker's gradient assertion says what it found: `f"{name}: no
gradient"`.
- The negative control's regex also accepts `no gradient`, with a
comment on why both ranks' errors are the same finding.

The control still fails if context-parallel-off training ever stops
stalling DDP, because then nothing raises at all.

## Testing

| | result |
|---|---|
| main, with rank 0 delayed 3 s before its checks so rank 1 fails first
(the CI case) | fails: `Regex pattern did not match`, `Process 1
terminated` |
| this branch, same delay | passes |
| this branch, `tests/test_remote_moe_shims.py` | 49 passed |
[skip ci]
@danielhanchen
danielhanchen merged commit 028cae9 into main Nov 8, 2026
@danielhanchen
danielhanchen deleted the studio-cli-tests-no-cloudflared-download branch November 8, 2026 18: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