macOS Python 3.14 CPU backend: intra_threads=0 aborts on 4.7.2 and oversubscribes on 4.8.0

Aperta
#2,063 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
cpp, macos, python

Direzione di ricerca

Inizia riproducendo il carico di lavoro macOS arm64 con CTranslate2 4.8.0, confrontando intra_threads=0 con 1, e ispeziona TranslatorWrapper::translate_batch, il BS::thread_pool vendorizzato e ruy::ThreadPool::ExecuteImpl. Il lavoro è completo quando il percorso che porta all’abort o alla sovrascrittura del numero di thread è stato spiegato e corretto, preservando le override esplicite del conteggio dei thread, e quando il benchmark di traduzione sostenuta è stato convalidato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

On macOS arm64 with Python 3.14.5, the no-OpenMP CTranslate2 CPU backend behaves poorly when intra_threads=0 is used through Argos Translate. In 4.7.2 it produced a native abort during a sustained translation workload. In 4.8.0 the same workload no longer aborted in my test, but the automatic backend threading path was still pathologically slow and CPU-heavy compared with intra_threads=1.

Environment

macOS 26.5.1 arm64
Python 3.14.5
CTranslate2 4.7.2 and 4.8.0 wheels
Argos Translate / argostranslate-lt 1.12.1
English -> Russian Argos model

4.7.2 crash

With CTranslate2 4.7.2 and Argos' default ARGOS_INTRA_THREADS=0, a sustained Markdown translation workload aborted after several hundred translation calls:

libc++abi: terminating due to uncaught exception of type std::__1::system_error:
condition_variable wait failed: Invalid argument

Crash report showed the faulting thread inside the vendored CPU backend thread pool:

BS::thread_pool_light::worker()
std::__1::condition_variable::wait(...)

The main thread was waiting in:

ctranslate2::python::wait_on_futures<ctranslate2::TranslationResult>(...)
ctranslate2::python::TranslatorWrapper::translate_batch(...)

4.8.0 performance problem

I upgraded the same environment to CTranslate2 4.8.0. The crash-adjacent segment completed, and a full sustained run completed when using intra_threads=1.

However, with the unpatched default intra_threads=0, the process became extremely CPU-heavy and slow:

CPU: ~1470%
Hot path: ctranslate2::TranslatorWrapper::translate_batch
          ctranslate2::ops::Gemm::compute
          ruy::ThreadPool::ExecuteImpl
          ruy::BlockingCounter::Wait
          BS::thread_pool...

Benchmark on the same 30-unit Markdown slice with CTranslate2 4.8.0:

intra=0  TIMEOUT >60s
intra=1  elapsed=31.012s user=36.103s  sys=0.120s
intra=2  elapsed=48.529s user=84.297s  sys=19.564s
intra=4  elapsed=38.526s user=139.771s sys=28.153s
intra=8  elapsed=37.895s user=275.805s sys=28.084s

For this workload, intra_threads=1 is both fastest and most stable.

Notes

Argos Translate is mitigating this by defaulting ARGOS_INTRA_THREADS to 1 on Darwin while preserving explicit user overrides:

https://github.com/argosopentech/argos-translate/pull/528

I am filing this here because the 4.7.2 abort and 4.8.0 oversubscription both appear to originate in the CTranslate2 macOS no-OpenMP CPU backend path when the backend default thread count is selected.

Lingua principale
C++
Stelle
4.8k
Fork
557
Merge medio
1g 6h
PR unite (30g)
24

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di OpenNMT/CTranslate2

Tutte le issue di OpenNMT/CTranslate2

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.