@@ -142,33 +142,6 @@ ET_EXPERIMENTAL std::unique_ptr<TextLLMRunner> create_text_llm_runner(
142142 const std::string& method_name = " forward" ,
143143 Module::LoadMode load_mode = Module::LoadMode::MmapUseMlockIgnoreErrors);
144144
145- /* *
146- * @brief Creates a TextLLMRunner over an already-loaded Program.
147- *
148- * Unlike create_text_llm_runner(model_path, ...), this does not load the model
149- * file again: the resulting runner's Module reuses `program` while owning its
150- * own method state and KV cache. This is the per-session construction path for
151- * TextLLMEngine — N sessions reuse one loaded Program but isolate their mutable
152- * KV state. Whether they also avoid re-materializing packed weights per session
153- * is backend-dependent (serving_capacity() is authoritative).
154- *
155- * The caller must keep the DataLoader backing `program` alive for the lifetime
156- * of every runner created from it (TextLLMEngine holds the loader Module).
157- *
158- * @param program Shared, already-loaded program.
159- * @param tokenizer Initialized tokenizer instance (owned by the new runner).
160- * @param temperature Optional temperature (deprecated; prefer
161- * GenerationConfig).
162- * @param method_name Name of the method to execute in the model.
163- * @return std::unique_ptr<TextLLMRunner> on success, or nullptr on failure.
164- */
165- ET_EXPERIMENTAL std::unique_ptr<TextLLMRunner>
166- create_text_llm_runner_from_program (
167- std::shared_ptr<Program> program,
168- std::unique_ptr<::tokenizers::Tokenizer> tokenizer,
169- float temperature = -1 .0f ,
170- const std::string& method_name = " forward" );
171-
172145/* *
173146 * @brief Engine for multi-session text generation over one loaded Program.
174147 *
@@ -225,6 +198,20 @@ class ET_EXPERIMENTAL TextLLMEngine : public LLMEngine {
225198 std::unordered_map<std::string, int64_t > metadata_;
226199};
227200
201+ namespace detail {
202+ // Implementation detail (not a public API): wraps a TextLLMRunner in an
203+ // LLMSession (the runner -> session seam). The supported entry point is
204+ // LLMEngine::create_session(); this exists only so TextLLMEngine can build its
205+ // sessions and so unit tests can drive the runner's token-step primitives
206+ // through the public LLMSession surface (the concrete adapter type is private).
207+ // Do not depend on wrapping arbitrary runners.
208+ //
209+ // @param runner A loaded TextLLMRunner; ownership transfers to the session.
210+ // @return std::unique_ptr<LLMSession> wrapping `runner`.
211+ std::unique_ptr<LLMSession> make_text_llm_session (
212+ std::unique_ptr<TextLLMRunner> runner);
213+ } // namespace detail
214+
228215/* *
229216 * @brief Creates a MultimodalRunner instance with dependency injection
230217 *
0 commit comments