Skip to content

Commit d83e3b0

Browse files
committed
model : fix meta-split lookup for archs with aliased cache slots
Cache tensors of archs that alias physical blocks across looped slots (hrm_text, nanbeige with num_loops > 1) can reference block indices without weight tensor names. Take the output projection from the layer array instead of asserting; all other lookups are unchanged.
1 parent 884a469 commit d83e3b0

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎src/llama-model.cpp‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,11 @@ struct ggml_backend_meta_split_state llama_meta_device_get_split_state(const str
464464
rotation = hparams.n_layer() % ud->n_devices;
465465
}
466466
const ggml_tensor * tensor_axis_0 = suffix.empty() ? tensor : ud->model->get_tensor((prefix + suffix).c_str());
467+
if (tensor_axis_0 == nullptr && tensor_name.compare(0, 6, "cache_") == 0 && il < hparams.n_layer()) {
468+
// the hrm_text cache slots alias physical blocks, so a cache tensor can reference a block
469+
// index with no weight tensor names and the output projection has to come from the layer array
470+
tensor_axis_0 = ud->model->layers[il].wo;
471+
}
467472
if (tensor_axis_0 == nullptr) {
468473
GGML_ASSERT(!suffix_fallback.empty());
469474
tensor_axis_0 = ud->model->get_tensor((prefix + suffix_fallback).c_str());

0 commit comments

Comments
 (0)