@@ -61,8 +61,11 @@ struct LLMServingCapacity {
6161 // sessions would copy the whole model); raise only on a backend proven to
6262 // share packed weights.
6363 int32_t max_physical_sessions_without_weight_duplication = 1 ;
64- // Planned bytes one session adds (KV + activations), for memory-budget
65- // admission. 0 = unknown; the server skips the memory clamp.
64+ // Planned bytes one session adds (KV + activations). Reported for a FUTURE
65+ // memory-budget admission policy; NOT yet enforced -- admission is currently
66+ // by session COUNT only (--max-sessions). Over-provisioning therefore fails
67+ // at the first execute (cudaMalloc) of the over-committed session, not at
68+ // admit time. 0 = unknown.
6669 int64_t estimated_bytes_per_session = 0 ;
6770};
6871
@@ -79,14 +82,28 @@ class ET_EXPERIMENTAL LLMSession {
7982 // / `initial_sampling` (optional): the sampling config for the FIRST generated
8083 // / token, for backends that sample during prefill (e.g. in-graph sampling).
8184 // / Pass it so the first token uses the request's sampling instead of a stale
82- // / default. Backends that only sample in decode_one() ignore it.
85+ // / default. Backends that only sample in decode_one() ignore it. NOTE:
86+ // / because the first token is sampled here, it does NOT pass through
87+ // / decode_one()'s logit processors -- a grammar/tool mask that must constrain
88+ // / the opening token is not applied to it (a known limitation for
89+ // / grammar-constrained serving).
90+ // /
91+ // / ERROR CONTRACT: an error may be returned AFTER backend state has already
92+ // / mutated. On any error from prefill_tokens()/decode_one(), the session is
93+ // / POISONED -- position() may no longer agree with the resident KV. The
94+ // / caller must call reset() (and only proceed once it returns Ok) before any
95+ // / further prefill/decode; it must NOT retry the failed call. The serving
96+ // / worker enforces this (marks the session dirty and forces a reset next
97+ // / request).
8398 virtual ::executorch::runtime::Error prefill_tokens (
8499 std::vector<uint64_t > tokens,
85100 const SamplingConfig* initial_sampling = nullptr ) = 0;
86101
87102 // / Decode one token from the pending state; looping reproduces a full
88103 // / generation while returning exact sampled token ids. A single decode_one()
89104 // / runs one forward pass and is not interruptible mid-call (see stop()).
105+ // / On error the session is poisoned -- see the error contract on
106+ // / prefill_tokens() (reset() before any further use; never retry).
90107 virtual ::executorch::runtime::Result<DecodeResult> decode_one (
91108 const SamplingConfig& sampling) = 0;
92109
0 commit comments