Crates.io | quantrs2 |
lib.rs | quantrs2 |
version | 0.1.0-beta.1 |
created_at | 2025-06-30 14:20:23.47324+00 |
updated_at | 2025-09-21 14:14:45.460448+00 |
description | Comprehensive Rust quantum computing framework - unified entry point for quantum simulation, algorithm development, and hardware interaction |
homepage | https://github.com/cool-japan/quantrs |
repository | https://github.com/cool-japan/quantrs |
max_upload_size | |
id | 1731887 |
size | 117,558 |
Facade crate for QuantRS2: unified entry point and documentation
This crate provides a single, convenient entry point that re-exports the public APIs from all QuantRS2 subcrates. Instead of managing multiple dependencies, you can simply add quantrs2
with the features you need.
Add this to your Cargo.toml
:
[dependencies]
# Enable all features
quantrs2 = { version = "0.1.0-beta.1", features = ["full"] }
# Or select specific features
quantrs2 = { version = "0.1.0-beta.1", features = ["circuit", "sim"] }
Then use it in your code:
// With the facade crate, modules are available under quantrs2::
use quantrs2::core::api::prelude::essentials::*; // QubitId, Register, QuantRS2Result
use quantrs2::circuit::builder::{Circuit, Simulator}; // Circuit and the Simulator trait
use quantrs2::sim::statevector::StateVectorSimulator; // Feature "sim"
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a 2-qubit circuit (const-generic N)
const N: usize = 2;
let mut circuit = Circuit::<N>::new();
circuit.h(QubitId::new(0))?;
circuit.cx(QubitId::new(0), QubitId::new(1))?;
// Simulate the circuit
let mut simulator = StateVectorSimulator::new();
let result: Register<N> = simulator.run(&circuit)?;
println!("Measurement results: {:?}", result);
Ok(())
}
Feature | Description | Dependencies |
---|---|---|
circuit |
Quantum circuit construction and optimization | quantrs2-circuit |
sim |
Quantum simulators (state vector, stabilizer, etc.) | quantrs2-sim , circuit |
anneal |
Quantum annealing algorithms | quantrs2-anneal , circuit |
device |
Hardware backends and device interfaces | quantrs2-device , circuit |
ml |
Quantum machine learning algorithms | quantrs2-ml , sim , anneal |
tytan |
TYTAN quantum annealing integration | quantrs2-tytan , anneal |
symengine |
Symbolic computation with SymEngine | quantrs2-symengine |
full |
All features enabled | All of the above |
When you enable features, the corresponding modules become available:
// Core is always available
use quantrs2::core;
// Available with "circuit" feature
use quantrs2::circuit;
// Available with "sim" feature
use quantrs2::sim;
// Available with "anneal" feature
use quantrs2::anneal;
// Available with "device" feature
use quantrs2::device;
// Available with "ml" feature
use quantrs2::ml;
// Available with "tytan" feature
use quantrs2::tytan;
// Available with "symengine" feature
use quantrs2::symengine;
Some features automatically enable others for convenience:
sim
→ enables circuit
anneal
→ enables circuit
device
→ enables circuit
ml
→ enables sim
and anneal
(which also enables circuit
)tytan
→ enables anneal
(which also enables circuit
)Use quantrs2
when:
Use individual crates when:
quantrs2-core
)quantrs2 = { version = "0.1.0-beta.1", features = ["circuit"] }
quantrs2 = { version = "0.1.0-beta.1", features = ["sim"] }
quantrs2 = { version = "0.1.0-beta.1", features = ["ml"] }
quantrs2 = { version = "0.1.0-beta.1", features = ["device", "sim"] }
quantrs2 = { version = "0.1.0-beta.1", features = ["full"] }
If you prefer to use individual crates instead of the facade:
[dependencies]
quantrs2-core = "0.1.0-beta.1"
quantrs2-circuit = "0.1.0-beta.1"
quantrs2-sim = "0.1.0-beta.1"
# etc.
This example builds a Bell state on 2 qubits and prints the probabilities. Enable features circuit
and sim
.
use quantrs2::core::api::prelude::essentials::*;
use quantrs2::circuit::builder::{Circuit, Simulator};
use quantrs2::sim::statevector::StateVectorSimulator;
fn main() -> Result<(), Box<dyn std::error::Error>> {
const N: usize = 2;
let mut circuit = Circuit::<N>::new();
circuit.h(QubitId::new(0))?; // H on qubit 0
circuit.cx(QubitId::new(0), QubitId::new(1))?; // CNOT 0->1
let sim = StateVectorSimulator::new();
let reg: Register<N> = sim.run(&circuit)?;
let probs = reg.probabilities();
println!(
"|00>: {:.3}, |01>: {:.3}, |10>: {:.3}, |11>: {:.3}",
probs[0], probs[1], probs[2], probs[3]
);
Ok(())
}
quantrs2-core
: Core types, math, error handling, and APIs — https://github.com/cool-japan/quantrs/tree/master/corequantrs2-circuit
: Circuit builder, DSL, optimization — https://github.com/cool-japan/quantrs/tree/master/circuitquantrs2-sim
: Simulators (statevector, stabilizer, MPS, etc.) — https://github.com/cool-japan/quantrs/tree/master/simquantrs2-anneal
: Quantum annealing algorithms and workflows — https://github.com/cool-japan/quantrs/tree/master/annealquantrs2-device
: Hardware/device connectors and scheduling — https://github.com/cool-japan/quantrs/tree/master/devicequantrs2-ml
: Quantum machine learning utilities — https://github.com/cool-japan/quantrs/tree/master/mlquantrs2-tytan
: High-level annealing interface inspired by TYTAN — https://github.com/cool-japan/quantrs/tree/master/tytanquantrs2-symengine
: Symbolic computation bindings — https://github.com/cool-japan/quantrs/tree/master/quantrs2-symengineLicensed under either of
at your option.