llm: rebuild postgres pgvector without AVX-512 — HNSW build SIGILLs the shared server on Zen2 #580
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The mirrored
fhirworx/postgresql:latestimage (Bitnami PG18, shared by gitea/nessie/polaris/llm) ships a pgvector 0.8.1vector.socompiled with AVX-512, but the server host is a Ryzen 9 3950X (Zen 2 — no AVX-512).Impact:
CREATE INDEX ... USING hnswandUSING ivfflatfault with signal 4 (SIGILL) during the build — verified even on 3 rows. The fault kills every Postgres backend and drops the whole server (gitea/nessie/polaris included) into recovery (~15s). This is a shared-infra stability hazard, not just an llm failure.Workaround shipped in P33: ANN index creation is gated behind
[llm].build_ann_index(default false); the llm module runs on pgvector exact search, which works fine (query-time distance dispatch is correct — only the bulk index-build path faults). Exact search on the pilot (15,852 vectors) answers in ~1.2s.Fix: rebuild the image's pgvector without AVX-512 / with working
__builtin_cpu_supportsdispatch. Cleanest low-risk path: a thin imageFROM fhirworx/postgresql:latestthat replacesvector.sowith a build compiled-march=x86-64-v2(orznver2). Then flip[llm].build_ann_index = true,stack llm index --forceto build HNSW, and addensure_hnswto the indexer tail.Acceptance:
CREATE INDEX ... USING hnswonlangchain_pg_embeddingcompletes without crashing the server[llm].build_ann_index = true+ a corpus-scale query uses the HNSW index (EXPLAIN shows index scan)Discovered during the P33 pilot run. Spec:
docs/superpowers/specs/2026-07-16-llm-module-design.md(P33 build outcomes).Fixed in main as
666195e.Root cause (confirmed from the kernel trap): the mirrored image's
vector.sowas built with pgvector's default-march=nativeon an AVX-512 host. On the Zen2 Ryzen 3950X,vector_norm()executed EVEX-encoded AVX-512 —vextractf64x2@ offset 0x1fe11 andvcvtusi2sd@ 0x121d4 — which the CPU rejects (SIGILL), during hnsw/ivfflat index build. Query-time distance ops were legal AVX2, which is why exact search never faulted.Fix:
infra/images/postgresql.Dockerfilebuildsfhirworx/postgresql:pgvectorFROM the:latestmirror, recompiling pgvector 0.8.1 (pinned + sha256-verified) with-march=x86-64-v3(AVX2/FMA/BMI2, fully supported by Zen2) and swapping in the AVX-512-freevector.so.compose.yml(postgres build section) anddeploy.sh(BUILDABLE) build it;[llm].build_ann_indexnow defaults true.Verified on the live pilot: HNSW builds on the 15,852-vector index in ~2s with no crash; ivfflat too;
EXPLAINshowsIndex Scan using ix_embedding_hnsw; gitea/nessie/polaris unaffected. Data volume untouched (same PG 18.1, same extension version).Build notes: Photon needs
binutils+linux-api-headers;glibc-develbumps glibc so the runtime stage installsglibcto match (elseGLIBC_2.38 not found); nevertdnf remove curlin the runtime (cascades outlibldap.so.2).