Chunking removes the 400 error but not the cost: on the CPU stack a 100k
character document takes 21 chunks and ~112 s on 24 vCPU. Documented that long
documents are better chunked client side and sent as a batch, or that
MAX_MODEL_LEN_CPU should be raised.
Previously a document longer than --max-model-len got HTTP 400. Now pre_process
splits text into overlapping token windows (offsets from the fast tokenizer,
recursively halved if a piece still does not fit) and post_process merges the
per chunk results, so the client always receives one vector per input text.
- new request fields: chunk_tokens (default: only chunk what does not fit,
window = max_model_len - 8), chunk_overlap (128), merge (max/sum/mean,
sparse defaults to max, dense to mean + renormalise)
- response gains chunks, merge, chunk_tokens, chunk_overlap
- dense chunked output stays L2 normalised (norm 1.0000)
- regression: texts that fit are still processed as a single chunk with the
same weights as before (verified against the FlagEmbedding reference)
Measured on the GPU stand: 100k characters -> 3 chunks in 0.8 s, 0.6 s with
chunk_tokens=1024 (48 chunks); chunking a 1.1k token text into 400-token
windows keeps 92% of the whole-document tokens (dot 0.481).
Adds sync_cpu_compose.py: docker-compose.cpu.yml is now generated from
docker-compose.yml, so the two embedded copies of the plugin cannot drift
(--check mode for CI). smoke_test.py covers chunking, merge modes and grouping.
Measured with a 2-CPU quota: 1.60 s for one ~20 word text, 5.60 s for a batch of
4, 10.10 s for a batch of 8 (~0.7-0.8 texts/s, batching saves ~20%). Document
that 'VLLM_CPU_NUM_OF_RESERVED_CPU is less than the minimum requirement' is a
consequence of the new default and is harmless.
The stand's log showed core ids=[1] and 'Reducing Torch threads from 2 to 1'
because the container only sees ~2 cores: VLLM_CPU_NUM_OF_RESERVED_CPU=1 left
a single OpenMP thread for inference. Default is now 0 (16 vs 15 threads on a
24 vCPU host, no latency change); document setting it back to 1 for large hosts
and how to check nproc / core ids= after a deploy.
The CPU stand reached 'Application startup complete' but needed ~11 minutes:
the warmup/profiling run took 604 s and the model was recompiled twice.
- drop OMP_NUM_THREADS: it resolved to an empty string, which makes libgomp
warn and vLLM bind a single thread
- default to --enforce-eager (ENFORCE_EAGER=1): inductor compilation is minutes
of work on CPU, eager is measurably no slower (0.18 s vs 0.18 s per ~30 word
text) and engine init drops to 0.00 s
- lower CPU defaults to MAX_MODEL_LEN_CPU=2048 with
MAX_NUM_BATCHED_TOKENS_CPU=2048 (batched tokens must be >= max model len),
which is plenty for indexing
- README: what each noisy log line means and that DTYPE_CPU=float32 buys
nothing but memory
docker-compose.cpu.yml: same self-contained plugin heredoc and the same
/pooling API, but on vllm/vllm-openai-cpu:v0.30.0-x86_64 (9 GB vs 31 GB),
without the nvidia device reservation, with fp32 head + bfloat16 dtype
(fp16 is unstable on CPU) and the seccomp/SYS_NICE settings vLLM recommends.
Measured on 24 vCPU: 0.24 s for a ~30 word text, 0.92 s for a batch of 4,
versus 0.030/0.011 s on the GPU stand.
The failing deploy on a fresh host is almost always the vLLM image pull
(~31 GB unpacked) hitting Portainer's stack deploy timeout. Documented
pre-pulling on the target host plus docker save|load alternative, and
replaced the :latest default with the exact tag this stack was tested on.
- fix the wrong warning about GPU_MEMORY_UTILIZATION: 0.15 is enough for
BAAI/bge-m3 (measured: 2.1 GB of VRAM on an 8 GB card)
- document batch/dense response shapes, token ids, and that BGE-M3 has a single
ReLU sparse logit per token (no rel/abs pair as in ColBERT)
- Portainer: env vars belong to the stack's Environment variables field,
stack must run in docker compose (standalone) mode
- add the measured verification table (determinism, thresholds, nnz,
max|delta| vs the FlagEmbedding reference)
- add smoke_test.py: dependency-free checks of every scenario plus an optional
--reference mode that recomputes weights with torch/transformers
Portainer's web editor has no repo checkout on the host, so relative bind
mounts turned into empty directories. The compose file no longer mounts
anything except the HF cache: the plugin is now written with heredocs and
pip-installed inside the container.
Also fixes two compose-specific traps: $ must be escaped as $$ (compose
interpolates values), and command has to be a single-element list (otherwise
compose splits the script and bash runs a bare 'set').
Adds a vllm.io_processor_plugins entry point (bge_m3_sparse_plugin) that serves
learned sparse vectors of BAAI/bge-m3 over POST /pooling, on top of the
BgeM3EmbeddingModel architecture that already ships with vLLM.
- plugin/: python package, sparse (token_classify) and dense (embed) modes,
batch support, per-request weight threshold
- entrypoint.sh: pip install the plugin from a read-only mount at container start
- docker-compose.yml: stack ready for Portainer (git repository deployment)
Verified against vLLM 0.30.0 on an RTX 5070: single/batch/parallel requests,
validation errors, and weights matching the FlagEmbedding reference formula.