| Crates.io | necstar |
| lib.rs | necstar |
| version | 0.1.1 |
| created_at | 2026-01-02 18:06:16.064322+00 |
| updated_at | 2026-01-03 11:15:30.565743+00 |
| description | A stabilizer decomposition based quantum circuit simulator core library implemented in Rust. |
| homepage | https://github.com/mutekichi/necstar |
| repository | https://github.com/mutekichi/necstar |
| max_upload_size | |
| id | 2018972 |
| size | 177,196 |
A high-performance quantum circuit simulator designed for the strong simulation of near-Clifford circuits based on the stabilizer decomposition method.
NECSTAR is particularly effective for circuits dominated by Clifford gates but also containing a small number of non-Clifford gates. Currently, NECSTAR supports only T-gates as non-Clifford operations, but future versions may include additional non-Clifford gates.
To use NECSTAR as a library in your Rust project, add the following to your Cargo.toml:
[dependencies]
necstar = "0.1.1"
If you want to modify the source code, you can set up the project locally.
Clone the repository:
git clone git@github.com:mutekichi/necstar.git
Specify the path dependency in your Cargo.toml:
[dependencies]
necstar = { path = "/path/to/necstar/crates/necstar" }
Replace /path/to/necstar with the actual path to the cloned repository.
use necstar::prelude::{QuantumCircuit, QuantumState};
use necstar::types::PauliString;
use std::str::FromStr;
// 1. Build a quantum circuit
let mut circuit = QuantumCircuit::new(2);
circuit.apply_h(0);
circuit.apply_cx(0, 1);
circuit.apply_t(1); // Non-Clifford T-gate
// 2. Compile into a QuantumState (internally decomposes T-states)
let mut state = QuantumState::from_circuit(&circuit).unwrap();
// 3. Perform operations
let shots = 1024;
let samples = state.sample(&[0, 1], shots, None).unwrap();
println!("Samples: {:?}", samples);
let pauli_z0 = PauliString::from_str("ZI").unwrap();
let exp_val = state.exp_value(&pauli_z0).unwrap();
println!("Expectation value: {}", exp_val);
// (Optional) Check the stabilizer rank
println!("Stabilizer rank: {}", state.stabilizer_rank());
See the Documentation for more details and examples. If you are a Python user, please refer to the NECSTAR Python Documentation.