Skip to content

DGX Spark: two-node clustering, pipeline training, and single-Spark guidance - #10280

Open
danielhanchen wants to merge 116 commits into
cluster/rpc-server-bundlefrom
feature/dgx-spark-two-node
Open

danielhanchen wants to merge 116 commits into
cluster/rpc-server-bundlefrom
feature/dgx-spark-two-node

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Sep 4, 2026 •

Copy link
Copy Markdown
Member

Stacked on #18276 (ships ggml-rpc-server with the llama.cpp bundle), and optional: multi-machine serving (#18277, #18278, #18279) no longer depends on this PR. The installer changes that put ggml-rpc-server in the bundle moved to #18276. The toolkit's rpc_server_binary, llama_bundle_dir and rpc_server_names now answer from studio/llama_rpc.py there, so there is one lookup.

Adds first class support for one DGX Spark, and for two of them cabled over the ConnectX-7 200GbE link, along with the diagnostics needed to tell a healthy pair from a broken one.

All numbers below are measured on real hardware (GB10, aarch64, sm_121a, CUDA 13), not projected.

New commands

unsloth spark gains: up, status, setup, peers, env, serve, train, doctor, provision, plan, kernels, merge, estimate.

unsloth spark up is the one command that covers all seven cluster states, so a user who does not know what state their machine is in still has somewhere to start.

What two Sparks actually buy

workload result notes
Inference, tensor parallel 2.09x median TPOT 332.7ms to 162.4ms
Training, layer split 1.96x 4204 tok/s against 2149 on one Spark
Llama-3.3-70B training fits 68.6 GiB per node, does not fit on one
Inference, pipeline parallel 1.08x TPOT flat, see below
Inference, two llama.cpp replicas 1.30x to 1.91x aggregate decode at 8 to 32 users, see below

The training figure uses torch.distributed.pipelining with DualPipeV at M=32, which is 99% of the 2M/(M+1) bubble ceiling. The schedule is no longer the limiting factor.

On a single Spark, spark kernels picks the right NVFP4 kernel for the workload: flashinfer_cutlass reaches 309 TF/s against Marlin's 50 TF/s at M=4096 for prefill, a 6.2x difference, while Marlin wins at M=1 for decode.

Two things the tooling says out loud

These are both cases where the intuitive expectation is wrong, so spark plan states them rather than letting people discover them by benchmark.

  1. Pipeline parallel cannot speed up decode. The bytes moved per token do not change when you split layers across nodes, so time per output token stays flat. This is not an artifact of our implementation: vLLM's own PP measures 1.08x with flat TPOT. plan --for latency recommends tensor parallel instead, which is the only axis that makes a single request faster.

  2. A model that fits on one Spark never decodes faster split across two. Measured from 1 to 32 concurrent users the layer split's aggregate decode is 0.85x to 1.01x of a single Spark (0.95x decode-only). Splitting buys capacity and prefill (1.7x to 1.85x), never decode. What a second Spark does buy for a model that fits is throughput at load: two independent replicas measured 1.30x at 8 users, 1.75x at 16 and 1.91x at 32, and only 1.00x to 1.13x below 8.

Also worth stating: usable memory is 121.69 GiB per node, not 128. spark estimate checks that a layer split run fits before it starts, rather than after an OOM.

Replicas planner, bundle provisioning, RPC protocol parity

Four follow-ups, all in studio/spark_cluster.py, unsloth_cli/commands/spark.py and the offbox tests, none of which run on the model-load path.

  1. spark plan now reasons about single / replicas / layer split. recommend_topology() is a pure function of model bytes, KV bytes per user, user count, prompt length and per-node free memory. A model that does not fit is a layer split, the only option. A model that fits is replicas from 8 users up and a single Spark below that (the second copy buys 1.13x at 2 to 4 users and 1.00x at 1, where only vLLM tensor parallel helps). A layer split of a model that fits is recommended only with --prefill-heavy, and says why. The measured table lives in one constants block (REPLICAS_DECODE_SPEEDUP, LAYER_SPLIT_DECODE_SPEEDUP), keyed by prompt tokens and concurrency, with the model, date and uncapped clocks named in the comment. plan gained --prompt-tokens and --prefill-heavy, and every printed sentence that quoted the old flat 0.92x now quotes this rule.

    Aggregate decode tok/s, Qwen3.8-27B-UD-Q4_K_XL (16.4 GiB), llama.cpp b10796, prompt 512, 128 generated tokens, uncapped clocks, 2026-09-04:

    users 1 Spark 2 replicas layer split replicas split
    1 12.0 12.0 11.3 1.00x 0.95x
    2 21.2 23.8 21.0 1.13x 0.99x
    4 39.0 44.0 35.8 1.13x 0.92x
    8 59.7 77.8 51.0 1.30x 0.85x
    16 68.1 119.4 64.2 1.75x 0.94x
    32 70.9 135.7 71.7 1.91x 1.01x

    At prompt 2048 the replicas ratios are 1.01 / 1.38 / 1.30 / 1.81 / 1.99 / 2.38. Memory per node at 16 users: single 22.6 GiB, replicas 19.3 GiB each, split 10.9 + 11.8 GiB.

  2. spark provision copies the llama.cpp bundle. provision_paths() gains the managed bundle directory, resolved the way the installer resolves it (UNSLOTH_LLAMA_CPP_PATH, else <UNSLOTH_STUDIO_HOME>/llama.cpp, else ~/.unsloth/llama.cpp), so a paired peer cannot end up on a different llama-server than the local node.

  3. RPC protocol mismatch is caught before a layer split is launched. Two independent signals: the bundle identity on both nodes (BUILD_INFO.txt tag plus the md5 of libggml-rpc, over ssh with a self-contained probe; a bundle without BUILD_INFO.txt reads as unknown, never a crash), and a live HELLO against any ggml-rpc-server already listening on either node, speaking the b10796 wire format (command 14, a 24-byte zero conn_caps request, a size-prefixed reply whose first three bytes are major, minor, patch). b10796 speaks RPC 6.0 where earlier bundles spoke 5.1, and llama-server then fails at load with RPC server version mismatch; spark serve and spark doctor now name both versions and the fix (unsloth spark provision). The HELLO probe is unit tested against an in-process fake server for a 6.0.0 reply, a truncated reply and a hang-up.

  4. rpc_server_binary() finds the executable in the bundle. Bundles from b10796-mix-659e406 ship ggml-rpc-server next to llama-server; the docstring that said otherwise is fixed, the bundle is searched first (current and legacy rpc-server names, honouring UNSLOTH_STUDIO_HOME), and the source-build and PATH fallbacks stay for older bundles.

  5. The installer now copies ggml-rpc-server, and backfills installs that lack it. The copy allowlist in studio/install_llama_prebuilt.py (runtime_patterns_for_choice) named llama-server, llama-quantize, the visual-server and lib*.so*, so a bundle that ships ./ggml-rpc-server next to ./libggml-rpc.so installed only the client library and every fresh install silently lacked the executable item 4 looks for. ggml-rpc-server (and the pre-rename rpc-server) is now in the Linux, macOS and Windows allowlists for fork and upstream bundles, chmod 755 in install_from_archives because extraction drops exec bits, and left in build/bin (build/bin/Release on Windows) with no root link, which is where rpc_server_binary() looks first; a test pins the installer's names and overlay directories to spark_cluster's search list. rpc_server_backfill_needed re-extracts a tag-matching install that has libggml-rpc but not the server (same shape as the DiffusionGemma backfill, not gated to fork bundles since upstream ships it too; fork builds before b10796 and bundles without libggml-rpc are never owed it, so nothing thrashes), and the three tag-match skips share one bundle_backfill_reason check. Verified on a Spark: a fresh install of b10798-mix-659e406 lands build/bin/ggml-rpc-server executable and --help prints usage; a pre-fix install of the same tag is re-extracted once with existing install matches b10798-mix-659e406 but is missing ggml-rpc-server and skipped on the run after.

  6. The source-build fallback ships ggml-rpc-server too. When the prebuilt install fails and studio/setup.sh or studio/setup.ps1 builds llama.cpp from source, neither configured GGML_RPC nor built the target, so a source-built install had nothing for item 4 to find. Every configure now carries -DGGML_RPC=ON -DGGML_RPC_RDMA=OFF (set before the CPU-fallback args are copied, so the CPU fallbacks carry them too) and, after the required llama-server and llama-quantize, builds the RPC server best-effort under whichever name the tree uses (ggml-rpc-server, or rpc-server before the rename, read from tools/rpc and examples/rpc because the VS generator has no --target help); a tree without it never fails the build, and the binary stays in build/bin (build/bin/Release on Windows) with no root link, where rpc_server_binary() looks. RDMA is off on every platform: it is what every shipped prebuilt is built with, and it avoids the hard runtime dependency on libibverbs and libnl that ggml-rpc otherwise picks up whenever libibverbs is installed on the build host (it is on every DGX Spark). macOS additionally checks the CMake cache and otool -L after the build, the gate the fork's unsloth-prebuilt-macos.yml runs, since a Mac with the RDMA framework would otherwise link /usr/lib/librdma.dylib into libggml-rpc and the install fails to load elsewhere; a build that trips it is redone without GGML_RPC. runtime_payload_health_groups and the staged validation do not require the RPC server. Verified with the CPU path of setup.sh on this Spark (GGML_RPC:BOOL=ON, GGML_RPC_RDMA:BOOL=OFF, build/bin/ggml-rpc-server executable, --help prints usage, no libibverbs in ldd, llama-server --version still runs); the CUDA variant of the same script path is untested here because both GPUs were busy benchmarking.

  7. spark provision moves bulk bytes at the disk floor instead of at ssh speed. rsync over ssh on this link is bound by ssh's CPU: with the same 1 GiB file in /dev/shm on both ends and one rail, rsync -a over ssh measured 0.22 GB/s (0.28 with -c [email protected]), one raw TCP stream 0.63 GB/s, the NVMe 1.1 to 1.3 GB/s, so a 170 GiB GGUF took about 13 minutes where the disk allows 3. provision_peer now starts an ephemeral rsync --daemon on the peer over ssh (temporary config in a 700 dir under /tmp, one module per destination root, random high port, random one-shot user and secret in a 600 secrets file, hosts allow = the single local rail address, address = the peer's rail address only, use chroot = no, read only = no, max connections = 4, log and pid file in the same dir, started under timeout as a backstop), then pushes the regular files with up to 4 concurrent rsync clients over disjoint byte-balanced file subsets against rsync://user@peer_rail:port/module/, secret in RSYNC_PASSWORD, no ssh on the data path. The unchanged ssh rsync then runs as the finaliser for every path: on a tree the workers filled it moves only symlinks, directory metadata and --delete (a non-chrooted daemon rewrites absolute symlink targets, so the workers never carry symlinks; the venv's bin/python -> /usr/bin/... arrives intact). The daemon is stopped by pid file (whole process group) and its dir removed from a finally, on error, on Ctrl-C and on SIGTERM, and pgrep -x rsync on the peer is reported afterwards. The bytes are unencrypted over the direct cable, a point-to-point link with no other host; the comment and --help say so, --no-fast and UNSLOTH_SPARK_PROVISION_FAST=0 force ssh, and the path is refused off Linux, off a Spark, for a non-private peer address, or when the local rail address is not in the peer's /24. ssh stays the default everywhere else and the fallback whenever the daemon does not start or a path fails.

    Measured 2026-09-04 on the two Sparks over the 192.168.200.0/24 rail, cold source cache every run (posix_fadvise DONTNEED), fresh destination every run, one transfer at a time, 4 workers, the local node running a vLLM benchmark throughout (peer GPU idle):

    workload direction ssh path fast path verified
    16 GiB /dev/urandom file (1 file, 1 stream) local to peer 39.0 s, 0.44 GB/s 22.7 s wall, 0.76 GB/s (stream 0.81) sha256 equal both ends
    same peer to local 50.2 s, 0.34 GB/s 31.0 s wall, 0.55 GB/s (stream 0.60) sha256 equal both ends
    studio venv, 6.1 GiB, 55,321 files, 4 symlinks local to peer 39.2 s 11.1 to 12.7 s wall over 5 runs, 0.61 to 0.68 GB/s 55,321 files, itemised dry run over ssh lists nothing
    peer venv, 6.4 GiB, 59,181 files peer to local 37.2 s 71.8 s, of which 60 s was one stalled flow waiting for its timeout, then a retry 59,181 files, itemised dry run lists nothing
    Qwen3.8-27B-UD-Q4_K_XL GGUF, 16.35 GiB (HF cache dir: blob plus snapshot symlink) local to peer 46.5 s, 0.38 GB/s 23.6 s wall, 0.80 GB/s md5 c54f8d4f84868ba6472c39beeab4bf9a
    same peer to local 57.6 s, 0.30 GB/s 23.9 s wall, 0.80 GB/s md5 c54f8d4f84868ba6472c39beeab4bf9a

    Floors measured the same day: cold NVMe read 1.1 GB/s (16 GiB random file) and 1.3 GB/s (the GGUF) on the local node, 0.72 GB/s on the peer; peer O_DIRECT write 7.5 GB/s. The single-file rows are one TCP stream because rsync cannot split one file, and land at 0.8 GB/s against a 1.1 to 1.3 GB/s read floor; multi-file trees get all four streams. Wall time includes daemon start and stop (about 1.5 s) and the ssh finaliser.

    The stall: with four concurrent streams, 2 of 9 venv runs had two of the four flows blackholed at once, in both directions on the same 5-tuple (ss -tni: cwnd:1 backoff:8 rto:51712, retransmits lost, while the other two flows on the same rail kept moving). Both NICs count millions of rx_err_lane_*_phy errors on that rail (local 2.15M / 6.78M, peer 0.61M / 4.65M), the QSFP seating problem the module already documents, so the loss is physical. Before the fix a stalled worker sat until the daemon's 600 s timeout and the path fell back to ssh. Now each worker runs with --timeout=30 (daemon timeout = 60) and up to 3 attempts; a retry is a fresh connection and rsync re-sends only what does not already match, which is what the 71.8 s row shows (the following 3 runs had no retries). Tests cover the config text and the secrets file mode (run under bash where available), the port range, every gate, the disjoint and complete work split, the retry, and that the daemon is stopped after a worker failure, an exception, and a finaliser error, with a fake ssh/rsync runner.

Diagnostics

unsloth spark doctor detects two hardware faults that look similar and have opposite remedies:

  • dead compute engine: cuInit returns 100 while nvidia-smi still works. Needs a plain reboot.
  • degraded interconnect: NCCL runs at 3 GB/s while RDMA still reads 24 GB/s. Needs a full power cycle. Finding and fixing this took the link from 3.0 to 21.1 GB/s.

doctor --parity-only catches cross node capability divergence. That is what made a two-node job hang for 1800 seconds when nvcc was absent from the peer's non-interactive ssh PATH, which is invisible from an interactive shell.

Fast-path parity, worth 2.19x on this pair

The capability check above catches divergence that hangs a job. This one catches divergence that does not: a kernel package installed on one node and missing on the other raises nothing, deadlocks nothing, and simply runs that node at a fraction of the speed.

Measured on this pair, on a byte-identical single-node Qwen3.5 LoRA training cell:

local peer
throughput 1183 tok/s 2593 tok/s
peak memory 14.02 GiB 10.07 GiB
bf16 matmul 95.0 TFLOP/s 96.0 TFLOP/s
copy bandwidth 124 GB/s 128 GB/s
clock 2392 MHz 2392 MHz
NCCL all-reduce 20.31 GB/s 20.31 GB/s

Same torch 2.11.0+cu130, same transformers 5.5.0, same peft, no throttle bits on either node. The cause was that local was missing causal_conv1d and flash-linear-attention / fla-core, so Qwen3.5's linear-attention layers fell back to the torch implementation. The only visible sign was one line, The fast path is not available, on one node's log and not the other's. Installing the peer's exact versions took local to 2557 and 2541 tok/s at 10.07 GiB, within 1.4 percent of the peer, with nothing else moved.

On a two-node run the pair moves at the slower node's pace, so this halves the whole job rather than one rank, and it stays invisible until somebody benchmarks each node separately.

unsloth doctor and unsloth spark doctor now compare the fast-path stack whenever a peer is configured:

  • package versions for torch, transformers, trl, peft, accelerate, bitsandbytes, triton, flash-attn, causal_conv1d, flash-linear-attention, fla-core and xformers, read from metadata only, so it is safe to run while a GPU is busy
  • a runtime probe in a short child interpreter on each node, which imports causal_conv1d_fn, the fla kernels, flash_attn_func, triton and the xformers attention entry point, and reads transformers' own is_causal_conv1d_available and is_flash_linear_attention_available gates. An installed package whose extension will not load is exactly as slow as an absent one and reads as present in pip list, so the metadata comparison alone would miss it. It runs as a child process so an import that aborts the interpreter costs the package inventory nothing, and it has its own timeout.

The report names the node, the package, both versions, and the command that fixes it:

    causal_conv1d
      this Spark : <absent>
      the peer   : 1.7.0
      gates      : the fused causal conv1d used by linear-attention and Mamba blocks
      fix, on this Spark:
        . $HOME/.unsloth/studio/unsloth_studio/bin/activate
        python3 -m pip install "causal_conv1d==1.7.0"

Two rules it follows, both learned here:

  • compare, do not demand. A package missing on both nodes is not a finding: it may be a model family the user never runs, and a check that lists packages nobody needs trains people to skip it. The one exception is a note, never a failure, when transformers itself reports a gate as unavailable on both nodes, since that is the signal that the installed build was looking for that kernel.
  • never fail open. An unreachable peer, or a runtime probe that did not report, answers UNKNOWN and says so. A check that reports a healthy pair because it did not look is worse than no check. --skip-fastpath turns it off.

Not breaking anything else

Everything is gated on actually running on a DGX Spark:

  • the loader notice costs a non-Spark host two string comparisons and no I/O, and only fires when a user asked for a multi-device device_map on a single-GPU box, where it would otherwise silently collapse onto cuda:0 with no message
  • the Studio run hint is advisory only, wrapped so it can never break unsloth run, and passes timeout=0 to discovery so no hint puts an mDNS browse in front of a model load
  • spark_cluster is stdlib only at module scope
  • the RPC parity checks and the bundle copy only run from the spark subcommands; unsloth/__init__.py and unsloth/models/ import none of it

No behaviour change on NVIDIA, AMD or CPU hosts, across Windows, Linux, WSL or macOS.

Testing

python3 -m pytest unsloth_cli/tests/test_spark_offbox.py unsloth_cli/tests/test_doctor_fastpath.py -q
110 passed, 41 skipped

The fast-path check has 17 tests of its own, driven with fake node responses: matching stacks, a package missing on one node, a version mismatch, an unreachable peer, a local probe that could not run, a runtime probe that crashed, and a node whose package is installed at the matching version but whose kernel does not import. None of them need a Spark, a GPU, a peer or a network.

These are hardware independent and run anywhere (the skips are the torch-dependent merge and loader-notice cases on a torch-free venv). Against the full CLI suite:

  • clean main: 35 failed, 1139 passed
  • this branch: 35 failed, 1203 passed, 55 skipped

Same 35 pre-existing failures in test_inference_chat.py, no regressions.

Three silent-cost fixes found by re-verifying this branch on the pair

Each was proved failing-first by mutating the fix back out and watching the new
test go red. Off-box suite 402 to 409 passed, 129 skipped either way: the seven
new tests are the whole difference. ruff clean at the pinned 0.15.18.

The harness defaulted to the schedule the docs say to avoid

studio/spark_pipeline.py's own --schedule defaulted to gpipe. unsloth spark train always passes --schedule explicitly, so the shipped path was
safe, but the commands it prints are what a user pastes and edits, and
dropping the flag from one of those selected the arm that peaked at 99.92 GiB
against a 121.69 GiB node, where 1f1b peaked at 7.34 GiB for identical work.

This is worth stating because it is not a one-line edit. The legacy backend
refuses 1f1b outright, because the hand-written version deadlocks. Flipping
the default globally would have turned --pp-backend legacy with no
--schedule from a working run into an error, trading one never-OOM hazard for
a hard failure somewhere else. The default is now resolved per backend by
default_schedule() in main(), 1f1b on torch and gpipe retained on legacy,
with argparse carrying default = None because it cannot express a default
that depends on another flag. Both arms verified end to end on the gloo path.

A missing attention fast path costs 2.1x and says almost nothing

Measured on two Sparks, Qwen3.5-9B, 1f1b, M=4, batch 64, seq 512, gradient
checkpointing, both nodes pinned at 300,1690: 877 tok/s with
flash-linear-attention and causal-conv1d present, 418 without
, and peak memory
14.02 GiB against 17.08. The only sign is one logger.warning_once from
transformers in the middle of the weight-loading output.

check_fast_path() now says so before the weights load, naming the missing
packages, the measured cost, and that both nodes need them, since two ranks
that disagree are not even slow in the same way. It is advisory and cannot break
a load. It also cannot cry wolf, which matters more than the warning itself: it
asks transformers the same question transformers asks itself, reading
is_fast_path_available from the model's own modeling module and warning only
on an explicit False. An architecture with no fused path has no such
attribute, so the value is None and nothing prints. Verified live on all three
cases: fast path present and silent, a plain llama with no fast path and silent,
packages made unavailable and warning.

--microbatches was pinned by no test

That flag was once omitted from the emitted commands, worth about 20% at 70B,
with no error and only a slower run. Nothing in the suite would have noticed it
going missing again. Three tests now cover it, including the default path, where
the CLI defaults to M=32 while the harness defaults to M=4, so a dropped flag
runs a different configuration rather than failing.

unsloth doctor diagnosed a real cross-node fault nobody arranged

This was unplanned and is the strongest evidence in the verification pass.

Early in the pass spark doctor --parity-only reported one divergence
(which_nvcc present locally, absent on the peer) with the
non-interactive-ssh PATH explanation and the fix, and "OK, the two nodes run the
same fast-path stack".

Later, unrelated work destroyed torch in the shared studio venv on one node:
bin/torchrun disappeared and site-packages/torch was reduced to csrc,
_inductor and share with no dist-info, so import torch failed with
"cannot import name 'nn' from 'torch' (unknown location)". Re-run unchanged,
doctor immediately reported 3 capability divergences (pkg_torch absent
locally, which_torchrun absent locally, which_nvcc absent on the peer) and
7 fast-path differences, named torch as the one that "gates everything; a
version split here also splits every kernel below it", and gave the exact
pip install "torch==2.11.0+cu130" against the right venv.

Nothing was staged for it and it was not shown the fault.

Reproducing the training numbers: state the conditions

The 70B capacity claim re-measured cleanly: 80 layers split 0-39 / 40-79,
--shard-load materialising 361 tensors with none left on meta, 66.10 GiB of
weights and 69.40 / 69.73 GiB peak per node
, no thermal event, both nodes
pinned and verified at 1677-1683 MHz under load. spark estimate had predicted
70.2 GiB. The single-node refusal is arithmetic from the run itself: 2 x 66.10 =
132.20 GiB against 121.69 GiB.

The pipeline-parallel speedup also re-earned itself: 1.86x against the
recorded 1.776x. That figure is an upper bound, because the control was a
single point rather than a sweep; a control swept over its accumulation axis
would pull the ratio toward 1.776x, not away from it.

The absolute 9B tok/s ladder did not reproduce (877 and 805 against 1073 and
1438), and the discrepancy could not be resolved, because the recorded
protocol does not state its batch
. Anyone quoting a tok/s figure from this
work should record the conditions beside it, as these are:

axis value
batch / seq / steps 64 global per step / 512 / 10
LoRA r16, alpha 16, dropout 0, the 7 usual projections
schedule / backend 1f1b on torch.distributed.pipelining, scale_grads=True
torch / transformers / peft 2.11.0+cu130 / 5.5.0 / 0.18.1
torchao 0.17.0 (0.18.0 breaks peft's LoRA dispatcher outright)
attention fast path flash_linear_attention 0.5.2, fla_core 0.5.2, causal_conv1d 1.7.0, flash_attn 2.8.1, einops 0.8.2
clocks both nodes pinned 300,1690, every sample 1677-1683 MHz

…uidance

Adds first class support for one DGX Spark and for two cabled over their
ConnectX-7 200GbE link, plus the diagnostics needed to tell a healthy pair from
a broken one.

New `unsloth spark` commands: up, status, setup, peers, env, serve, train,
doctor, provision, plan, kernels, merge, estimate.

Measured on two Sparks (GB10, aarch64, sm_121a, CUDA 13):

- Inference, tensor parallel across the pair: 2.09x, median TPOT 332.7ms to
  162.4ms. Tensor parallel is the only axis that makes a single request faster.
- Training, layer split with torch.distributed.pipelining: 1.96x (DualPipeV,
  4204 tok/s) against 2149 tok/s on one Spark, which is 99% of the 2M/(M+1)
  bubble ceiling at M=32.
- Llama-3.3-70B trains across the pair at 68.6 GiB per node. It does not fit on
  one, so this is capacity rather than speed.
- NVFP4 kernel selection on a single Spark: 6.2x prefill (flashinfer_cutlass at
  309 TF/s against Marlin's 50 TF/s at M=4096).

Two things the tooling states plainly rather than letting users assume:

- Pipeline parallel cannot speed up decode. Bytes moved per token are unchanged,
  so TPOT stays flat; measured 1.08x in vLLM's own implementation. `spark plan`
  says so and points at tensor parallel instead.
- A model that fits on one Spark is slower layer split across two (0.92x),
  because ggml walks the split graph device by device. Splitting buys capacity,
  never speed.

Usable memory is 121.69 GiB per node, not 128, and `spark estimate` checks a run
fits before it starts rather than after an OOM.

`doctor` detects two hardware faults with opposite remedies: a dead compute
engine (cuInit=100 with working nvidia-smi) needs a plain reboot, while a
degraded interconnect (NCCL at 3 GB/s while RDMA reads 24) needs a full power
cycle. `--parity-only` catches cross node capability divergence, which is what
made a two-node job hang for 1800 seconds when nvcc was missing from the peer's
non-interactive ssh PATH.

Everything is gated on actually being a DGX Spark. The loader notice costs a non
Spark host two string comparisons and no I/O, the Studio run hint is wrapped so
it can never break `unsloth run`, and spark_cluster is stdlib only at module
scope. Nothing changes on NVIDIA, AMD or CPU hosts across Windows, Linux, WSL or
macOS.

Tests: 33 hardware-independent tests in unsloth_cli/tests/test_spark_offbox.py.
Full unsloth_cli suite goes from 1139 passed to 1172 passed with the same 35
pre-existing failures in test_inference_chat.py, so no regressions.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 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-22T21:28:46.268134Z b3502ba 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[bot]

This comment was marked as resolved.

…ith tests

Three changes from a pre-merge audit that simulated the full platform matrix.

notify_device_map_cannot_span_sparks runs inside FastLanguageModel.from_pretrained
and FastModel.from_pretrained, so it executes for every Unsloth user on every OS
and every accelerator. Its probes caught OSError, but nothing caught anything
else, so a non-OSError escaping a sysfs read would propagate out of from_pretrained
and fail a load that had nothing to do with a Spark. Wrapped in a blanket guard: a
cosmetic notice must never be able to do that. The cheap gates still run first, so
the try costs nothing on the common path.

install.sh's gate now reads ${OS:-} and ${_ARCH:-} rather than $OS and $_ARCH.
Both are set unconditionally long before the gate runs, so this is not a live bug,
but install.sh is the entry point for every user on every platform and if anyone
ever adds set -u above that line an unbound variable would abort the whole install
instead of skipping a hint. Fails closed either way.

Adds 41 tests covering the notice across [Windows, Linux, WSL, macOS] x
[NVIDIA, AMD, CPU-only]: it must stay silent off a cabled Spark, and it must not
propagate OSError, PermissionError, IsADirectoryError, ValueError or RuntimeError
from its probes, nor a failure from torch.cuda.device_count(). The ValueError and
RuntimeError cases fail without the guard above, so the tests pin the fix rather
than describing it. They also stub the filesystem, not just platform, so they pass
when CI runs on an actual DGX Spark.

Verified: 1955-check platform simulation of the notice, 121-check simulation of
all 17 spark/doctor subcommands across 7 platforms (all exit cleanly, no traceback,
and the CLI still imports neither torch nor numpy), 79-check simulation of the
Studio run hint against a spark_cluster whose every helper raises or returns junk,
and a 36-check simulation of the install.sh gate across every (OS, arch) pair,
strace-confirmed to open no files on a simulated Mac.

unsloth_cli suite: 1172 passed with the same 35 pre-existing test_inference_chat
failures as origin/main. test_spark_offbox: 74 passed with torch present.
@danielhanchen

Copy link
Copy Markdown
Member Author

Pushed two fixes and 41 tests from a pre-merge audit. The question I was trying to answer was narrow: this PR adds a hardware path, so does it change anything for the overwhelming majority of users who will never own a DGX Spark?

The one real defect

notify_device_map_cannot_span_sparks is called inside FastLanguageModel.from_pretrained and FastModel.from_pretrained. That means it runs for every Unsloth user on every OS and every accelerator, and it is purely cosmetic.

Its probes caught OSError, which covers FileNotFoundError, PermissionError and IsADirectoryError from the sysfs and /etc/dgx-release reads. Nothing caught anything else. A non-OSError escaping one of those reads would propagate straight out of from_pretrained and fail a model load that had nothing to do with a Spark.

Now wrapped in a blanket guard. The cheap gates still run first, so the try costs nothing on the common path, and the notice fails silent rather than taking a load down with it.

This was found by simulation, not by reading, and the new tests fail without the fix:

FAILED test_spark_notice_never_breaks_a_load[ValueError-Linux-aarch64]
FAILED test_spark_notice_never_breaks_a_load[RuntimeError-Linux-aarch64]

The one hardening

install.sh's gate now reads ${OS:-} and ${_ARCH:-} rather than $OS and $_ARCH. Both are set unconditionally long before the gate runs, so this is not a live bug. But install.sh is the entry point for every user on every platform, and if anyone ever adds set -u above that line an unbound variable would abort the whole install rather than skip a hint nobody asked for. It also matches what the rest of the file already does at lines 568, 2176, 2308 and 4444.

What was simulated

Everything below ran on a real DGX Spark, which is the awkward case: the machine answers yes to the detection probes, so the simulations have to stub the filesystem as well as platform, or they only prove things about hardware nobody else has.

simulation checks result
the notice, [Windows, Linux, WSL, macOS] x [NVIDIA, AMD, CPU-only] x 13 device_maps x 5 hostile envs 1955 0 failures
all 17 spark / doctor subcommands across 7 platforms 121 0 failures
the Studio run hint against a spark_cluster whose every helper raises or returns junk 79 0 failures
the install.sh gate across every (OS, arch) pair 36 0 failures

Specifically confirmed:

  • The notice is silent on every non-Spark host, for every device_map, and fires at most once per process.
  • It defers to the distributed path under torchrun rather than printing a second, less accurate message.
  • All 17 subcommands exit 0 with a sentence off a Spark. None raise, none print a traceback, none attempt network calls.
  • Importing unsloth_cli still pulls in neither torch nor numpy, so unsloth --help stays fast.
  • The install.sh gate opens no files on a simulated Mac, strace-confirmed. OS="wsl" is a distinct value from "linux", so WSL never enters the block either.
  • The detection regex matches NVIDIA DGX Spark, DGX_SPARK and DGX-Spark, and does not match DGX Station A100, DGX H100, DGX A100, GH200 Grace Hopper or Jetson AGX Orin. /etc/dgx-release is checked before DMI, which is the right order given OEM variants like the MSI EdgeXpert can be flashed with the NVIDIA image and report the OEM name in DMI.

Backwards compatibility

I checked whether the CLI still works if studio is not importable, since unsloth_cli ships the spark commands and studio.spark_cluster is what they defer to. It does not, but that is pre-existing and unrelated: unsloth_cli/commands/start.py already imports studio.backend.utils.coding_agents at module scope, and the identical failure reproduces on clean main. This PR does not make it worse. spark.py itself guards the import via _cluster_or_none, and _getnum defends against missing constants, so version skew between the two degrades to a message.

Test counts

unsloth_cli suite    : 1172 passed, 35 failed   (clean main: 1139 passed, 35 failed)
test_spark_offbox    : 74 passed with torch present, 33 passed / 41 skipped without

Same 35 pre-existing test_inference_chat.py failures as main, so no regressions.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

Found by installing the PR from scratch into a non-default UNSLOTH_STUDIO_HOME
and provisioning a second Spark from it. Both bugs are invisible with the
default layout, which is why the tests did not catch them.

1. UNSLOTH_STUDIO_HOME moved the venv but four call sites still assumed
   ~/.unsloth/studio/unsloth_studio: PROVISION_PATHS, the two-node torchrun
   launch, the parity/SMI probes, and the peer-venv presence check. The worst of
   these is provision, which copied the default path, skipped or copied a stale
   venv, and then printed "Peer now matches this node". That hands the user the
   exact 601 s `DistStoreError: 1/2 clients joined` the command exists to
   prevent, while reporting success. `doctor` failed more quietly: the probe ran
   without a venv, torchrun was absent, and it reported "could not measure NCCL
   bandwidth" on a healthy pair.

   Resolved through `provision_paths()` and `venv_activate()` rather than
   hardcoded. `venv_activate()` deliberately keeps the literal `$HOME/...` form
   in the default case so it expands on the PEER, which stays correct when the
   nodes have different usernames or home directories; only a custom
   UNSLOTH_STUDIO_HOME forces an absolute path, and that is right because
   provision copies to that same absolute path.

2. rsync creates only the last component of the destination, so provisioning a
   peer that lacks the parent directory failed with
   `mkdir "<dest>" failed: No such file or directory`. This is not an edge case:
   it is the normal state of a brand-new second Spark, which has no
   ~/.unsloth/studio yet, so the primary use case was broken with the default
   layout too. Fixed with `--rsync-path='mkdir -p "<parent>" && rsync'`, with `~`
   rewritten to "$HOME" because a quoted tilde does not expand and it must expand
   on the peer.

Verified on two Sparks with a fresh install at a custom UNSLOTH_STUDIO_HOME:
provision copies the right venv and now succeeds; the peer's torchrun resolves
into it with torch 2.11.0+cu130 and CUDA available; a real two-node NCCL
all-reduce runs, world=2, 64 MiB in 5.31 ms; and doctor's parity divergences drop
from 2 to 1 because the peer finally sources the same venv.

Default behaviour is unchanged and pinned by a test asserting the resolved path
still equals ~/.unsloth/studio/unsloth_studio when neither variable is set.

Tests: 1176 passed (up from 1172) with the same 35 pre-existing
test_inference_chat failures; test_spark_offbox 78 passed with torch present.
@danielhanchen

Copy link
Copy Markdown
Member Author

Two bugs found by installing this PR from scratch into a non-default UNSLOTH_STUDIO_HOME and provisioning a second Spark from it. Both are invisible with the default layout, which is why the tests missed them. Fixed and pushed.

1. UNSLOTH_STUDIO_HOME moved the venv, four call sites did not follow

_studio_root() honours the variable, but PROVISION_PATHS, the two-node torchrun launch, the parity and SMI probes, and the peer-venv presence check all hardcoded ~/.unsloth/studio/unsloth_studio.

The worst is provision. With a custom studio home it copied the default path, so it copied a stale venv or skipped it entirely, and then printed:

  Peer now matches this node. Verify with: unsloth doctor

which is false. That hands the user the exact 601 s DistStoreError: 1/2 clients joined that this command exists to prevent, while reporting success.

doctor failed more quietly. Its probe ran on the peer without a venv, torchrun was therefore absent, and it reported could not measure NCCL bandwidth (needs a peer and torchrun) on a completely healthy pair. A false negative on a diagnostic is worse than a loud failure, because the next step a user takes is to go looking for a hardware fault that does not exist.

Now resolved through provision_paths() and venv_activate(). venv_activate() deliberately keeps the literal $HOME/... form in the default case so it expands on the peer, which stays correct when the two nodes have different usernames or home directories. Only a custom UNSLOTH_STUDIO_HOME forces an absolute path, and that is correct because provision copies to that same absolute path on the peer.

2. provision could not create the destination on a fresh peer

rsync creates only the last component of the destination, so provisioning a peer that lacks the parent failed:

FAILED  Unsloth venv: rsync: [Receiver] mkdir "/.../unsloth_studio" failed: No such file or directory (2)

This is not an edge case, and it is not limited to custom studio homes. It is the normal state of a brand-new second Spark, which has no ~/.unsloth/studio yet. So the primary use case of this command, pairing a fresh peer, was broken with the default layout too.

Fixed with --rsync-path=mkdir -p "<parent>" && rsync, with ~ rewritten to $HOME because a quoted tilde does not expand and it has to expand on the peer.

Verified on two Sparks

Fresh install from this PR into a custom UNSLOTH_STUDIO_HOME, then provisioned across the ConnectX link:

  • provision --dry-run now names the right venv, and is byte-identical to before when the variable is unset
  • the real provision succeeds on all four paths where it previously failed on the venv
  • the peer's torchrun resolves into the provisioned venv, torch 2.11.0+cu130, CUDA available
  • a real two-node NCCL all-reduce runs: world=2, allreduce 64MiB: 5.31 ms
  • doctor parity divergences drop from 2 to 1, because the peer finally sources the same venv
  • link measured 111.86 Gb/s per rail -- healthy

Tests

1176 passed, up from 1172, with the same 35 pre-existing test_inference_chat.py failures. test_spark_offbox is 78 passed with torch present.

Four new tests, including one asserting the resolved path is still exactly ~/.unsloth/studio/unsloth_studio when neither variable is set, so the default cannot drift.

One thing I did not change: doctor's NCCL probe still does not complete even with the peer correctly provisioned. Its backgrounded remote process exits without writing to /tmp/spark_nccl_probe.log. I verified two-node NCCL works by running torchrun directly, so this is a defect in the probe's remote launch rather than a link or environment problem. Left as is for now and flagged here rather than fixed silently.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

The planner shipped one number for splitting a model that already fits on one
node: 0.92x, a loss, always. That is still correct for a llama.cpp whose RPC
backend predates ggml-org/llama.cpp#18626 ("rpc: implement event and async
backend APIs", merged 2026-08-26), which is what the fork currently builds.
Without that commit the RPC backend advertises neither async nor events,
ggml_backend_sched refuses to pipeline across RPC devices, and the two halves
run strictly one after the other.

With it the answer stops being a constant, because what overlaps is prefill.
Measured end to end on two Sparks, Qwen3-27B Q4_K_XL, same binary in both arms
so the only variable is whether the model is split:

  prompt tokens |  c=1    c=4    c=8
          128   | 0.94x  0.95x  0.95x
          256   | 0.98x  1.00x  1.00x     <- break-even
          512   | 0.96x  1.05x  1.07x
         1024   | 1.02x  1.12x  1.17x
         2048   | 1.07x  1.23x  1.29x
         4096   | 1.11x  1.35x  1.45x

Decode is 0.93-0.98x throughout and cannot be otherwise: a layer split moves the
same weight bytes per token, so the entire gain is prefill and the entire
question is prompt length. Below ~256 tokens splitting costs 2-6%; above ~1024
it wins, growing with both prompt length and concurrency. So it is a loss for
chat-shaped traffic and a win for prompt-heavy work, which is the opposite of a
single verdict.

`layer_split_speedup()` defaults to `async_rpc=False` and returns the
conservative 0.92x, so nothing promises users a speedup their build cannot
deliver. With `async_rpc=True` and no prompt length it returns None rather than
guessing, and it snaps down to the nearest measured row rather than
interpolating: these are six measured points, not a fitted curve.

The old constant is kept and still used, so no existing caller changes
behaviour.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Four follow-ups to the two-Spark work, all confined to the spark subcommands.

1. spark plan reasons about single, replicas and layer split, not only single
   versus split. recommend_topology() is a pure function of model bytes, KV
   bytes per user, users, prompt tokens and per-node free bytes. A model that
   does not fit is a layer split, the only option. A model that fits is
   replicas from 8 users up and a single Spark below that; a split of a model
   that fits is recommended only for prefill-heavy long-prompt work, and says
   why. The measured table (Qwen3.8-27B-UD-Q4_K_XL, llama.cpp b10796, two
   Sparks, 2026-09-04, uncapped clocks) lives in one constants block keyed by
   prompt tokens and concurrency: two replicas 1.00x / 1.13x / 1.13x / 1.30x /
   1.75x / 1.91x and a layer split 0.95x / 0.99x / 0.92x / 0.85x / 0.94x /
   1.01x aggregate decode at 1 / 2 / 4 / 8 / 16 / 32 users, prompt 512. Every
   sentence that quoted the pre-#18626 flat 0.92x now quotes this rule: a
   split never speeds up decode for a model that fits, it is a capacity and
   prefill feature (1.7x to 1.85x prefill). plan gains --prompt-tokens and
   --prefill-heavy.

2. spark provision copies the llama.cpp bundle. provision_paths() gains the
   managed bundle directory, resolved as the installer resolves it:
   UNSLOTH_LLAMA_CPP_PATH, else <UNSLOTH_STUDIO_HOME>/llama.cpp, else the
   legacy ~/.unsloth/llama.cpp. Without it a paired peer keeps whatever
   llama-server it had, and two bundles a release apart speak different RPC
   protocols.

3. RPC protocol mismatch is detected before a two-node layer split is
   printed. Two independent signals: the bundle identity on both nodes
   (BUILD_INFO.txt tag and the md5 of libggml-rpc, read on the peer by a
   self-contained probe over ssh; a bundle without BUILD_INFO.txt reads as
   unknown, never a crash), and a live HELLO against any ggml-rpc-server
   already listening on either node, using the b10796 wire format (command
   14, a 24-byte zero conn_caps request, a size-prefixed reply whose first
   three bytes are major, minor, patch). b10796 speaks RPC 6.0 where earlier
   bundles spoke 5.1, and llama-server fails at load with "RPC server version
   mismatch"; spark serve and spark doctor now name both versions and the fix,
   which is unsloth spark provision. The probe is bounded and never raises.

4. rpc_server_binary() looks in the bundle first. Bundles from
   b10796-mix-659e406 ship ggml-rpc-server next to llama-server; the docstring
   that said otherwise is fixed, the bundle is searched under the current and
   the legacy rpc-server name honouring UNSLOTH_STUDIO_HOME, and the source
   build and PATH fallbacks stay for older bundles. The serve output now names
   the resolved binary on the peer instead of a hardcoded ~/llamacpp-rpc path.

Tests: 23 new offbox tests cover the topology rules and table lookups, the
provision paths under the default and a custom UNSLOTH_STUDIO_HOME, bundle
identity with and without BUILD_INFO.txt, the comparison message, the HELLO
probe against an in-process fake server (6.0.0 reply, truncated reply,
hang-up), the preflight verdicts, and binary discovery (found, legacy name,
absent). The one existing provision test that pinned the tuple by position is
updated for the new entry. 64 passed, 41 skipped.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…existing installs

The copy allowlist in runtime_patterns_for_choice named llama-server,
llama-quantize, the DiffusionGemma visual-server and lib*.so*, so a bundle
that ships ./ggml-rpc-server next to ./libggml-rpc.so installed only the
client library: the executable the two-Spark layer split runs on the peer
was filtered out of every fresh install, and spark_cluster.rpc_server_binary()
looks for it in the bundle first.

Name ggml-rpc-server (and the pre-rename rpc-server) in the Linux, macOS and
Windows allowlists, for fork and upstream bundles alike, and chmod it 755 in
install_from_archives since extraction drops the archive's exec bits. It stays
in build/bin (build/bin/Release on Windows) with no root-level link, which is
where rpc_server_binary() looks first; a test pins that the installer's names
and overlay directories match spark_cluster's search list.

Add rpc_server_backfill_needed so an install that matches on tag but lacks
the executable is re-extracted on the next update, and route all three
tag-match skips through one bundle_backfill_reason check. Unlike the
visual-server it is not gated to fork bundles, since upstream ships the server
too when built with GGML_RPC; thrash on bundles that never carry it is
prevented by evidence instead (no libggml-rpc in the runtime dir, or a fork
build older than b10796, means nothing is owed).
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 4, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 4, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 4, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 4, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 4, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 4, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 4, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: e1ddc3a60b

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

…ofile is the runner-independent one

[skip ci]
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 9976aa17b5

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

# Conflicts:
#	tests/studio/install/test_install_llama_prebuilt_logic.py
#	tests/studio/install/test_source_build_rpc_server.py
The installer, the worker CLI and serving now share one lookup, so the
toolkit's rpc_server_binary, llama_bundle_dir and rpc_server_names answer
from it instead of keeping a second copy. The cross-platform cases live with
the lookup; these tests pin that the toolkit agrees with it and that the
bundle identity names the server the installer placed.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…esolves

AutoConfig reads back _attn_implementation = None for a checkpoint that never
named one, and the model constructor then takes SDPA, so --pp-backend legacy
rejected every ordinary config. The check now resolves the backend the model
class will use (SDPA when it supports it, eager otherwise) and still refuses
eager.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4a7094cc3d

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

Comment thread studio/spark_cluster.py Outdated
Comment on lines +1414 to +1419
out = subprocess.run(
f"env {local_common} --node_rank=0 {shlex.quote(local_probe)}",
shell = True,
capture_output = True,
text = True,
timeout = timeout,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Terminate the local probe process group on timeout

When the NCCL probe times out, subprocess.run(..., shell=True) kills only the intermediate shell, leaving its torchrun process and workers running. The finally block cleans up only the peer, so a failed spark doctor or bandwidth check can leave the local rank holding GPU memory or waiting for rendezvous long after the requested timeout. This shell-timeout behavior was reproduced locally with a harmless child process. Start the local probe in a separate session and terminate its entire process group on timeout or interruption.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed (subprocess.run with shell=True and a timeout leaves the shell's child running). Fixed in cc58936: the local rank runs in its own session through _run_in_own_group, and a timeout or an interrupt stops the whole group with SIGTERM, then SIGKILL, even when the shell already exited and torchrun still holds the pipe. Covered by test_a_timed_out_local_probe_stops_its_whole_process_group, with a real child process.

subprocess.run(shell=True, timeout=...) kills only the shell, so a timed-out
bandwidth check or spark doctor left torchrun and its worker holding the GPU
and waiting for rendezvous. The local rank now runs in its own session and a
timeout or interrupt stops the whole group (SIGTERM, then SIGKILL).
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Unknown error
ℹ️ 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 Review: Didn't find any major issues. 🚀

Reviewed commit: cc58936264

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

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b70d4ec4ec

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

Comment thread studio/spark_cluster.py
Comment on lines +357 to +361
for var in ("UNSLOTH_STUDIO_HOME", "STUDIO_HOME"):
value = os.environ.get(var)
if value:
return Path(value).expanduser()
return Path.home() / ".unsloth" / "studio"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor UNSLOTH_HOME when resolving the Studio root

When Studio is installed with only UNSLOTH_HOME set, this resolver uses ~/.unsloth/studio instead of <UNSLOTH_HOME>/studio, unlike the installer and existing Studio root resolvers. Consequently, provision_paths() skips the actual managed venv (or copies an older default installation), while managed_torchrun() and venv_activate() also select the wrong environment. Pairing can therefore report success without provisioning the environment needed by subsequent training launches. Resolve the root using the existing root precedence, including UNSLOTH_HOME, rather than falling directly back to the legacy location.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b3502ba. _studio_root() now follows the same order as storage_roots: UNSLOTH_STUDIO_HOME / STUDIO_HOME first, then <UNSLOTH_HOME>/studio, then the legacy ~/.unsloth/studio. Blank values count as unset. provision_paths(), config_path(), managed_torchrun() and venv_activate() all read it, so an install made with only UNSLOTH_HOME now provisions and activates its own venv. test_provision_paths_follow_unsloth_home covers this, including an explicit Studio home still winning, and fails without the change.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: b3502ba7b3

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

@Imagineer99

Copy link
Copy Markdown
Member

Reproduced a checkpoint-loss bug at b3502ba. When I reused a --save directory and simulated the peer launch failing with SSH exit 255, the launcher deleted the existing local stage1/adapter_model.safetensors and requested deletion of stage1 on the peer. The new run never started. Cleanup code

Could we reject a save directory that already contains a checkpoint before touching either node? A regression test could simulate a failed peer launch and verify that the existing checkpoint is preserved.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicts# edge case# new-feature# refactor# security# Moves a security boundary: sandbox, allowlist, permission or network guard >3000#

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants