quantrs2
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.
Quick Start
Add this to your Cargo.toml:
[]
# Enable all features
= { = "0.1.0-beta.2", = ["full"] }
# Or select specific features
= { = "0.1.0-beta.2", = ["circuit", "sim"] }
Then use it in your code:
// With the facade crate, modules are available under quantrs2::
use *; // QubitId, Register, QuantRS2Result
use ; // Circuit and the Simulator trait
use StateVectorSimulator; // Feature "sim"
Available Features
| 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 |
Module Structure
When you enable features, the corresponding modules become available:
// Core is always available
use core;
// Available with "circuit" feature
use circuit;
// Available with "sim" feature
use sim;
// Available with "anneal" feature
use anneal;
// Available with "device" feature
use device;
// Available with "ml" feature
use ml;
// Available with "tytan" feature
use tytan;
// Available with "symengine" feature
use symengine;
Feature Dependencies
Some features automatically enable others for convenience:
sim→ enablescircuitanneal→ enablescircuitdevice→ enablescircuitml→ enablessimandanneal(which also enablescircuit)tytan→ enablesanneal(which also enablescircuit)
When to Use This Crate
Use quantrs2 when:
- You want a simple, unified dependency
- You're building applications that use multiple QuantRS2 components
- You prefer feature flags over managing multiple crate dependencies
- You want the convenience of a single import namespace
Use individual crates when:
- You only need specific functionality (e.g., just
quantrs2-core) - You want minimal compile times and dependencies
- You're building libraries that should have minimal dependencies
- You need fine-grained control over versions
Example Configurations
Minimal quantum programming:
= { = "0.1.0-beta.2", = ["circuit"] }
Circuit simulation:
= { = "0.1.0-beta.2", = ["sim"] }
Quantum machine learning:
= { = "0.1.0-beta.2", = ["ml"] }
Hardware interaction:
= { = "0.1.0-beta.2", = ["device", "sim"] }
Everything:
= { = "0.1.0-beta.2", = ["full"] }
Alternative: Individual Crates
If you prefer to use individual crates instead of the facade:
[]
= "0.1.0-beta.2"
= "0.1.0-beta.2"
= "0.1.0-beta.2"
# etc.
End-to-End Example
This example builds a Bell state on 2 qubits and prints the probabilities. Enable features circuit and sim.
use *;
use ;
use StateVectorSimulator;
Documentation
Subcrates
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-symengine
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.