[Engine] Inkling-2-Mini: every follow-up turn in a chat with images re-encodes all images and re-reads the whole prompt (no image-embedding cache; prefix reuse is off when a request has images)

Aperta
#7,303 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
performance

Direzione di ricerca

Start with engine/src/inkling2/ink_serve.h, especially the image encode loop near line 645 and prefix reuse check near line 671. Trace how image embeddings and cached prefixes are represented and used across turns. Done means follow-up requests without new images reuse prior image encodings and matching prompt prefixes, while requests with changed images still process them correctly.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Area

[Engine] (speed, kernels, models, the server and API)

Desktop app, Terminal or source?

Source (START-HERE.bat, setup.sh or a build)

What happened

I sent 5 screenshots and a question in one chat, and got the answer. I then asked a follow-up in the same chat with no new images, and waited again before the first token.

The client resends the whole conversation each turn, as OpenAI-style clients do. While I waited, strata-inkling was at ~1,600% CPU (16 cores busy): all 5 images were being encoded again before any token was read.

Why (from the source, engine/src/inkling2/ink_serve.h, v0.2.22-1, c23477403)

  1. Every image in the request is encoded again, every turn. The encode loop at ~line 645 runs for every image in the prompt. There is no cache of image embeddings, so an image already encoded on the previous turn costs the full encode again.
  2. Prefix reuse is turned off when the request has any image. The reuse check at ~line 671 is wrapped in if (pg.images.empty()) { ... }. Once a chat contains one image, every later turn also re-reads the full prompt (old text, old answers and image tokens), even though the KV for that prefix is still in the slot.

Expected: a follow-up turn without new images reads only the new text.

Suggested fix

  1. An image-embedding cache. Key it by a hash of the decoded, resized pixels plus the grid size. Store the vision encoder output, LRU-bounded in MiB, per server process or per slot. A follow-up turn would then skip the encode for images it has already seen.
  2. Image-aware prefix reuse. Keep, next to cached_prefix, the image hash for each image-pad position. Then pg.images no longer has to disable reuse: a prefix matches when the token ids AND the image hashes match.

With both, a follow-up turn in an image chat only reads the new text.

Smallest steps or command that reproduce it
  1. Start Inkling-2-Mini with --vision Inkling-2-Mini-Vision.strata.
  2. In one chat, send 5 screenshots and a question, and wait for the answer.
  3. Ask a follow-up in the same chat, without new images.
  4. Watch top during step 3: strata-inkling uses many cores until all images are encoded again, then reads the whole prompt from the start.

For scale: one 640x400 PNG (0.256 MP) plus a short question took 15.2 s to answer here; the answer was 100 tokens.

Reproduction status

Reproduced locally

Strata version

Strata 0.2.22 (terminal v0.2.22-1) · strata-inkling 0.1.69 (linux-x86_64-cuda-cuda13)

Graphics card, memory and system

RTX 3090 24 GB + RTX 4060 Ti 16 GB · Xeon Gold 6136 (12C/24T) · 93 GB RAM · Ubuntu 26.04

Model, size and settings

Inkling-2-Mini SQ-20 + Inkling-2-Mini-Vision · 512K context · pictures on · --gpus 2 --layer-split ep2 --ep-split 0.4 --kv fp8 --draft dspark

Lingua principale
C++
Stelle
11.6k
Fork
1k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Niko1221/Strata

Tutte le issue di Niko1221/Strata

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.