Skip to main content

Rill

Rust-backed neighbor sampling for PyTorch.

CI License: MIT OR Apache-2.0 Python 3.8+

Rill accelerates mini-batch GNN data loading by moving graph storage, multi-hop neighbor sampling, feature gathering, and batch assembly into a native Rust core. The Python GIL is released during all native work, and batches are handed to PyTorch via zero-copy DLPack tensors.

On ogbn-products (2.4M nodes, 124M edges) with a 2-layer GraphSAGE model, Rill delivers:

  • 8.1–8.7× faster batch loading than PyG NeighborLoader
  • 3.6–4.5× faster end-to-end training epochs (loader + transfer + model)
  • 2.86 GB (30%) lower peak host memory
  • 1.000× equivalent subgraph sizes and identical tensor layouts (float32 / int64, contiguous)

Benchmarks

All timings are medians over 10 timed repeats after 3 warmup epochs on ogbn-products (2,449,029 nodes, 123,718,280 edges), 20,000 training seeds, fanout [10, 10], batch size 256. Reproduce with examples/benchmark_full.py.

Controlled comparison

Both loaders sample the same workload and emit identical tensor formats (medians across all 79 batches):

Loader Median nodes / batch Median edges / batch x dtype / contiguous edge_index dtype / contiguous
Rill 24,659 27,591 float32 / True int64 / True
PyG (pyg_lib) 24,673 27,582 float32 / True int64 / True
Ratio (Rill / PyG) 0.999× 1.000× Match Match

Loader and end-to-end epoch timing

Threads Rill loader PyG loader Loader speedup Rill E2E PyG E2E E2E speedup
1 670 ms 5,402 ms 8.06× 1,389 ms 6,293 ms 4.53×
4 408 ms 3,546 ms 8.68× 1,100 ms 3,902 ms 3.55×
8* 441 ms 5,093 ms 11.56× 1,131 ms 5,368 ms 4.75×

*Oversubscribed: 8 workers on a 4-core CPU; included to illustrate contention behavior rather than as a scaling point.

E2E measures the full training epoch: batch loading + host-to-device transfer + 2-layer GraphSAGE (hidden=256) forward, loss, backward, and optimizer step. Only E2E totals are compared head-to-head; PyG's multi-worker IPC and background CPU contention affect both transfer (543 ms vs 180 ms at 4 threads) and model execution.

Peak host memory & one-time construction

Metric Threads Rill PyG Delta
Peak RSS (baseline ~3,770 MB) 1 6,604 MB 9,465 MB -2.86 GB (-30%)
Peak RSS (baseline ~3,770 MB) 4 6,678 MB 9,559 MB -2.88 GB (-30%)
Loader construction (one-time) 1 18.86 s 11.04 s +7.82 s
Loader construction (one-time) 4 11.80 s 6.99 s +4.81 s

Rill eagerly builds CSR/CSC indexes in parallel and copies node features into Rust-managed memory, whereas PyG defers part of its setup to the first iteration. At 4 threads, Rill's extra ~4.8 s construction cost is recovered in ~2 epochs.

Test environment
  • CPU: Intel Xeon @ 2.00 GHz, 4 vCPUs
  • RAM: 31 GB
  • GPU: 2× Tesla T4 (15 GB each)
  • OS: Linux 6.18.55+ (x86_64, glibc 2.39)
  • Stack: Python 3.13, PyTorch 2.11.0+cu130, PyG 2.8.1, pyg_lib, CUDA 13.0
  • Host: Kaggle Notebook (GPU T4 ×2)

Installation

pip install rill-gnn

To build from source (requires a stable Rust toolchain):

python -m pip install .

Requirements: Python 3.8+, PyTorch 2.0+, NumPy 1.22+.


Quick Start

RillLoader accepts any mapping or object (such as a PyG Data object) with edge_index, x, and optional y:

import torch.nn.functional as F
from torch_geometric.nn import SAGEConv
from rill import RillLoader

loader = RillLoader(
    data,
    num_neighbors=[10, 10],
    batch_size=1024,
    input_nodes=data.train_mask,
    shuffle=True,
    seed=42,
)

for batch in loader:
    x = batch["x"].to(device)
    edge_index = batch["edge_index"].to(device)
    y = batch["y"].to(device)

    out = model(x, edge_index)
    loss = F.cross_entropy(out[: batch["batch_size"]], y)
    loss.backward()

Batch schema

Key Shape / Type Description
x (num_sampled_nodes, num_features) float32 Node features for the sampled subgraph.
edge_index (2, num_sampled_edges) int64 Local [source, target] inbound edges (source -> target).
n_id (num_sampled_nodes,) int64 Original graph node IDs.
batch_size int Number of unique seed nodes at the start of the batch.
y (batch_size, ...) int64 (optional) Labels for the seed nodes only.

Scope & Limitations

Supported today:

  • In-memory homogeneous graphs (edge_index + dense float32 node features x + optional integer labels y)
  • Inbound multi-hop neighbor sampling (num_neighbors list per hop)
  • Seed selection via node IDs or boolean mask (input_nodes)
  • Deterministic per-epoch shuffling and sampling (seed)

Not yet supported:

  • Heterogeneous graphs (HeteroData), edge features (edge_attr), or link prediction (LinkNeighborLoader)
  • num_neighbors=[-1] (all-neighbor fanout) or sampling with replacement in RillLoader
  • Out-of-core / disk-backed graphs (e.g., ogbn-papers100M)
  • Attribute-style batch access (batch.x — currently returns a dict)

Reproducing Benchmarks

Install the development and OGB benchmark extras (plus a compatible pyg_lib or torch_sparse build):

python -m pip install ".[dev,benchmark]"

Run the full multi-thread sweep with end-to-end GraphSAGE timing:

python -m examples.benchmark_full \
  --dataset ogbn-products \
  --num-seeds 20000 \
  --warmup 3 \
  --repeats 10 \
  --sweep \
  --e2e

For a quick single-thread check on Cora:

python -m examples.benchmark_cora --dataset cora --warmup 3 --repeats 10 --threads 1

See CONTRIBUTING.md for development setup, Rust/Python test commands, and benchmark methodology.


Roadmap

  • Drop-in batch.x / batch.edge_index attribute access alongside dict access
  • CSC-only index construction for RillLoader and zero-copy feature buffer borrowing
  • num_neighbors=[-1] (all-neighbor) and edge_attr support

AI Disclosure

Rill was built with significant assistance from AI coding tools. Architecture, design decisions, and research direction are human-driven; implementation, tests, benchmarks, and documentation were developed collaboratively with AI pair-programming. All code has been reviewed and tested by the author.

License

Dual-licensed under either the MIT License or the Apache License, Version 2.0, at your option.

Metadata

Release files for rill-gnn 0.1.0

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

Source distribution (sdist)

Source distribution for rill-gnn 0.1.0
File Size Uploaded Provenance Actions
rill_gnn-0.1.0.tar.gz 25.9 kB With provenance Details for rill_gnn-0.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for rill-gnn 0.1.0
File Interpreter ABI Platform Actions
rill_gnn-0.1.0-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details for rill_gnn-0.1.0-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
rill_gnn-0.1.0-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details for rill_gnn-0.1.0-cp38-abi3-macosx_11_0_arm64.whl
rill_gnn-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl CPython 3.8 abi3 macOS 10.12+ x86-64 Details for rill_gnn-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl

Total release size: 2.2 MB

Release files / rill_gnn-0.1.0.tar.gz

Download URL rill_gnn-0.1.0.tar.gz
Size 25.9 kB
Tags Source
SHA-256 checksum
How to use checksums
72de33b6ca6b3cf2bac109d7167cf514b78ecf2826ce8a30d6d4bc4e1f679c2a
BLAKE2b-256 checksum
How to use checksums
f1cf54f9ab6cbdf6b51e5c96cfd625868fbcc4e04398cb4637d84f6f4c2f2bc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / rill_gnn-0.1.0-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL rill_gnn-0.1.0-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 1.5 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
c7dbac5a667b338a75dd64ea11f9c1b95ffae41b0f1ef733c91b0d2640269101
BLAKE2b-256 checksum
How to use checksums
b6da4ce8fcaec3715fa49c95b1c24dcb396b0fab6db6f72824af8e240ac50076
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / rill_gnn-0.1.0-cp38-abi3-macosx_11_0_arm64.whl

Download URL rill_gnn-0.1.0-cp38-abi3-macosx_11_0_arm64.whl
Size 332.5 kB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
57c6ae8c4bd34a2c9c49f45f18df5fe5f6de39a62476f875539886f470c355f6
BLAKE2b-256 checksum
How to use checksums
bd4d262f6572bf48a99b9714dd660178b8e27c3d9cb1670e0f9bcc71acb6ab87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / rill_gnn-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl

Download URL rill_gnn-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl
Size 341.2 kB
Tags CPython 3.8 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
11da64cfd89a58c137c77c47d5cb7abe9ab787fc76ef64631d6535d82ec9c086
BLAKE2b-256 checksum
How to use checksums
ef05ee1736fc5bbf5a6152088b41555eb792a58625bbe6b537db51d8dcfd6d4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Security for rill-gnn 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for rill_gnn-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

4 release files Full provenance

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