Skip to content

Commit e5c8808

Browse files
committed
- fixed thread-safety test
- moved asserts to load_hparams
1 parent 60be2e2 commit e5c8808

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/llama-graph.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,6 +1856,9 @@ llm_graph_input_mem_hybrid * llm_graph_context::build_inp_mem_hybrid() const {
18561856
void llm_graph_context::build_dense_out(
18571857
ggml_tensor * dense_2,
18581858
ggml_tensor * dense_3) const {
1859+
if (!cparams.embeddings) {
1860+
return;
1861+
}
18591862
ggml_tensor * cur = res->get_embd_pooled();
18601863
if (dense_2 != nullptr) {
18611864
cur = ggml_mul_mat(ctx0, dense_2, cur);

src/llama-model.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,9 @@ void llama_model::load_hparams(llama_model_loader & ml) {
12301230
ml.get_key(LLM_KV_DENSE_3_FEAT_IN, hparams.dense_3_feat_in, false);
12311231
ml.get_key(LLM_KV_DENSE_3_FEAT_OUT, hparams.dense_3_feat_out, false);
12321232

1233+
GGML_ASSERT((hparams.dense_2_feat_in == 0 || hparams.dense_2_feat_in == hparams.n_embd) && "dense_2_feat_in must be equal to n_embd");
1234+
GGML_ASSERT((hparams.dense_3_feat_out == 0 || hparams.dense_3_feat_out == hparams.n_embd) && "dense_3_feat_out must be equal to n_embd");
1235+
12331236
switch (hparams.n_layer) {
12341237
case 24: type = LLM_TYPE_0_3B; break;
12351238
default: type = LLM_TYPE_UNKNOWN;
@@ -3678,9 +3681,7 @@ bool llama_model::load_tensors(llama_model_loader & ml) {
36783681

36793682
// Dense linear weights
36803683
dense_2_out_layers = create_tensor(tn(LLM_TENSOR_DENSE_2_OUT, "weight"), {n_embd, hparams.dense_2_feat_out}, TENSOR_NOT_REQUIRED);
3681-
GGML_ASSERT((dense_2_out_layers == nullptr || hparams.dense_2_feat_in == n_embd) && "dense_2_feat_in must be equal to n_embd");
36823684
dense_3_out_layers = create_tensor(tn(LLM_TENSOR_DENSE_3_OUT, "weight"), {hparams.dense_3_feat_in, n_embd}, TENSOR_NOT_REQUIRED);
3683-
GGML_ASSERT((dense_3_out_layers == nullptr || hparams.dense_3_feat_out == n_embd) && "dense_3_feat_out must be equal to n_embd");
36843685

36853686

36863687
for (int i = 0; i < n_layer; ++i) {

0 commit comments

Comments
 (0)