2 unstable releases
| 0.2.0 | Sep 21, 2025 |
|---|---|
| 0.1.0 | Sep 21, 2025 |
#642 in Simulation
Used in 2 crates
105KB
2K
SLoC
quantsim_core
A pure Rust library for quantum circuit simulation. This crate provides the core simulation engine for quantum computing, designed to be portable and reusable without any UI dependencies.
Features
- Pure Rust Implementation: No UI dependencies, making it suitable for integration into any Rust project
- Comprehensive Gate Library: Support for standard quantum gates including single-qubit, multi-qubit, and parametric gates
- Custom Gate Support: Define your own unitary gates programmatically
- Embedded Circuit Templates: Built-in quantum algorithm examples (Bell states, Grover's algorithm, QFT, etc.)
- Parallel Execution: Uses Rayon for efficient parallelization of computationally intensive operations
- Introspection API: Detailed per-timestep snapshots of quantum state evolution
- JSON Serialization: Easy circuit persistence and sharing
Usage
Add this to your Cargo.toml:
[dependencies]
quantsim_core = "0.1.0"
Basic Example
use quantsim_core::{Circuit, Engine, GateRegistry};
let mut registry = GateRegistry::new();
registry.register_standard_gates();
// Create a Bell state circuit
let mut circuit = Circuit::new(2);
circuit.add_gate("H", &[0]).unwrap();
circuit.add_gate("CX", &[0, 1]).unwrap();
// Simulate
let mut engine = Engine::new();
let result = engine.run(&circuit, None).unwrap();
println!("Final state: {:?}", result.final_state);
Loading Built-in Templates
use quantsim_core::circuits;
let bell_circuit = circuits::load_template("bell").unwrap();
Architecture
The library is organized into several key modules:
circuit: Quantum circuit representation and manipulationengine: Simulation execution enginegates: Gate definitions and registry systemtypes: Core data types and representationscircuits: Built-in circuit templates
Performance
- Parallel gate application using Rayon
- Efficient state vector representation
- Optimized for both small educational circuits and larger quantum algorithms
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
Dependencies
~7MB
~143K SLoC