Repository navigation
feat(params): with_tensor_split to set each device's share of the model - #1129
Merged
Merged
Conversation
Contributor
|
needs a fmt |
…odel `tensor_split` was reachable only as an output of `fit_params`, so a caller who had computed its own placement — which is the whole point of driving several RPC devices — had no way to hand it to llama.cpp. The pointer llama.cpp keeps addresses the `Vec`'s heap buffer rather than this struct, so it survives the moves builder chaining performs; a test pins that. The slice is padded to `llama_max_devices()` because the C API reads that many entries, and an empty slice restores llama.cpp's free-memory default.
hxphsts
force-pushed
the
feat/with-tensor-split
branch
from
October 2, 2026 15:17
db36d61 to
613299f
Compare
Contributor
Author
|
@MarcusDunn The branch was rebased from latest main, and fmt was run |
MarcusDunn
approved these changes
Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
LlamaModelParams::with_tensor_split(&[f32]), the safe setter forllama_model_params::tensor_split: the proportion of the model each device inwith_devicesreceives. The slice is copied into the params struct's fixed-size array (LLAMA_MAX_DEVICES), with the remaining entries zeroed, so the caller never touches raw pointers or the array length. Also exposes the current value viatensor_split().Why
with_devicesselects which backends load a model, but withouttensor_splitllama.cpp decides the proportions by free memory alone. A caller placing a model deliberately (a small GPU beside a large one, or a device that should hold a fixed share) has no way to say so from the Rust side today, althoughllama-cli --tensor-splitexposes it. This is the last piece ofllama_model_paramsaround device placement not reachable from the safe API.Scope is deliberately just the params setter, in the spirit of the "safe API to the core llama.cpp features" scoping in #809.
Test
cargo check -p llama-cpp-2on this branch; used in a downstream crate that splits a 26B model across two machines' GPUs by explicit proportions.