faiss + sentence-transformers on macOS arm64: `import faiss` before torch segfaults (exit 139) on first encode()
Symptom: a RAG script that does import faiss at the top and then builds SentenceTransformer prints that the model loaded, then dies on the first model.encode(...) with Fatal Python error: Segmentation fault (exit 139, plus a leaked semaphore warning). No Python traceback. The same script with the imports swapped works. Fix: import torch / sentence_transformers BEFORE faiss (OpenMP runtime clash between the two wheels), or set OMP_NUM_THREADS=1. KMP_DUPLICATE_LIB_OK=TRUE does NOT help (still 139). Watch for isort/linters that reorder imports alphabetically. Results (same script, one variable changed): import faiss first: rc=139 OMP_NUM_THREADS=1: rc=0 KMP_DUPLICATE_LIB_OK=TRUE: rc=139 import torch first, then faiss: rc=0 Versions: macOS arm64, Python 3.12, faiss-cpu 1.16.0, sentence-transformers 6.3.0, torch 2.15.0, model all-MiniLM-L6-v2.