Repository navigation
Studio cluster: pair and serve across networks with one code - #18279
danielhanchen wants to merge 11 commits into
Conversation
…n Settings Pairing codes (v2) carry the master's one-time tailcat address, so a worker the master cannot reach on the LAN pairs and serves through a userspace WireGuard tunnel (tailscale/tailcat, run by the small unsloth-link helper) with the same mutual TLS inside. Both sides show three words derived from the pairing transcript and the master approves them; --yes skips that for scripts. The local network stays first; a worker reachable only through a relay is left out of splits unless UNSLOTH_CLUSTER_ALLOW_RELAY=1. The helper is built reproducibly for six targets by unsloth-link.yml, pinned by archive and binary sha256, and downloaded on the first pairing only. Settings > Machines adds a machine, shows the approval words, lists paired machines and removes them.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
The rail now renders only tabs listed in SETTINGS_NAV_GROUPS, so Machines was defined, routable and searchable but never shown (the browser gate saw 19 of 20 tabs). It sits after Remote access in Connections, and a guard test fails for any Settings tab that no group lists.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 97b558ceaa
ℹ️ 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".
| port = port or PAIR_PORT_DEFAULT, | ||
| ttl = seconds, | ||
| addrs = addr or None, | ||
| approve = None if yes else (lambda name, words: asyncio.to_thread(ask, name, words)), |
There was a problem hiding this comment.
Make the CLI approval prompt cancellable
When the owner leaves the approval prompt unanswered until APPROVAL_TIMEOUT_S expires, or presses Ctrl-C while it is displayed, cancelling the asyncio.to_thread await does not stop the thread blocked inside typer.confirm. The enclosing asyncio.run(run()) then waits for its default executor to shut down, so the command remains stuck until someone supplies input instead of reporting the timeout or cancellation. Use a cancellable input mechanism, or otherwise ensure the blocked prompt cannot hold up executor shutdown.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in a661cec. The prompt now runs on a daemon thread and hands its answer back as a future on the running loop (prompt_in_background), not through asyncio.to_thread. When the approval times out or Ctrl-C is pressed, asyncio.run has no executor thread to join, so the command reports the timeout or the cancellation and exits. With the old asyncio.to_thread version, the same unanswered prompt keeps the process alive until a 10 s kill. tests/test_cluster_cli_approval_prompt.py runs it in a subprocess.
The merge of the TLS-port fix skips that direct dial for workers reached through tailcat (70183bd). There the forward is the reachability check. test_native_tls_through_tailcat_dials_the_forwarded_native_port now fails if it dials.
# Conflicts: # studio/backend/core/inference/cluster_serving.py
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Stacked on #18278 (home cluster pairing), which is stacked on #18277 and #18276. Part of #4858. This replaces #17763, rebuilt on the Spark-free stack with the same content.
What this does
Pairing a machine now takes one code and one command on each side, and it also works when the two machines are on different networks or behind NAT. There is no port forwarding, no account and no admin rights involved.
Studio gets the same flow under Settings > Machines:
How it works
unsloth-link, built fromstudio/cluster_link/tailcat_helperwith tailcat pinned to e00cdde6.cluster remove) runs inside the tunnel, so it is still what decides who may connect. The tunnel only provides reachability.UNSLOTH_CLUSTER_ALLOW_RELAY=1overrides this, for example with your own relay set viaUNSLOTH_CLUSTER_DERP_MAP.--yesskips approval for scripted setups. Existing unattendedcluster pairscripts need it now.UNSLOTH_CLUSTER_TAILNET=0keeps pairing local-only and offline.studio/unsloth_link_pins.jsonbefore anything is extracted or run..github/workflows/unsloth-link.ymlbuilds byte-reproducible archives for Linux, macOS and Windows (amd64 and arm64) and fails unless they match the pins. It then smoke-tests each platform natively and publishes on theunsloth-link-v1tag.UNSLOTH_CLUSTER_TAILNET=0turns the whole thing off.Tests
tests/studio/test_cluster_link_tailnet_e2e.py, run whenUNSLOTH_LINK_BINis set):cluster removedrops the worker.Not proven yet
The workflow has not run on GitHub yet, so the pins come from local builds that were checked to be reproducible.
Speed across the internet is not measured yet. On a real gigabit LAN of 5 CPU machines, RPC through tailcat was compared with the same mutual-TLS RPC over the LAN, both with copies between workers going through the master:
Every tunnel reached a direct path at about 865 Mbit/s. At 4 and 5 machines, all worker-to-worker copies cross the master's tunnel endpoint. That is why the LAN stays first, and tailcat is only used for workers the LAN cannot reach.
The macOS and Windows helper binaries are cross-compiled but unsigned, and have not run on those platforms outside CI.
cluster removeon the master drops the worker at once: the master's TLS check refuses it and its tunnel is closed. The worker's own tunnel keeps admitting the master's key untilcluster leaveis run on the worker.Screenshots
These come from two separate
install.sh --local --no-torchinstalls: BEFORE is this PR's base (#18278), AFTER is this branch. The worker is a realunsloth worker --joinrun from a second cluster state directory on the same host. The code is blanked out.Settings gains Machines, in the Connections group after Remote & LAN (19 tabs before, 20 after). Before,
/api/cluster/machinesanswered 404.Nothing paired yet:
Add a machine shows the command to run on the other machine and the one-time code:
Approval: the worker ran
unsloth worker --joinand its terminal showed the same three words.After Allow:
The paired worker is Ready:
Remove asks first: