Skip to content

Commit a6647b1

Browse files
authored
common : use hf primary split as model path (ggml-org#25194)
Fixes ggml-org#25181
1 parent 13e6738 commit a6647b1

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

common/arg.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -496,13 +496,15 @@ void common_models_handler_apply(common_models_handler & handler, common_params
496496
}
497497

498498
// handle hf_plan tasks
499-
auto add_tasks = [&opts, &tasks](const hf_cache::hf_files & model_files, common_params_model & model) {
499+
auto add_tasks = [&opts, &tasks](const hf_cache::hf_files & model_files,
500+
const hf_cache::hf_file & primary,
501+
common_params_model & model) {
500502
for (size_t i = 0; i < model_files.size(); ++i) {
501503
auto & model_file = model_files[i];
502-
bool is_first = (i == 0);
503-
tasks.emplace_back(model_file, opts, [&, is_first]() {
504-
if (is_first) {
505-
// only use first part as model path
504+
bool is_primary = (model_file.path == primary.path);
505+
tasks.emplace_back(model_file, opts, [&, is_primary]() {
506+
if (is_primary) {
507+
// the primary file is the first split (00001-of), use it as model path
506508
model.path = hf_cache::finalize_file(model_file);
507509
} else {
508510
hf_cache::finalize_file(model_file);
@@ -511,7 +513,7 @@ void common_models_handler_apply(common_models_handler & handler, common_params
511513
}
512514
};
513515
if (!plan.model_files.empty()) {
514-
add_tasks(plan.model_files, params.model);
516+
add_tasks(plan.model_files, plan.primary, params.model);
515517
}
516518
if (!plan.mmproj.local_path.empty()) {
517519
tasks.emplace_back(plan.mmproj, opts, [&]() {
@@ -539,12 +541,12 @@ void common_models_handler_apply(common_models_handler & handler, common_params
539541

540542
// handle plan_spec (e.g. --spec-draft-hf)
541543
if (!plan_spec.model_files.empty()) {
542-
add_tasks(plan_spec.model_files, params.speculative.draft.mparams);
544+
add_tasks(plan_spec.model_files, plan_spec.primary, params.speculative.draft.mparams);
543545
}
544546

545547
// handle vocoder plan (e.g. --hf-repo-v)
546548
if (!plan_voc.model_files.empty()) {
547-
add_tasks(plan_voc.model_files, params.vocoder.model);
549+
add_tasks(plan_voc.model_files, plan_voc.primary, params.vocoder.model);
548550
}
549551

550552
// run all tasks in parallel

0 commit comments

Comments
 (0)