paulimer
Pauli and Clifford algebra for quantum computing.
Overview
paulimer provides efficient implementations of Pauli operators and Clifford unitaries, the building blocks for stabilizer quantum mechanics and quantum error correction.
Key Features:
-
Pauli Operators: Dense and sparse representations with phase tracking (±1, ±i)
- [
DensePauli]: Bit vectors optimized for operators on most qubits (O(n) memory) - [
SparsePauli]: Index sets for operators on few qubits in large systems (O(k) memory)
- [
-
Pauli Groups: Subgroup representation for stabilizer codes
- [
PauliGroup]: Membership testing, factorization, and structure queries - Essential for code verification and logical operator analysis
- [
-
Clifford Unitaries: Efficient representation enabling fast operations
- [
CliffordUnitary]: O(n²) Pauli conjugation via binary symplectic matrix - Supports all standard Clifford gates (H, S, CNOT, etc.)
- [
Based on algorithms from arXiv:2309.08676.
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Quick Start
Pauli Operators
use ;
// Dense notation: one character per qubit
let dense: DensePauli = "YIZI".parse.unwrap; // Y₀ ⊗ I₁ ⊗ Z₂ ⊗ I₃
assert_eq!; // Acts on 2 qubits
// Sparse notation: only specify non-identity positions
let sparse: SparsePauli = "Y0 Z2".parse.unwrap; // Same operator, compact
assert_eq!;
// Check commutation
let x: DensePauli = "XII".parse.unwrap;
let z: DensePauli = "ZII".parse.unwrap;
assert!; // X and Z anticommute
Pauli Groups
use ;
// Define stabilizer group for 3-qubit repetition code
let generators = vec!;
let group = new;
// Check properties
assert!;
assert_eq!; // 4 elements
// Test membership
let zzi = "ZZI"..unwrap;
assert!;
Clifford Unitaries
use ;
use ;
// Build CNOT gate
let mut cnot = identity;
cnot.left_mul_cx;
// Propagate Pauli through gate: X₀ → X₀ ⊗ X₁
let x0: DensePauli = "XI".parse.unwrap;
let image = cnot.image;
assert_eq!;
// Build circuits with UnitaryOp
let mut circuit = identity;
circuit.left_mul;
circuit.left_mul;
When to Use Each Type
| Type | Best For | Memory | Example |
|---|---|---|---|
DensePauli |
Operators on most qubits | O(n) | Error correction on small codes |
SparsePauli |
Few qubits in large systems | O(k) | Syndrome extraction, weight-k errors |
PauliGroup |
Stabilizer groups, code analysis | O(k·n) | Checking stabilizer properties |
CliffordUnitary |
Gate sequences, circuit analysis | O(n²) | Clifford circuit simulation |
Features
The crate supports optional features:
python: Enables Python bindings via PyO3serde: Enables serialization/deserialization supportschemars: Enables JSON schema generation
Enable features in your Cargo.toml:
[]
= { = "0.1.0", = ["serde"] }
Python Bindings
Python bindings are available in bindings/python/:
Then in Python:
# Create Pauli operators
=
# X₀
# Multiply operators
= *
# Should be Y₀ (X*Z = iY)
Performance
paulimer is designed for high performance:
- Built on top of binar for optimized bit operations
- Cache-aligned data structures for efficient memory access
- Sparse representations for large but sparse operators
- Benchmarks available in
benches/
Run benchmarks:
Documentation
Build and view comprehensive API documentation:
Key documentation:
DensePauli- Dense Pauli representation with examplesSparsePauli- Sparse Pauli representation for large systemsPauliGroup- Subgroup operations and stabilizer groupsCliffordUnitary- Clifford gates and Pauli conjugation- Trait documentation -
Pauli,Clifford, and other core traits
Contributing
This project welcomes contributions. See CONTRIBUTING.md for guidelines.
License
This project is licensed under the MIT License - see the LICENSE file for details.