Entropic 2.14.3
Local-first agentic inference engine
Loading...
Searching...
No Matches
session_pool_util.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
41#pragma once
42
44
45#include <algorithm>
46#include <string>
47
48namespace entropic {
49
52 int n_seq_max = 1;
53 bool kv_unified = false;
54 int n_ctx = 0;
55 int temp_seq_base = 1;
56};
57
67 const int sessions = std::max(1, cfg.max_sessions);
68 const int parallel = std::max(1, cfg.n_parallel);
69
71 g.n_seq_max = std::max(parallel, sessions);
72 // gh#98's same-prefix batch fan-out REQUIRES a unified buffer (seq_cp
73 // asserts on per-sequence buffers), so preserve that exactly — but a
74 // session pool must NOT be unified, per the header. The two are made
75 // mutually exclusive at configure time, so this can never be asked to
76 // satisfy both.
77 g.kv_unified = (parallel > 1) && (sessions <= 1);
78 // context_length is PER SESSION.
79 g.n_ctx = cfg.context_length * sessions;
80 // Sessions own seq ids [0, sessions). The batch fan-out's temp ids must
81 // start above them: allocate_temp_seq_id hands out 1, 2, 3... which
82 // would otherwise collide with session slots. The configure-time
83 // exclusion already makes this unreachable; raising the base is defence
84 // in depth against a future change that removes the exclusion silently.
85 g.temp_seq_base = std::max(1, sessions);
86 return g;
87}
88
101inline std::string session_pool_conflict_reason(const ModelConfig& cfg) {
102 std::string reason;
103 if (cfg.max_sessions > 1) {
104 if (cfg.n_parallel > 1) {
105 reason = "max_sessions > 1 conflicts with n_parallel > 1: a "
106 "session pool needs private per-session KV streams, "
107 "while the same-prefix batch fan-out "
108 "(entropic_run_batch) needs a unified buffer. Set one "
109 "or the other, not both.";
110 } else if (cfg.context_length <= 0) {
111 reason = "max_sessions > 1 requires a positive context_length: "
112 "the pool allocates context_length * max_sessions "
113 "cells.";
114 }
115 }
116 return reason;
117}
118
119} // namespace entropic
Configuration structs with defaults.
Activate model on GPU (WARM → ACTIVE).
@ optional
optional: every escape asks the host's path approver
PoolGeometry derive_pool_geometry(const ModelConfig &cfg)
Derive the context geometry a tier's config implies.
std::string session_pool_conflict_reason(const ModelConfig &cfg)
Why this tier's session-pool request cannot be honoured.
Model configuration for a single tier.
Definition config.h:154
Context geometry derived from a tier's session-pool request.
int n_seq_max
cparams.n_seq_max
int n_ctx
cparams.n_ctx (TOTAL cells, all streams)
int temp_seq_base
First seq id the batch fan-out may use.
bool kv_unified
cparams.kv_unified