NECSTAR: NEar-Clifford STAbilizer decomposition simulator in Rust (Python bindings)

A high-performance quantum circuit simulator designed for the strong simulation of near-Clifford circuits based on the stabilizer decomposition method [1].

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.

Features

  • Stabilizer Decomposition Core: The simulator represents the quantum state as a linear combination of stabilizer states [1]. This approach avoids the memory overhead of dense state vectors and is efficient for circuits with low non-Clifford gate counts.

  • Magic State Teleportation: Non-Clifford gates are applied via the gate teleportation protocol using magic states. A T-gate is implemented by consuming a T-state, and the tensor product of T-states is automatically decomposed into stabilizer states using optimized techniques [2].

  • Intuitive Declarative API: Users can define quantum computations by building a QuantumCircuit. This is compiled into a QuantumState, which manages the internal stabilizer decomposition and provides a clean interface for simulation.

References

Typical Workflow

  1. Construct a quantum circuit using QuantumCircuit.

  2. Compile the circuit into a QuantumState using from_circuit().

  3. Perform operations such as measure(), sample(), or exp_value().

Example

import necstar

# 1. Build a quantum circuit
qc = necstar.QuantumCircuit(2)
qc.apply_h(0)
qc.apply_cx(0, 1)
qc.apply_t(1) # Non-Clifford T-gate

# 2. Compile into a QuantumState (internally decomposes T-states)
state = necstar.QuantumState.from_circuit(qc)

# 3. Perform operations
shots = 1024
samples = state.sample(qargs=[0, 1], shots=shots)
print(f"Samples: {samples}")

pauli_z0 = necstar.PauliString.from_str("ZI")
exp_val = state.exp_value(pauli_z0)
print(f"Expectation value: {exp_val}")

# (Optional) Check the stabilizer rank
print(f"Stabilizer rank: {state.stabilizer_rank}")

Indices and tables