Skip to content

Commit dc1d109

Browse files
committed
mamba : fix mismatched new and delete size for llm_build_mamba
Subclasses of llm_graph_context cannot have extra fields, because the called destructor is not the one from the subclass. This otherwise would cause problems when runnning Mamba-(1|2) inference when compiled -DGGML_SANITIZE_ADDRESS=ON
1 parent afdb669 commit dc1d109

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/llama-model.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9198,9 +9198,7 @@ struct llm_build_starcoder2 : public llm_graph_context {
91989198
};
91999199

92009200
struct llm_build_mamba : public llm_graph_context {
9201-
const llama_model & model;
9202-
9203-
llm_build_mamba(const llama_model & model, const llm_graph_params & params, ggml_cgraph * gf) : llm_graph_context(params), model(model) {
9201+
llm_build_mamba(const llama_model & model, const llm_graph_params & params, ggml_cgraph * gf) : llm_graph_context(params) {
92049202
ggml_tensor * cur;
92059203
ggml_tensor * inpL;
92069204

@@ -9219,9 +9217,9 @@ struct llm_build_mamba : public llm_graph_context {
92199217
cb(cur, "attn_norm", il);
92209218

92219219
if (model.arch == LLM_ARCH_MAMBA2) {
9222-
cur = build_mamba2_layer(rs_inp, gf, cur, ubatch, il);
9220+
cur = build_mamba2_layer(rs_inp, gf, cur, model, ubatch, il);
92239221
} else {
9224-
cur = build_mamba_layer(rs_inp, gf, cur, ubatch, il);
9222+
cur = build_mamba_layer(rs_inp, gf, cur, model, ubatch, il);
92259223
}
92269224

92279225
if (il == n_layer - 1 && inp_out_ids) {
@@ -9260,6 +9258,7 @@ struct llm_build_mamba : public llm_graph_context {
92609258
llm_graph_input_rs * inp,
92619259
ggml_cgraph * gf,
92629260
ggml_tensor * cur,
9261+
const llama_model & model,
92639262
const llama_ubatch & ubatch,
92649263
int il) const {
92659264
const auto * mctx_cur = static_cast<const llama_memory_recurrent_context *>(mctx);
@@ -9398,6 +9397,7 @@ struct llm_build_mamba : public llm_graph_context {
93989397
llm_graph_input_rs * inp,
93999398
ggml_cgraph * gf,
94009399
ggml_tensor * cur,
9400+
const llama_model & model,
94019401
const llama_ubatch & ubatch,
94029402
int il) const {
94039403
const auto * mctx_cur = static_cast<const llama_memory_recurrent_context *>(mctx);

0 commit comments

Comments
 (0)