prav-core
High-performance, no_std, zero-heap Union Find decoder for quantum error correction.
Features
- Zero heap allocations: All memory from user-provided buffer via arena allocator
no_stdcompatible: Works on embedded systems, FPGAs, and WebAssembly- Multiple topologies: Square (surface codes), 3D, triangular (color codes), honeycomb
- Blazingly fast: SWAR bit operations, cache-optimized layout, path halving
Quick Start
use ;
// Calculate and allocate buffer
let size = required_buffer_size;
let mut buffer = vec!;
let mut arena = new;
// Create decoder using builder (automatically calculates STRIDE_Y)
let mut decoder = new
.dimensions
.build
.expect;
// Decode syndromes
let syndromes = vec!; // Empty syndromes for demo
let mut corrections = ;
decoder.load_dense_syndromes;
decoder.grow_clusters;
let count = decoder.peel_forest;
// Reset for next cycle
decoder.reset_for_next_cycle;
Understanding STRIDE_Y
The DecodingState struct requires a STRIDE_Y const generic equal to max(width, height, depth).next_power_of_two(). If using DecodingState directly:
use ;
let size = required_buffer_size;
let mut buffer = vec!;
let mut arena = new;
// STRIDE_Y = 32 for a 32x32 grid (32.next_power_of_two() = 32)
let mut decoder: = new;
Use DecoderBuilder to avoid this manual calculation.
Supported Topologies
| Topology | Neighbors | Use Case |
|---|---|---|
SquareGrid |
4 | Surface codes, toric codes |
Grid3D |
6 | 3D topological codes |
TriangularGrid |
6 | Color codes |
HoneycombGrid |
3 | Kitaev honeycomb model |
Memory Requirements
Use required_buffer_size(width, height, depth) to calculate exact buffer size:
| Grid Size | Approximate Buffer |
|---|---|
| 32x32 | ~100 KB |
| 64x64 | ~400 KB |
| 128x128 | ~1.6 MB |
| 256x256 | ~6.4 MB |
Minimum Supported Rust Version
Rust 1.85 or later (Edition 2024).
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.