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…
Repair the edits the web editor mangled, and the paths they broke
YasserHaidar
6e08541
Six files were edited in the Hugging Face web editor. Three things did not
survive that round trip:
- _CJK_RE's private-use-area range '-' was flattened to a bare
'-', so the class no longer stripped PUA characters and did strip a literal
ASCII hyphen from every model reply ("التسجيل المباشر - المفاضلة" came back
without its dash).
- Four files lost their trailing newline.
- LLM_MAX_TOKENS gained a trailing space.
Two paths the LangChain switch left broken:
- engine.build_llm imported llm.langchain_llm unconditionally, but
requirements-deploy.txt (Streamlit Community Cloud, Docker) does not carry
LangChain, so every chat answer there would have fallen to the deterministic
reply. LangChain is added to that manifest, and an ImportError now falls back
to the provider SDKs — the behaviour requirements.txt already claims in its
own comment.
- Four build_llm tests still patched llm.cloud_llm.CloudLLM, which build_llm no
longer calls. They patch the LangChain path inste…