Skip to content

Studio: ship ggml-rpc-server with the llama.cpp bundle and locate it - #18276

Open
danielhanchen wants to merge 4 commits into
mainfrom
cluster/rpc-server-bundle
Open

danielhanchen wants to merge 4 commits into
mainfrom
cluster/rpc-server-bundle

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

First PR of the multi-machine serving stack (#4858). It only makes sure ggml-rpc-server is installed beside llama-server and can be found. This was previously part of #10280, which also carries the DGX Spark toolkit; that toolkit is now optional and stacked on top of this PR.

What changes

  • Prebuilt installs (studio/install_llama_prebuilt.py):
    • keep ggml-rpc-server (and the older rpc-server name) from the bundle;
    • set its exec bit, which extraction does not keep;
    • re-extract an install whose tag matches but which has the ggml-rpc client library and not the server. This is the same backfill path as the DiffusionGemma visual server: bundle_backfill_reason names what is missing.
    • Published bundles from before build 10796 never shipped the server, so they are not re-extracted for it.
  • Source builds:
    • setup.sh and setup.ps1 configure with -DGGML_RPC=ON -DGGML_RPC_RDMA=OFF.
    • They build the rpc-server target, read from tools/rpc/CMakeLists.txt (ggml-rpc-server, or rpc-server on older trees).
    • A reused build that predates the target gets it built in place. If that is not possible (no configured build directory, no cmake), you get a note instead of a failure.
    • A build directory that moved after it was configured cannot be built in place, because cmake refuses it. Setup rebuilds it instead, at most once.
    • On macOS, if the build links librdma even with GGML_RPC_RDMA=OFF, setup rebuilds without RPC and marks the build, so later runs do not try again. That rebuild still produces llama-server, llama-quantize, llama-fit-params and the diffusion visual server.
  • Locating the server: studio/llama_rpc.py resolves it the way the installer places it:
    • it looks in the managed bundle first: UNSLOTH_LLAMA_CPP_PATH, else the master root (UNSLOTH_HOME, or the root setup recorded in the Studio tree), else the Studio root. Then it tries ~/src/llamacpp-rpc, then PATH;
    • it checks build/bin, build/bin/Release, bin and the root in that order;
    • the platform's own spelling comes first, and on Windows a file only counts as executable by its suffix.
    • It is standard library only, so the installer, the worker CLI and serving can all import it.

Nothing runs the server yet. The next PR in the stack uses it to split a GGUF across machines.

Tests

  • tests/studio/install/test_source_build_rpc_server.py: the shell and PowerShell target detection, a reused build that predates the target, and the messages when it cannot be built.
  • test_install_llama_prebuilt_logic.py:
    • the server is in every runtime allowlist;
    • the backfill is owed only when the client library is present, and the legacy name counts;
    • a tarball that lost its exec bit still ends up executable where llama_rpc finds it.
  • tests/studio/test_llama_rpc_binary.py: on Windows the .exe wins over a stray extensionless file and a non-executable file is rejected; POSIX requires the exec bit; the search order follows the platform.
  • The whole tests/studio/install directory: 10517 passed, 118 skipped. 21 failures in test_dependency_pass_skips.py fail the same way on current main on this host.
  • A real source build: with the same flags setup.sh uses, the target detected from the llama.cpp tree (ggml-rpc-server) builds and --help runs. llama_rpc.rpc_server_binary() then returns that binary.

Prebuilt installs keep ggml-rpc-server (and the legacy rpc-server name) from the
bundle, set its exec bit, and re-extract a tag-matching install that has the
ggml-rpc client library but lost the server. Source builds turn on GGML_RPC and
build the rpc-server target, including a reused build that predates it.
studio/llama_rpc.py finds the server the same way the installer places it.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 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-18T11:52:20.221558Z c2ec612 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.

@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: 5671d1b7cc

ℹ️ 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/setup.sh
Comment on lines +1168 to +1171
if ! grep -q '^GGML_RPC:BOOL=ON' "$_dir/build/CMakeCache.txt"; then
run_quiet_no_exit "enable GGML_RPC (existing install)" cmake -S "$_dir" -B "$_dir/build" -DGGML_RPC=ON -DGGML_RPC_RDMA=OFF || true
fi
if run_quiet_no_exit "build $_target (existing install)" cmake --build "$_dir/build" --config Release --target "$_target" -j"$_jobs"; then

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 Handle relocated build caches before backfilling RPC

For an existing source install created by setup.sh, this backfill cannot reuse the configured build directory: the source-build section configures under ${LLAMA_CPP_DIR}.build.$$ and then moves that tree to $LLAMA_CPP_DIR, leaving absolute temporary paths in CMakeCache.txt and the generated build files. Reproducing that configure/move/backfill sequence makes CMake reject this reconfiguration because the source and cache directories have changed, and the subsequent build cannot build the missing target. Consequently, managed source installations predating this change remain without the RPC server on every setup rerun, even when CMake is available. Handle the relocated cache or configure a fresh build directory while preserving the existing backend options.

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: source builds are staged in llama.cpp.build. and moved, so cmake refuses the moved cache (reproduced with a real cmake in test_cmake_really_refuses_a_moved_build_and_the_check_sees_it). Fixed in e5343ff: setup.sh and setup.ps1 detect a moved build that never enabled RPC and rebuild once through the normal source build, the in-place backfill no longer runs cmake against a moved cache, and the macOS no-RPC fallback marks its build so it is not rebuilt on every run.

…t in place

Source builds are configured in llama.cpp.build.<pid> and moved into place, so
their CMakeCache still names the staging directory and cmake refuses to
reconfigure or build there. A reused build that predates ggml-rpc-server could
therefore never gain it. setup.sh and setup.ps1 now notice a moved build
directory that never enabled RPC and rebuild once, the backfill no longer runs
cmake against a moved cache, and the macOS no-RPC fallback marks its build so
it is not rebuilt on every run.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: e5343ff7c9

ℹ️ 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: 9f4af2ae3f

ℹ️ 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/llama_rpc.py
override = (os.environ.get("UNSLOTH_LLAMA_CPP_PATH") or "").strip()
if override:
return Path(override).expanduser()
root = _studio_root()

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 locating the managed RPC server

For installations configured with UNSLOTH_HOME=/custom/root, without an explicit UNSLOTH_LLAMA_CPP_PATH, this resolver searches the wrong bundle directory. setup.sh selects _MASTER_ROOT ahead of the Studio home and installs into $UNSLOTH_HOME/llama.cpp, but this helper ignores that variable and returns either ~/.unsloth/llama.cpp or <studio home>/llama.cpp. Consequently, rpc_server_binary() returns None for an installed executable (or selects an unrelated fallback). Honor the installer's master-root precedence before deriving the bundle from the Studio home.

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 c2ec612. llama_bundle_dir() now checks the master root before the Studio home, the same way storage_roots.unsloth_home() does: UNSLOTH_HOME (blank counts as unset), else the root setup recorded in <studio>/share/.unsloth-master-root, but only while that root exists and contains Studio. An explicit UNSLOTH_LLAMA_CPP_PATH still comes first. Tests in tests/studio/test_llama_rpc_binary.py cover UNSLOTH_HOME, the recorded note and a note that does not contain Studio. Two of them fail on the previous head.

@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: 9f4af2ae3f

ℹ️ 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/setup.sh
Comment on lines +1234 to +1237
if [ "$BUILD_OK" = true ]; then
run_quiet_no_exit "build llama-quantize (no rpc)" cmake --build "$_BUILD_TMP/build" --config Release --target llama-quantize -j"$NCPU" || true
run_quiet_no_exit "build diffusion visual server (no rpc)" cmake --build "$_BUILD_TMP/build" --config Release --target llama-diffusion-gemma-visual-server -j"$NCPU" || true
fi

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 Rebuild the Metal memory probe after clearing the build tree

On macOS, when the RDMA gate triggers the no-RPC rebuild, deleting build also deletes the llama-fit-params executable built immediately before this helper runs. This replacement build restores the server, quantizer and visual server, but never restores that probe. Consequently, an otherwise successful Metal installation loses its measured-memory fitting behavior: _metal_demand_paged_embedding_bytes() in studio/backend/core/inference/llama_cpp.py keeps input embeddings charged when the probe is absent, reducing the usable model/context budget. Rebuild llama-fit-params in this fallback as well.

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 c2ec612. The no-RPC rebuild only runs on macOS, and it wipes the build directory, so it now rebuilds llama-fit-params after llama-quantize, best-effort like the first pass. test_macos_rdma_leak_rebuilds_without_rpc_from_the_active_args now expects that target in the rebuild 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 them coming!

Reviewed commit: c2ec61292f

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant