Repository navigation
Studio: serve one GGUF across N machines over llama.cpp RPC - #13726
danielhanchen wants to merge 120 commits into
Conversation
…le ones, add a real loopback test and a user guide
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
Security findingsAdvisory findings (1)
ℹ️ 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 security review |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 974ba7fd74
ℹ️ 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 = entry.get("rpc_port", node.rpc_port) | ||
| if not isinstance(port, int) or not (0 < port < 65536): | ||
| raise ClusterConfigError(f"not a port: {entry!r}") |
There was a problem hiding this comment.
Reject boolean RPC ports in JSON configuration
JSON true and false deserialize to Python booleans, which are instances of int, so a configuration such as {"rpc_port": true} passes this validation. It subsequently produces an endpoint like host:True for llama.cpp while socket probing treats the value as port 1, yielding confusing reachability and launch failures instead of the intended configuration error; require an actual integer type and explicitly exclude booleans.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing: a boolean port is a malformed config, and llama.cpp and the reachability probe already fail on it.
There was a problem hiding this comment.
🛡️ Codex Security Review
Here are some automated security review suggestions for this pull request.
Reviewed commit: 974ba7fd74
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
| process = ss.PeerProcess( | ||
| "ggml-rpc-server", | ||
| node.ssh_target, | ||
| argv, | ||
| log_dir / f"rpc-server-{node.host}-{node.rpc_port}.log" if log_dir else None, |
There was a problem hiding this comment.
🛡️ Codex Security Review
Security: Bound managed-worker log growth
When cluster serving is enabled with a managed node, an attacker controlling or successfully impersonating that SSH endpoint can stream stdout indefinitely. This call gives PeerProcess a persistent coordinator-side log path; _drain_output() then appends and flushes every remote line without rotation, a byte limit, or rate limiting, while only the in-memory tail is bounded. The long-lived worker can therefore fill the coordinator's disk and disrupt Studio or colocated services. Use capped/rotating logs and terminate or throttle workers that exceed the budget.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing: this needs a managed node the operator listed and reaches over their own ssh keys to turn hostile, which already has far more than disk to work with; it is the same PeerProcess logging the two-Spark peer has always used.
…laced model, keep live workers, match endpoints whole, honour cancel
…oads, one projector from env, reserve KV for uncached models, retire workers when the config goes
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b264dc11ba
ℹ️ 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".
| if not any(str(a).split("=", 1)[0] in named for a in extras) and not any( | ||
| os.environ.get(k) for k in ("LLAMA_ARG_MMPROJ", "LLAMA_ARG_MMPROJ_URL") | ||
| ): |
There was a problem hiding this comment.
Account for projectors downloaded from URLs
When --mmproj-url or LLAMA_ARG_MMPROJ_URL is used, this condition suppresses sizing the automatically discovered projector, but neither sidecar_bytes() nor env_launch_files() can size the URL that llama.cpp downloads and loads. Fresh evidence after the environment-sidecar fix is that env_launch_files() deliberately returns only existing local paths, so the effective remote projector still contributes zero bytes; a near-capacity split can then OOM on projector load. Resolve the download size or conservatively avoid managed placement when it is unknown.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing: a projector given only by URL is a rare setup, and llama.cpp reports an out-of-memory load clearly; sizing a download before it exists is out of scope here.
| ctx, cache_type, cache_type_v = ss.effective_kv_settings(request, extras) | ||
| kv = 0.0 | ||
| if local_file and ctx: |
There was a problem hiding this comment.
Budget KV memory when context is automatic
Fresh evidence after the uncached-model KV fix is that LoadRequest.max_seq_length defaults to 0 and explicitly defines that value as asking llama.cpp to select a context, not as requesting a zero-length context. Here that common default leaves ctx false and therefore records zero KV bytes even for a cached GGUF whose native context is available in its header; a weights-only plan near capacity can then OOM when llama.cpp allocates the automatically selected nonzero cache. Resolve the native/fitted context before planning or conservatively reserve KV when the context is automatic.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing: with no context given llama.cpp fits the unset context to the free memory of the chosen devices (--fit, on by default in this build, minimum 4096), so no fixed KV is allocated beyond what fits.
…ojectors, honour the toggle at commit, keep workers the split uses
…drafter locally, automatic speculation off on splits, hand over cleanly to and from the two-Spark path
SparkServing.status() reports split_reload_pending; the frozen two-Spark status payloads were recorded before it existed, so the whole-dict comparison failed. Re-recorded with SPARK_GOLDEN_RECORD=1; the only change is the new key.
--n-cpu-moe 0 / --n-cpu-ffn 0 place nothing (the loader and the env twins only act on a positive count), so they no longer bypass cluster planning.
ctx_checkpoints sizes the host checkpoint pool and load_mode=mlock pins the host copy, so a config-error reload changing either must not be handed the old split. gpu_memory_mode and tensor_parallel are placement inputs too.
An automatically planned load started every managed rpc-server over ssh before probing this machine, so a model that fits locally still paid an ssh timeout per dead host and left unneeded workers running. When workers would be started and the topology is not forced to layer_split, plan this machine alone first and start workers only if it does not fit.
[skip ci]
|
Codex Review: Didn't find any major issues. Keep them coming! 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". |
…city) into #13726 [skip ci]
…aliases as one host
…e split loaded, whatever its share
|
Codex Review: Didn't find any major issues. Chef's kiss. 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". |
…rch is not installed [skip ci]
A master with no accelerator listed no local device, so the planner split even a small model across the workers. It now serves locally when the model and its context fit the usable host RAM, as a GPU master does, and splits only when it does not fit or the split is forced with UNSLOTH_CLUSTER_TOPOLOGY=layer_split.
|
Codex Review: Didn't find any major issues. Bravo. 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". |
|
Superseded by #18277, which has the same changes rebuilt on a stack that no longer needs the DGX Spark PRs: #18276 (ships #10280 and #10323 stay open as optional Spark extras stacked on top. Closing this one so review continues on #18277; the discussion here stays for reference. |
Stacked on #10323 (base
spark/serving-orchestrator). Refs #4858.#10323 serves one GGUF across exactly two paired DGX Sparks: one peer address,
--device RPC0,CUDA0, a fixed0.5,0.5split, and router slotsmain/peer. llama.cpp RPC itself takes any number of workers, so this PR lets Studio split a GGUF over N machines of any kind (more Sparks, Macs over Metal, Linux boxes with NVIDIA or AMD GPUs, or a mix), while the two-Spark path stays exactly as it is.How it works
Opt-in only. Nothing changes until the operator lists workers in
UNSLOTH_CLUSTER_NODESor<studio home>/cluster.json; with neither, every Spark code path runs unchanged.UNSLOTH_SPARK_SERVING=0still turns both off.On a load the new
core/inference/cluster_serving.py:llama-server --rpc ... --list-devicesto read each worker's devices and free memory.--rpclists the workers that exposed a device,--device RPC0,...,RPCk,<local GPU>keeps the local device last so the output layer stays here, and--tensor-splitweights each device by its usable free memory (free minus max(1 GiB, 8%), plus a 5% layer-rounding margin). Projectors, drafters and adapters are charged to the coordinator, which loads them.Nodes marked
managedgetggml-rpc-serverstarted over non-interactive ssh with the samePeerProcessmachinery the Spark peer uses (POSIXkill -0only, so it works on macOS too). A reload strips exactly the block this module appended, so inherited extras are planned afresh. The owner-only status route reports nodes, devices, plan and the exact args.spark_serving.pychanges are dispatch only (43 lines): when a cluster is configured the module-levelbefore_load/after_load/load_failed/shutdown/statusdelegate to the cluster;ssh_argvacceptsuser@hostnodes;strip_layer_split_extra_argsalso removes the cluster's own block. TheSparkServingclass, the split args, router names and status keys are untouched.User guide:
studio/MULTI_NODE_SERVING.md.Two Sparks do not break
test_spark_legacy_golden.pywas recorded on Studio: two-Spark serving orchestrator with an async replica router #10323's head before any change (first commit) and freezes every launch argv, remote command, router backend and status payload for layer split (with and without pipeline groups, with inherited extras), single, replicas before and after load, and the disabled state. It passes unchanged after the change.test_spark_serving.py,test_spark_router.py,tests/studio/*spark*andunsloth_cli/tests/test_spark_offbox.pypass with zero edits (git diffon them is empty).Evidence
before_load--rpc 127.0.0.1:51060,...,51063 --device RPC0,RPC1,RPC2,RPC3 -sm layer --tensor-split 0.25,0.25,0.25,0.25 --cache-ram 0--device RPC0,RPC1,RPC2,CUDA0tests/test_cluster_serving_e2e.pyrepeats the loopback run as a test whenUNSLOTH_TEST_RPC_BINandUNSLOTH_TEST_GGUFare set (skipped otherwise): 3 workers, the planner's own probe, a real llama-server, and a check that each worker logged a model buffer.Suites:
test_cluster_serving.py(34), goldens,test_spark_serving.py,test_spark_router.py: 217 passed, 18 skipped.tests/studio/*spark*+test_spark_offbox.py+test_source_read_encoding.py: 370 passed. Security lints (lint_av_shapes,lint_exec_literals,lint_risky_loaders) clean.Not in this PR
cluster.json.ggml-rpc-serverhas no authentication; the guide says to bind it to a trusted private network.