Skip to main content

scann-core-torch

The native backend of scann-core's scann.torch: C++ PyTorch ops (torch.ops.scann.search, torch.ops.scann.search_batched) that search a ScaNN index held in a module's buffers.

pip install scann-core-torch    # installs the matching scann-core, and torch>=2.10

With it installed, scann.torch.Searcher keeps the index in its buffers and searches with these ops, with the same API and results as without it. What it adds:

  • torch.export and AOTInductor programs of a model that searches carry the index and run in other processes;
  • state_dict() contains the index (and load_state_dict() restores it);
  • a model holding a Searcher can be pickled (torch.save(model)).
import torch
import scann.torch as scann_torch

searcher = scann_torch.builder(embeddings, 10, "dot_product").score_ah(2).reorder(100).build()
assert scann_torch.backend() == "native"

ep = torch.export.export(model_that_searches, (features,))
torch.export.save(ep, "retriever.pt2")    # the index is inside

The ops are built against LibTorch's stable ABI only, so the one wheel per architecture (py3-none-manylinux_2_34_x86_64 / _aarch64) works with any torch >= 2.10 (CPU, CUDA and ROCm builds) and any Python >= 3.10. Searches run on the CPU; queries on a GPU are copied to host memory and the results back.

Documentation: docs/integrations.md. Derived from Google's ScaNN; not an official Google product. Apache-2.0.

Metadata

Release files for scann-core-torch 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for scann-core-torch 0.2.1
File Interpreter ABI Platform
scann_core_torch-0.2.1-py3-none-manylinux_2_34_x86_64.whl Python 3 none Linux glibc 2.34+ x86-64 Details
scann_core_torch-0.2.1-py3-none-manylinux_2_34_aarch64.whl Python 3 none Linux glibc 2.34+ ARM64 Details

Total release size: 12.4 MB

Release files / scann_core_torch-0.2.1-py3-none-manylinux_2_34_x86_64.whl

Download URL scann_core_torch-0.2.1-py3-none-manylinux_2_34_x86_64.whl
Size 7.1 MB
Tags Linux glibc 2.34+ x86-64 Python 3
SHA-256 checksum
How to use checksums
d001100c541bdc6c0ec5bdffdc4e0b8cf5bf62f6e0aadea304ff582819d3fcf5
BLAKE2b-256 checksum
How to use checksums
d473d238bb05c67bdf85e81ad34516a75bb3b64ff10d305cff8bde1ccf83bbe8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / scann_core_torch-0.2.1-py3-none-manylinux_2_34_aarch64.whl

Download URL scann_core_torch-0.2.1-py3-none-manylinux_2_34_aarch64.whl
Size 5.3 MB
Tags Linux glibc 2.34+ ARM64 Python 3
SHA-256 checksum
How to use checksums
4ac1a67cce2019f797c6ceccc294c672f59fe2094d7ef2d732a36e2c45f76b11
BLAKE2b-256 checksum
How to use checksums
e9f280fdce4c3967c13ca1602d7f5c22a9022f559d3f88948c6613e73b8a6eac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page