Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion examples/models/gemma4_31b/gemma4_31b_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,15 @@ Result<std::unique_ptr<Gemma4_31BEngine>> Gemma4_31BEngine::create(
}
}
#elif defined(EXECUTORCH_BUILD_MLX)
mutable_state = std::make_unique<GemmaMutableStateContextOwner>();
// Only enable the per-session mutable-buffer path when actually serving more
// than one session. For a single session (the CLI runner) the rebind would
// allocate a second copy of the KV-cache buffers on top of the program's
// default buffers — doubling KV-cache memory and adding a one-time
// session-buffer allocation during the first prefill — for no isolation
// benefit. Leaving mutable_state null keeps the program's default buffers.
if (config.max_sessions > 1) {
mutable_state = std::make_unique<GemmaMutableStateContextOwner>();
}
#endif

auto module_res = mutable_state != nullptr
Expand Down
Loading