Skip to content

Commit e58be96

Browse files
build: enable multimodal serving on cloud run
Bake the ColQwen2 weights so startup pays no HF fetch. The 2B CPU query encoder (~8GB fp32) plus bge-m3 needs 16Gi/4vCPU; 8Gi was too small.
1 parent 73e80a2 commit e58be96

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

.github/workflows/deploy.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ jobs:
8181
# config (corpus collection, pages dir, etc.) is preserved. Enables the
8282
# experimental DCI mode; with no server key it runs on the caller's key.
8383
# max-instances=1 + timeout bound the worst-case Cloud Run burn rate.
84-
flags: --port=8000 --memory=8Gi --cpu=2 --cpu-boost --min-instances=0 --max-instances=1 --timeout=120 --allow-unauthenticated --update-env-vars=RAG_ENABLE_DCI=true
84+
# ADR 0028: 16Gi/4vCPU fits the in-process ColQwen2 query encoder (2B,
85+
# fp32 ~8GB) alongside bge-m3; Cloud Run requires >=4 vCPU at 16Gi.
86+
# RAG_ENABLE_MULTIMODAL turns the visual leg on (it stays inert unless
87+
# the visual collection is populated in the baked Qdrant snapshot).
88+
flags: --port=8000 --memory=16Gi --cpu=4 --cpu-boost --min-instances=0 --max-instances=1 --timeout=120 --allow-unauthenticated --update-env-vars=RAG_ENABLE_DCI=true,RAG_ENABLE_MULTIMODAL=true
8589

8690
- name: Print URL
8791
run: |

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ COPY --chown=app:app qdrant_local /home/app/qdrant_local
7070
RUN /home/app/.venv/bin/python -c \
7171
"from sentence_transformers import SentenceTransformer, CrossEncoder; SentenceTransformer('BAAI/bge-m3'); CrossEncoder('cross-encoder/ms-marco-MiniLM-L-6-v2')"
7272

73+
# ADR 0028: bake the ColQwen2 visual encoder so the multimodal serve path pays
74+
# no HuggingFace fetch at startup — a ~4 GB cold download would blow the Cloud
75+
# Run startup window. from_pretrained caches the adapter, its Qwen2-VL-2B base,
76+
# and the processor. Only the query is encoded at serve time; the page vectors
77+
# are pre-built into the Qdrant snapshot (scripts/build_visual_index.py). Adds
78+
# ~4 GB to the image; the visual leg only activates when RAG_ENABLE_MULTIMODAL
79+
# is set AND the visual collection is populated.
80+
RUN /home/app/.venv/bin/python -c \
81+
"from colpali_engine.models import ColQwen2, ColQwen2Processor; ColQwen2.from_pretrained('vidore/colqwen2-v1.0'); ColQwen2Processor.from_pretrained('vidore/colqwen2-v1.0')"
82+
7383
# RAG_RERANKER_MODEL: light CPU-feasible cross-encoder (see settings.py).
7484
# RAG_RERANK_TOP_K: trim the rerank pool 50 -> 20 for CPU latency; the 20-paper
7585
# demo corpus doesn't need a 50-candidate pool.

0 commit comments

Comments
 (0)