Pin the embedding model to the CPU so ZeroGPU stops intercepting it
YasserHaidar
835249d
The background index build died with "ZeroGPU's PyTorch CUDA emulation mode did
not intercept a CUDA operation in your code". sentence-transformers picks a
device by asking torch whether CUDA is available; on ZeroGPU that answers yes,
because CUDA is emulated and only intercepted for calls made on the request
path inside an @spaces.GPU function. Building the index on a background thread
put the call outside that path, so it reached torch._C._cuda_init directly.
Nothing here wants a GPU: it is a 471MB MiniLM embedding 95 short documents
once per restart. Passing device explicitly skips the availability check that
breaks, rather than working around it. KALIM_EMBEDDING_DEVICE overrides it for
a machine with a GPU worth using.
Both Chroma paths are covered — build_index and search each embed through this
model and hand Chroma the finished vectors, so Chroma never runs an embedding
function of its own.
sentence-transformers is not a test dependency, so the constructor is stubbed;
what th…