@@ -16191,7 +16191,7 @@ struct llm_build_plamo2 : public llm_graph_context_mamba {
1619116191 {
1619216192 // PLaMo-2 uses combined QKV tensor
1619316193 ggml_tensor * qkv = build_lora_mm(model.layers[il].wqkv, cur);
16194- cb(qkv, "qkv ", il);
16194+ cb(qkv, "wqkv ", il);
1619516195
1619616196 // split QKV tensor into Q, K, V
1619716197 const int64_t n_embd_head_q = hparams.n_embd_head_k;
@@ -16231,7 +16231,7 @@ struct llm_build_plamo2 : public llm_graph_context_mamba {
1623116231 ext_factor, attn_factor, beta_fast, beta_slow
1623216232 );
1623316233
16234- cur = build_attn(inp, model.layers[il].wo, NULL, Qcur, Kcur, Vcur, NULL, NULL, 1.0f, il);
16234+ cur = build_attn(inp, model.layers[il].wo, NULL, Qcur, Kcur, Vcur, NULL, NULL, 1.0f/sqrtf(float(n_embd_head_v)) , il);
1623516235 }
1623616236
1623716237 cb(cur, "attn_out", il);
@@ -16306,8 +16306,9 @@ struct llm_build_plamo2 : public llm_graph_context_mamba {
1630616306 ggml_build_forward_expand(gf,
1630716307 ggml_cpy(ctx0, last_conv,
1630816308 ggml_view_1d(ctx0, conv_states_all,
16309- (d_conv - 1)*(d_inner)*(n_seqs),
16310- kv_head*(d_conv - 1)*(d_inner)*ggml_element_size(conv_states_all))));
16309+ (d_conv - 1)*(d_inner + 2*n_group*d_state)*(n_seqs),
16310+ kv_head*(d_conv - 1)*(d_inner + 2*n_group*d_state)*ggml_element_size(conv_states_all))));
16311+ cb(conv_states_all, "mamba_conv1d_state", il);
1631116312
1631216313 // 1D convolution
1631316314 x = ggml_ssm_conv(ctx0, conv_x, model.layers[il].ssm_conv1d);
@@ -16370,9 +16371,9 @@ struct llm_build_plamo2 : public llm_graph_context_mamba {
1637016371 // store last states
1637116372 ggml_build_forward_expand(gf,
1637216373 ggml_cpy(ctx0,
16373- ggml_view_1d(ctx0, y_ssm, d_state*d_inner* n_seqs, x->nb[3]*x->ne[3] ),
16374- ggml_view_1d(ctx0, ssm_states_all, d_state*d_inner* n_seqs,
16375- kv_head*d_state*d_inner*ggml_element_size (ssm_states_all))) );
16374+ ggml_view_1d(ctx0, y_ssm, n_heads*head_dim*d_state* n_seqs, n_heads*head_dim*n_seq_tokens*n_seqs*ggml_element_size(y_ssm) ),
16375+ ggml_view_1d(ctx0, ssm_states_all, n_heads*head_dim*d_state* n_seqs, kv_head*n_seqs*n_heads*head_dim*d_state*ggml_element_size(ssm_states_all))));
16376+ cb (ssm_states_all, "mamba_ssm_states", il );
1637616377
1637716378 ggml_tensor * y = ggml_view_4d(ctx0, y_ssm, head_dim, n_heads, n_seq_tokens, n_seqs, head_dim * ggml_element_size(x), head_dim * n_heads * ggml_element_size(x), head_dim * n_heads * n_seq_tokens * ggml_element_size(x), 0);
1637816379 cb(y, "mamba_y_view", il);
0 commit comments