[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)

Abierto
#7,303 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 4 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
cpp
Área
performance

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
C++
Estrellas
11.6k
Forks
1k
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Niko1221/Strata

Todos los issues de Niko1221/Strata

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.