Skip to content

fix: ignore parallel only for CoreML text models, with a warning - #934

Merged
joein merged 2 commits into
perf/coreml-gpufrom
coreml-parallel-warning
Dec 2, 2026
Merged

joein merged 2 commits into
perf/coreml-gpufrom
coreml-parallel-warning

Conversation

@joein

@joein joein commented Dec 2, 2026

Copy link
Copy Markdown
Member

Follow-up to #916, opened against perf/coreml-gpu.

parallel is now dropped only for models that run on CoreML, and never silently. #916 added requests_coreml(providers) to the single-process check in OnnxTextModel._embed_documents. That check is shared by every text model, so parallel was ignored without a word whenever CoreML was the first provider, including for SPLADE, BM42, miniCOIL and ColBERT, which have no CoreML runner.

The shared check is back to main's if parallel is None or is_small:. Instead, OnnxTextEmbedding.embed passes parallel through CoreMLMixin._coreml_parallel, which returns None for a model that uses the CoreML runner and warns once:

parallel=2 is ignored with CoreML, which runs in this process: worker processes would each compile and load the model again, to share one GPU.

Other models get parallel unchanged. The parallel docstrings of TextEmbedding.embed and OnnxTextEmbedding.embed say it's ignored with CoreML.

Checked on an M2 Max, with the worker pool replaced by a stub that only records whether embed(parallel=2) would start workers:

Case Before After
BAAI/bge-small-en-v1.5, CoreML, 300 texts runs in the process, no warning runs in the process, one warning at the caller's line
BAAI/bge-small-en-v1.5, CPU, 300 texts starts workers starts workers
prithivida/Splade_PP_en_v1 (no CoreML runner), CoreML, 300 texts runs in the process, parallel dropped silently starts workers, as on main

Small inputs (fewer texts than batch_size) also get the warning, although parallel would be ignored for them anyway.

@joein
joein merged commit 6fa51af into perf/coreml-gpu Dec 2, 2026
9 checks passed
@joein
joein deleted the coreml-parallel-warning branch December 2, 2026 14:50
joein added a commit that referenced this pull request Dec 2, 2026
* perf: run text embeddings on the Apple GPU with CoreML

* fix: use np.flatnonzero so mypy passes with numpy 2.4 stubs

* chore: Address review

* chore: forward max_batch_tokens to CoreML workers

* refactor: move CoreML support into CoreMLMixin

* chore: run CoreML in the current process, ignoring parallel

* fix: fall back when the CoreML export or cache is unavailable (#930)

* fix: fall back when the CoreML export or cache is unavailable

* tests: remove CoreML fallback tests

* fix: lock CoreML session creation and load all lengths in the constructor

* fix: default to 3 CoreML lengths, document their cost and shorten load logs

* fix: keep the CPU batch budget for texts longer than the CoreML lengths (#931)

* fix: fall back quickly and quietly when the CoreML export can't be downloaded (#933)

* fix: download the CoreML export once and quietly

* fix: call the CoreML export the CoreML-compatible copy in the warning

* fix: run each CoreML batch of long texts in one CPU run (#932)

* docs: list CoreML models in the README and shorten its example

* fix: ignore parallel only for CoreML text models, with a warning (#934)

* fix: ignore parallel only for CoreML text models, with a warning

* fix: resolve parallel through a general hook that CoreML overrides

---------

Co-authored-by: George <george.panchuk@qdrant.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant