Docs: hardware sizing omits the local knowledge-bank embedder (~3.7 GB resident, ~5.3 GB peak on PDF ingest)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
- Tipo di issue
- Documentazione
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- docker, helm, python
- Ambito
- backend, documentation
Direzione di ricerca
Inizia da hindsight-docs/docs/developer/installation.md, knowledge-banks.mdx e configuration.mdx; confronta le indicazioni sulla memoria con le misurazioni riportate e il limite API di 4Gi in helm/hindsight/values.yaml. Documenta il fabbisogno di memoria residente e di picco dell’embedder locale e chiarisci se le distribuzioni che usano l’impostazione predefinita richiedono un limite più alto. Il lavoro è completato quando i lettori possono dimensionare container e distribuzioni Helm in base alle indicazioni aggiornate.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug Description
The documented memory sizing does not account for the local knowledge-bank embedder, which is the default (HINDSIGHT_API_KB_EMBEDDINGS_PROVIDER=local, EmbeddingGemma 2 in-process) now that knowledge banks are enabled by default.
hindsight-docs/docs/developer/installation.md→ Hardware lists API — Full image at 1.5 GB minimum / 2 GB recommended ("Idle RSS settles around 0.8–1.0 GB; expect 1.2–1.5 GB under load"), counting the BGE embedder (~130 MB) and the MiniLM cross-encoder (~90 MB).- The image table on the same page mentions the knowledge banks' EmbeddingGemma 2 model only as "~1.5 GB" bundled in the image.
knowledge-banks.mdxand theHINDSIGHT_API_KB_*rows inconfiguration.mdxgive no memory guidance for the embedder.helm/hindsight/values.yamldefaults the API to a 4Gi memory limit.
Measured on 1.3.1, the model alone is about 3.7 GB resident once loaded, and embedding PDF pages peaks at about 5.3 GB, before counting the rest of the server. A deployment sized from the docs runs out of memory on PDF ingest.
This is not a leak: memory plateaus. The model loads on first knowledge-bank use and stays resident.
Steps to Reproduce
- Save the script below as
repro.pyin an empty directory. - Run it in the stock full image, with no server or database:
docker run --rm -m 8g --network none \
-e HF_HUB_OFFLINE=1 -e TRANSFORMERS_OFFLINE=1 \
-v "$PWD":/repro:ro \
--entrypoint /app/api/.venv/bin/python \
ghcr.io/vectorize-io/hindsight:1.3.1 /repro/repro.py
- Read the RSS printed after the model loads and after each document.
The script calls LocalGemmaEmbedder.embed_documents() with batch_size=4 on three documents of 24 synthetic page images (1187×1536 PNG, 560 image tokens, the PDF page recipe in knowledge/media.py), in rounds of 8 with up to 4 in flight. It takes about 16 minutes on CPU.
repro.py
"""RSS of the local knowledge embedder across batches of PDF-page-sized images, called the way the service
calls it: embed_documents() (asyncio.to_thread), several rounds in flight, batch_size 4, 560 image tokens."""
import asyncio, ctypes, gc, io, random, time
from PIL import Image, ImageDraw
from hindsight_api.knowledge.embedders import EmbedInput, LocalGemmaEmbedder
DOCS, PAGES, ROUND, IN_FLIGHT = 3, 24, 8, 4
T0 = time.time()
def log(label):
s = dict(l.split(":", 1) for l in open("/proc/self/status") if ":" in l)
mb = lambda k: int(s[k].split()[0]) // 1024
print(f"{time.time()-T0:7.1f}s {label:<28} rss={mb('VmRSS'):5d}MB peak={mb('VmHWM'):5d}MB threads={int(s['Threads'])}", flush=True)
def page(seed):
r = random.Random(seed)
img = Image.new("RGB", (1187, 1536), "white")
d = ImageDraw.Draw(img)
for y in range(40, 1500, 22):
words = ("".join(r.choice("abcdefghijklmnopqrstuvwxyz") for _ in range(r.randint(2, 9))) for _ in range(16))
d.text((50, y), " ".join(words), fill="black")
b = io.BytesIO()
img.save(b, "PNG")
return b.getvalue()
emb = LocalGemmaEmbedder("google/embeddinggemma-2", dimensions=None, device=None, batch_size=4, image_tokens=280)
async def ingest(doc):
items = [EmbedInput(modality="image", data=page(doc * 1000 + p), mime="image/png", image_tokens=560) for p in range(PAGES)]
sem = asyncio.Semaphore(IN_FLIGHT)
async def one(chunk):
async with sem:
return await emb.embed_documents(chunk)
await asyncio.gather(*(one(items[i:i + ROUND]) for i in range(0, len(items), ROUND)))
async def main():
log("start")
emb.ensure_loaded(); log("model loaded")
for doc in range(DOCS):
await ingest(doc); log(f"doc {doc + 1} done ({PAGES} pages)")
time.sleep(15)
gc.collect(); log("after gc.collect()")
ctypes.CDLL("libc.so.6").malloc_trim(0); log("after malloc_trim(0)")
asyncio.run(main())
Expected Behavior
The Hardware table and the Knowledge Banks page state what the default local knowledge embedder needs in memory, so a container or Helm limit can be sized for it. The default Helm limit either fits a deployment that uses the default embedder, or the docs say it must be raised.
Actual Behavior
Isolated run (the steps above), ghcr.io/vectorize-io/hindsight:1.3.1, CPU, torch 2.13.0+cpu, 8 GiB limit:
| Point | RSS |
|---|---|
| Process start | 128 MB |
| Model loaded | 3,653 MB |
| After document 1 | 4,125 MB |
| After document 2 | 4,249 MB |
| After document 3 | 4,247 MB |
After malloc_trim(0) |
3,726 MB |
| Peak (VmHWM) | 5,346 MB |
In a real deployment of the same image under an 8 GiB container limit:
- The server idled at about 2.5 GiB until its first PDF. The log then showed
Knowledge embedder loaded: google/embeddinggemma-2 on cpu (768 dims), and it has idled at about 6.05 GiB RSS since. - Ingesting one 1.3 MB PDF (27 passages) peaked at 7.6 GiB.
- On 1.3.0, submitting 19 PDFs (14 KB to 12.7 MB) within a few seconds failed 15 of them with
MediaError: ... the PDF renderer crashed on this file, and the kernel then OOM-killedhindsight-api(Memory cgroup out of memory, anon-rss 8,123,236 kB). The same files ingested without error one or two at a time.
The memory guard added in https://github.com/hindsightai/hindsight/pull/6735 kills the biggest worker process, so it does not help when the memory is held by the server process itself. That PR's description assumes "a 2–3 GB server"; with the local knowledge embedder loaded the server here is about 6 GiB.
Version
1.3.1 (ghcr.io/vectorize-io/hindsight:1.3.1; the OOM kill was on 1.3.0). Docker on Linux x86_64 (kernel 6.12, 20 CPU threads), Python 3.11.18 as shipped in the image, CPU only.
LLM Provider
Other (not involved: knowledge-bank ingest makes no LLM calls)
- Lingua principale
- Python
- Stelle
- 45.2k
- Fork
- 5.9k
- 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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di vectorize-io/hindsight
-
core
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
vectorize-io/hindsight#7254 ·
-
Control Plane shows different calendar dates for the same occurrence in Constellation and TimelineApertacore
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
vectorize-io/hindsight#7240 · 1 commento ·
-
core
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
vectorize-io/hindsight#7231 ·
-
Flaky system test: test_embedding_and_rerank_calls_are_in_request_history raises StopIterationApertacore
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
vectorize-io/hindsight#7228 · 1 commento ·
-
test-embed-windows: test_ui_that_never_answers_hits_the_cap_and_is_terminated fails on WindowsForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertacore
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
vectorize-io/hindsight#7196 ·
Tutte le issue di vectorize-io/hindsight
Issue simili
-
docs(contributing): the two things that silently block a PRForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertaavailable documentation good first issue
Difficoltà 1/5 1-3 ore Idoneità per principianti 95/100
Nixitov/Riptide-Native#944 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
JTHCode/secretguard#24 ·
I maintainer di solito rispondono entro 1 giorno
-
area: middleware documentation good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
good first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
omarelshamy25x/shamy-hijri#63 ·
I maintainer di solito rispondono entro 1 giorno