npuContextWindowNote function

  1. @visibleForTesting
String? npuContextWindowNote({
  1. required int asked,
  2. required int window,
})

What an NPU engine says, once, when the context window its executor runs with (window, read after the first turn) is not the maxTokens it was asked for; null when they agree. An NPU bundle has one compiled KV cache, and LiteRT-LM lowers max_num_tokens to the bundle's metadata (or, without it, to the cache). When the metadata is above the cache (upstream #4184) the window read here is the metadata's, and a context past the cache fails natively; this note cannot see that case.

Implementation

@visibleForTesting
String? npuContextWindowNote({required int asked, required int window}) =>
    window == asked
    ? null
    : '[litertlm_dart] this NPU bundle runs with a context window '
          'of $window tokens, not the maxTokens $asked asked for: it is '
          'compiled for one KV cache size. Shown once per engine.';