Skip to content

Commit 6edbb17

Browse files
committed
[UPDATE] Update
[ghstack-poisoned]
1 parent 4648639 commit 6edbb17

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

extension/llm/runner/llm_session.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,11 @@ class ET_EXPERIMENTAL LLMSession {
9090
virtual ::executorch::runtime::Result<DecodeResult> decode_one(
9191
const SamplingConfig& sampling) = 0;
9292

93-
/// Rewind the KV cache to `pos` (prefix reuse). Valid for full-KV models;
94-
/// sliding-window KV may reject a seek past its window (the caller falls back
95-
/// to a fresh prefill).
93+
/// Rewind the KV cache to `pos` (prefix reuse). Valid for full-KV models.
94+
/// Returns InvalidArgument if `pos` is outside [0, position()]. Returns
95+
/// NotSupported for models whose state cannot be safely rewound (for example,
96+
/// non-KV-cache, sliding-window, or recurrent-state models); callers should
97+
/// fall back to reset() + full prefill.
9698
virtual ::executorch::runtime::Error seek(int64_t pos) = 0;
9799

98100
/// Number of tokens with resident KV (upper bound for seek()).

extension/llm/runner/util.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,14 @@ ET_EXPERIMENTAL size_t inline utf8_complete_prefix_len(const std::string& s) {
101101

102102
// How many leading bytes of `text` a streaming consumer may safely emit given a
103103
// set of `stops` strings, and whether a stop was hit (`stop_hit`).
104-
// * If any stop occurs, returns the byte offset of the EARLIEST occurrence and
105-
// sets stop_hit=true — text before it is safe; the stop and everything after
106-
// are dropped (the stop is excluded from output).
104+
// * If any stop occurs, returns the byte offset of the EARLIEST occurrence
105+
// and
106+
// sets stop_hit=true — text before it is safe; the stop and everything
107+
// after are dropped (the stop is excluded from output).
107108
// * Otherwise returns the length minus the longest possible partial-stop tail
108-
// (max(len(stop))-1 bytes), snapped DOWN to a UTF-8 boundary so a multi-byte
109-
// character is never split; stop_hit=false. Holding back that tail lets a
110-
// stop that straddles the next piece still be caught.
109+
// (max(len(stop))-1 bytes), snapped DOWN to a UTF-8 boundary so a
110+
// multi-byte character is never split; stop_hit=false. Holding back that
111+
// tail lets a stop that straddles the next piece still be caught.
111112
// `text` is expected to be complete-UTF-8 (e.g. the assembled output of
112113
// utf8_complete_prefix_len). Empty `stops` => emit everything, no hold-back.
113114
ET_EXPERIMENTAL size_t inline stop_safe_prefix_len(

0 commit comments

Comments
 (0)