| Crates.io | prav-core |
| lib.rs | prav-core |
| version | 0.0.1 |
| created_at | 2026-01-08 09:58:51.516654+00 |
| updated_at | 2026-01-08 09:58:51.516654+00 |
| description | High-performance, no_std, zero-heap Union Find decoder for quantum error correction |
| homepage | https://github.com/qubitsok/prav |
| repository | https://github.com/qubitsok/prav |
| max_upload_size | |
| id | 2029877 |
| size | 917,692 |
High-performance, no_std, zero-heap Union Find decoder for quantum error correction.
no_std compatible: Works on embedded systems, FPGAs, and WebAssemblyuse prav_core::{Arena, DecoderBuilder, SquareGrid, EdgeCorrection, required_buffer_size};
// Calculate and allocate buffer
let size = required_buffer_size(32, 32, 1);
let mut buffer = vec![0u8; size];
let mut arena = Arena::new(&mut buffer);
// Create decoder using builder (automatically calculates STRIDE_Y)
let mut decoder = DecoderBuilder::<SquareGrid>::new()
.dimensions(32, 32)
.build(&mut arena)
.expect("Failed to build decoder");
// Decode syndromes
let syndromes = vec![0u64; 16]; // Empty syndromes for demo
let mut corrections = [EdgeCorrection::default(); 512];
decoder.load_dense_syndromes(&syndromes);
decoder.grow_clusters();
let count = decoder.peel_forest(&mut corrections);
// Reset for next cycle
decoder.reset_for_next_cycle();
The DecodingState struct requires a STRIDE_Y const generic equal to max(width, height, depth).next_power_of_two(). If using DecodingState directly:
use prav_core::{Arena, DecodingState, SquareGrid, required_buffer_size};
let size = required_buffer_size(32, 32, 1);
let mut buffer = vec![0u8; size];
let mut arena = Arena::new(&mut buffer);
// STRIDE_Y = 32 for a 32x32 grid (32.next_power_of_two() = 32)
let mut decoder: DecodingState<SquareGrid, 32> = DecodingState::new(&mut arena, 32, 32, 1);
Use DecoderBuilder to avoid this manual calculation.
| Topology | Neighbors | Use Case |
|---|---|---|
SquareGrid |
4 | Surface codes, toric codes |
Grid3D |
6 | 3D topological codes |
TriangularGrid |
6 | Color codes |
HoneycombGrid |
3 | Kitaev honeycomb model |
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 |
Rust 1.85 or later (Edition 2024).
Licensed under either of:
at your option.
Contributions are welcome! Please feel free to submit a Pull Request.