feat: external PLE file loading (#31185)
* model : allow loading external PLE files
Assisted-by: Codex
* convert : add separate PLE exports
Assisted-by: Codex
* tests : fix PLE export test lint
Assisted-by: Codex
* model : make --ple an alias of --shard, allow multiple shard locations
Reuse the multi-shard loading path for external PLE files instead of a
separate option.
* --ple is an alias of --shard: both take a comma separated list and may
be given more than once, and the shards may live anywhere
* metadata comes from the main file; numbered shards are still
auto-discovered and strictly validated
* explicit files outside the discovered set are appended as extra shards,
exempt from split.no and split.count checks
* -isnm/--ignore-shard-num-mismatch loads only the given files, in order,
with no auto-discovery and no split metadata validation
* ple_path, path_ple and llama_model_loader::add_ple_file are removed;
common_model_load() uses llama_model_load_from_splits for two or more
paths
* common/fit.{h,cpp} take the shard path vector, so --fit and the router
memory measurement load every shard
Assisted-by: GPT-6-Astra
* rm -isnm
* make sure to dedup paths
* rm test_convert_ple
* address comments
* allow ple shard to override tensor
---------
Co-authored-by: Xuan Son Nguyen <son@huggingface.co>
This commit is contained in:
1 parent
9d340ec341
commit
5f490d7bfe
16 files changed
+317
-97
No files matched your search
@@ -245,6 +245,26 @@ static void test(void) {
|
||||
assert(true == common_params_parse(argv.size(), list_str_to_char(argv).data(), params, LLAMA_EXAMPLE_COMMON));
|
||||
assert(params.model.path == "model_file.gguf");
|
||||
|
||||
{
|
||||
auto parse_shards = [&list_str_to_char](std::vector<std::string> args) {
|
||||
common_params shard_params;
|
||||
args.insert(args.begin(), {"binary_name", "-m", "model_file.gguf"});
|
||||
assert(common_params_parse(args.size(), list_str_to_char(args).data(), shard_params, LLAMA_EXAMPLE_COMMON));
|
||||
auto paths = shard_params.model.get_paths();
|
||||
assert(paths.front() == "model_file.gguf");
|
||||
return std::vector<std::string>(paths.begin() + 1, paths.end());
|
||||
};
|
||||
assert(parse_shards({"--shard", "a.gguf"}) == std::vector<std::string>({"a.gguf"}));
|
||||
const std::vector<std::string> two = {"a.gguf", "b.gguf"};
|
||||
assert(parse_shards({"--shard", "a.gguf", "--shard", "b.gguf"}) == two);
|
||||
assert(parse_shards({"--shard", "a.gguf,b.gguf"}) == two);
|
||||
const std::vector<std::string> three = {"a.gguf", "b.gguf", "c.gguf"};
|
||||
assert(parse_shards({"--shard", "a.gguf,b.gguf", "--shard", "c.gguf"}) == three);
|
||||
assert(parse_shards({"--shard", "a.gguf", "--shard", "b.gguf", "--shard", "c.gguf"}) == three);
|
||||
assert(parse_shards({"--ple", "p.gguf"}) == parse_shards({"--shard", "p.gguf"}));
|
||||
assert(parse_shards({"--shard", "model_file.gguf,a.gguf,b.gguf,a.gguf"}) == two);
|
||||
}
|
||||
|
||||
argv = {"binary_name", "-t", "1234"};
|
||||
assert(true == common_params_parse(argv.size(), list_str_to_char(argv).data(), params, LLAMA_EXAMPLE_COMMON));
|
||||
assert(params.cpuparams.n_threads == 1234);
|
||||
|
||||
Reference in new issue
Block a user