khora-accel Rust
extension (built on PyO3) handles these natively, with zero-copy NumPy access, GIL
release during compute, and Rayon work-stealing parallelism across cores.
It’s entirely optional: if Rust isn’t installed, Khora falls back transparently.
The 3-tier fallback
Every accelerated operation has three implementations. The fastest available is chosen automatically at import:| Tier | Backend | Notes |
|---|---|---|
| 0 | Rust (khora-accel) | Fastest: rayon parallelism, GIL release, zero-copy NumPy |
| 1 | NumPy / RapidFuzz | Good, widely available: vectorized + C-backed |
| 2 | Pure Python | Always works: stdlib only (math, difflib, re) |
KHORA_ACCEL_BACKEND env var: rust, numpy, or python
(unset = auto-detect). python is handy for debugging.
Installing
khora-accel wheel is pinned in lockstep with Khora’s own version. Install
the matching pair. Verify it loaded:
What’s accelerated
khora-accel ships ~40 functions across vector math, string similarity, ranking, and
graph ops. Indicative speedups over pure Python:
| Category | Operations | Speedup |
|---|---|---|
| String similarity | Levenshtein, Jaro-Winkler, batch variants | 10–40× |
| Entity resolution | 3-stage batch matching (exact → alias → fuzzy) | 10–30× |
| PageRank / PPR | Skeleton core selection, graph scoring | 5–15× |
| Vector math | Cosine, batch/pairwise cosine, dot product, MMR | 5–10× |
| BM25 | Index build + search | 3–8× |
| Keyword extraction | Tokenize + stopword filter | 3–5× |
| RRF fusion | Reciprocal rank fusion + normalization | 2–5× |
Thread pool tuning
Rayon uses one global thread pool per process. Size it for your workload before any parallel work runs:When it matters
- Large-scale ingestion (>1,000 docs): entity resolution and pairwise cosine dominate, and Rayon scales near-linearly across cores.
- Skeleton indexing: PageRank and keyword extraction run every ingest batch.
- High-volume query: BM25 and RRF fusion benefit at >10k indexed documents.
- Small workloads (under ~100 docs): the NumPy/Python tiers are plenty, and Rust is unnecessary (but harmless).
extension
Integrations
Wire Khora into CrewAI, LangGraph, Google ADK, OpenAI Agents, or LlamaIndex.
speed
Performance & scaling
Where Rust acceleration fits among the other scaling levers.