Skip to content

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

Merged
joein merged 2 commits into
perf/coreml-gpufrom
quiet-coreml-export-download
Dec 2, 2026
Merged

joein merged 2 commits into
perf/coreml-gpufrom
quiet-coreml-export-download

Conversation

@joein

@joein joein commented Dec 2, 2026

Copy link
Copy Markdown
Member

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

Six models run CoreML from a separate export, which the constructor downloads on first use. Since #930, a failed download falls back to the CPU with one warning, but download_model still treats the export like the model itself:

  • Offline (HF_HUB_OFFLINE=1 or local_files_only=True), it logs two ERROR lines before the warning, and they name the main model as if it were missing.
  • With huggingface.co unreachable, it retries with 3 s and 9 s sleeps and then tries Google Cloud Storage, logging 5 ERROR lines and adding about 12 s to creating the model.

download_model now takes optional=False. With optional=True it still checks the cache first. If the files aren't there, it raises a ValueError right away offline, or tries Hugging Face once online, with no retries, sleeps, error logs or Google Cloud Storage fallback. A corrupted cache is still downloaded again. _init_coreml passes optional=True, so its warning now ends with the export's real error. Downloads of the models themselves are unchanged.

Checked on an M2 Max:

Case Before After
BAAI/bge-small-en with CoreML, export not cached, offline 2 ERROR lines and the warning only the warning, 0.08 s
Same, with HF_ENDPOINT at a closed local port 5 ERROR lines, 12.1 s only the warning, 0.09 s
A model that isn't cached, offline or unreachable ERROR lines, then ValueError unchanged

In the fallback runs the vectors match a CPU-only model. download_model(optional=True) also downloaded Qdrant/bm25 into an empty cache, loaded it again offline, downloaded a truncated file again, and raised at once offline with an empty cache, all without warning or error logs. A real download of a CoreML export through the new code isn't tested.

@joein
joein merged commit 3615258 into perf/coreml-gpu Dec 2, 2026
9 checks passed
@joein
joein deleted the quiet-coreml-export-download branch December 2, 2026 13:44
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