Source-linked AI summary

Qulacs: a fast and versatile quantum circuit simulator for research purpose

Yasunari Suzuki, Yoshiaki Kawase, Yuya Masumura, Yuria Hiraga, Masahiro Nakadai, Jiabao Chen, Ken M. Nakanishi, Kosuke Mitarai, Ryosuke Imai, Shiro Tamiya, Takahiro Yamamoto, Tennin Yan, Toru Kawakubo, Yuya O. Nakagawa, Yohei Ibe, Youyuan Zhang, Hirotsugu Yamashita, Hikaru Yoshimura, Akihiro Hayashi, Keisuke Fujii

arXiv:2011.13524v4quant-phphysics.comp-ph

TL;DR

Quantum-circuit simulation is essential for studying near-term and fault-tolerant quantum computing, but its runtime grows exponentially with qubit count. This paper introduces Qulacs, a research-oriented simulator using optimized state updates, parallelism, GPU acceleration, and circuit optimization. Benchmarks and comparisons show advantages in several scenarios, particularly for small-qubit simulations, while performance measurements depend on circuit and execution conditions.

  • Problem

    Quantum-circuit simulation is needed for ideal references, noisy-circuit analysis, and quantum-error-correction studies, despite runtime increasing exponentially with qubit count.

  • Method

    Qulacs combines optimized state-update functions with SIMD, OpenMP, GPU acceleration, circuit optimization, and support for research-oriented quantum operations.

  • Results

    Qulacs is one of the fastest simulators in several research-relevant regions and shows significant speed-up when the number of qubits is small.

  • Takeaways & Limitations

    Qulacs can support simulations with many layers and serve as a backend for libraries such as Cirq and OpenFermion.

  • Takeaways & Limitations

    Benchmark timings vary with circuit structure, library versions, compilers, hardware, and simulation environment, with a few-percent difference in multi-thread and GPU results considered meaningless.

Abstract

from arXiv · show

To explore the possibilities of a near-term intermediate-scale quantum algorithm and long-term fault-tolerant quantum computing, a fast and versatile quantum circuit simulator is needed. Here, we introduce Qulacs, a fast simulator for quantum circuits intended for research purpose. We show the main concepts of Qulacs, explain how to use its features via examples, describe numerical techniques to speed-up simulation, and demonstrate its performance with numerical benchmarks.

1 Introduction

Quantum-circuit simulation is important for developing and evaluating quantum computers, but its time grows exponentially with qubit count. Qulacs is introduced as a fast, versatile simulator designed for quantum-computing research.

  • Motivation: Classical simulation provides ideal results for comparison with error-prone quantum devices and supports analyses unavailable from direct measurement.It is also used for simulating noisy circuits under arbitrary noise models.
  • Motivation: Although full quantum-circuit simulation is computationally inefficient, implementing it as fast as possible remains important.
  • Contribution: Qulacs targets research needs including near-term applications, quantum error correction, and quantum benchmark methods.
  • Contribution: Qulacs provides interfaces across popular environments and is presented as one of the fastest quantum-circuit simulators.
  • Paper scope: The paper presents Qulacs’ structure, optimization methods, numerical benchmarks, and comparisons with existing simulators.

2 Overview

Qulacs is a research-oriented simulator that combines optimized execution, low overhead, broad quantum-operation support, and multiple programming environments. Its design uses the Schrödinger method while distinguishing it from alternative simulation approaches and existing libraries.

  • Features of Qulacs: Qulacs accelerates large-circuit simulation through optimized and parallelized CPU, SIMD, GPU, and circuit-optimization techniques.These techniques can provide a few orders of magnitude performance improvement over naive implementations.
  • Features of Qulacs: Qulacs provides interfaces for Python and C++, supports GCC and MSVC, and is tested on Linux, Windows, and Mac OS.
  • Features of Qulacs: Qulacs supports general operations including completely positive instruments and adaptive quantum gates conditioned on measurement results.
  • Structure of Qulacs: Qulacs consists of C, C++, and variational-method libraries, with runtime selection of gate implementations based on qubit count.
  • Simulation methods: Qulacs implements Schrödinger’s method, which sequentially updates state vectors or density matrices by applying quantum gates as general maps.
  • Simulation methods: Feynman’s approach sums path contributions and can reduce memory requirements, while tensor-network simulation scales with network tree-width.
  • Relation to existing libraries: Qulacs focuses on research-oriented optimization, low overhead for small simulations, general quantum operations, and varied environments.

3 Expected usages of Qulacs

Qulacs is intended for research workflows spanning repeated small variational simulations and single large many-body simulations. It also supports quantum-error-correction analysis, experimental references, and use as a backend for other libraries.

  • Near-term applications: Qulacs supports variational quantum-circuit workflows that repeatedly simulate relatively small circuits while optimizing a target function.Variational angles can serve as parameters of a cost function, as in VQE.
  • Large-system simulation: Qulacs also supports large quantum-system simulations for exploring many-body physics, where memory and time limit circuit size.
  • Research integration: Qulacs has been used in research on NISQ applications and fault-tolerant quantum computing and can serve as a faster backend for higher-layer libraries.
  • Error-correction analysis: Quantum-error-correction performance analysis uses simulation because required qubit counts depend strongly on error-correcting-scheme performance.
  • Experimental reference: Portable, fast simulators remain useful for generating small-scale experimental references even when quantum-supremacy circuits require supercomputers.

4.1 Overview

Qulacs represents quantum states through a common base class and updates them with quantum operations, while providing observable evaluation and CPU or GPU execution. The paper illustrates these features primarily through Python examples.

  • Quantum states: Qulacs supports state-vector and density-matrix representations through the StateVector and DensityMatrix classes.
  • Quantum states: QuantumStateBase utilities initialize states, compute marginal probabilities, sample measurement results, and store measurement outcomes in classical registers.
  • Quantum operations: QuantumGateBase subclasses update quantum states using unitary operations, projection measurements, and general quantum maps.Supported maps include completely-positive instruments and completely-positive trace-preserving maps.
  • Observables: Observable represents linear combinations of Pauli operators for evaluating expectation values and creating Trotterized circuits.
  • Execution: Qulacs uses CPU StateVector simulation by default and supports GPU execution through StateVectorGpu.GPU-allocated states are updated and evaluated on the GPU unless explicitly converted to StateVector.
  • Examples: The paper explains typical features with Python examples while noting that Qulacs is also available as a C++ library.

4.2 Quantum state

Qulacs represents quantum states with StateVector objects that support flexible initialization, copying, inspection, sampling, and analysis-oriented transformations.

  • Initialization: StateVector allocates a quantum state initialized by default to |0⟩⊗n, with alternatives including computational-basis, supplied-array, and randomized pure states.States can also be copied or loaded from another StateVector.
  • State properties: Built-in functions evaluate full vectors, marginal probabilities, squared norms, inner products, and Z-basis sampling.Sampling preprocesses a cumulative probability distribution and temporarily allocates additional 2n-length storage.
  • State manipulation: StateVector supports analysis operations including scalar multiplication, index-dependent elementwise multiplication, state addition, tensor products, qubit permutation, and qubit dropping.These operations are useful for theoretical analysis even when they are not physically achievable.

4.3 Quantum gates

Qulacs models quantum gates as state-update operations and accelerates them by exploiting limited target support, structured matrices, and specialized implementations.

  • Basic gate model: Basic gates update density operators as ρ 7→KρK† and pure-state vectors as |ψ⟩ 7→K|ψ⟩, without requiring K to be unitary.Non-basic maps such as CPTP maps, projection measurements, and adaptive operations are represented using basic gates.
  • Gate updates: A gate acting nontrivially on m target qubits uses a 2m × 2m gate matrix, while basis-state transitions vanish when non-target bits differ.This decomposes the n-qubit update into target-subspace operations across the remaining qubit configurations.
  • Gate updates: Naive dense-matrix updates require 2n−m iterations, each reading and writing 2m complex numbers around a matrix-vector multiplication.The implementation therefore incurs repeated memory transfers in addition to arithmetic work.
  • Optimization: Gate application time is governed by arithmetic and memory-operation costs, with total dense-gate costs O(2n+m) and O(2n + 2n+m).For small m, effective memory cost is approximated as O(2n).
  • Optimization: Specialized subclasses exploit structured gate matrices to reduce arithmetic cost, memory cost, or both.ReversibleBoolean implements permutation-matrix operations with arithmetic and memory costs O(2n), independent of target-qubit count m.

4.4 Quantum circuit

Qulacs represents circuits as ordered arrays of quantum gates and provides APIs for editing, executing, and parameterizing those circuits.

  • Circuit representation: QuantumCircuit stores gates in an array, allowing users to append or insert gates at positions and remove gates from specified positions.The class also exposes circuit-structure queries such as depth, gate count, and gate copies.
  • Circuit execution: Calling update_quantum_state applies every contained gate sequentially to a supplied quantum state.This provides the execution path from a circuit description to a state update.
  • Parametric circuits: ParametricQuantumCircuit supports parametric RX, RY, RZ, and Pauli-rotation gates whose angles can be read and varied through parameter functions.Users can retrieve or set parameter values and locate a parametric gate by parameter index.

4.5 Observable

Qulacs represents observables as Pauli-operator combinations, evaluates expectation values and transition amplitudes, and supports Hamiltonian evolution and OpenFermion interoperability.

  • Observable representation: Observables are linear combinations of Pauli matrices with real coefficients, constructed from PauliOperator terms and managed through the Observable class.Qulacs computes expectation values for one state and transition amplitudes for two states.
  • Hamiltonian evolution: Hamiltonian time evolution is added to circuits through Trotter-decomposed observable-rotation gates.The rotation-gate function generates a gate set for evolution under a supplied Hamiltonian.
  • Interoperability: Molecular Hamiltonian expressions from OpenFermion can be converted into Qulacs observables after fermionic-to-Pauli transformations.The create_quantum_operator_from_openfermion_text function loads OpenFermion text into Qulacs.

5 Optimizations

Qulacs accelerates circuit simulation by reducing function, arithmetic, memory, and data-movement costs across CPUs and GPUs. Its optimizations include SIMD, multithreading, gate merging, and device-specific memory management.

  • Performance model: Simulation time reflects function-call overhead plus arithmetic and memory operations, with Python interfaces, parallel functions, and GPU kernels adding overhead.The paper models gate-application time using these components, while noting that computation and memory operations may overlap.
  • Performance model: For small qubit counts, Qulacs minimizes pre- and post-processing overhead; for larger counts, arithmetic and memory costs grow exponentially with n.The optimization priorities change as overhead gives way to Ncom/VFLOPS and Nmem/VBW.
  • SIMD optimization: AVX2 processes up to four real values simultaneously, reducing arithmetic instruction count Ncom by at most a factor of four.Qulacs hand-optimizes several update functions and enables AVX2 during installation when supported.
  • SIMD optimization: Qulacs combines loop unrolling and bitwise index computation to SIMDize dense matrix gates despite scattered state-vector accesses.The strategy depends on target-qubit indices, while reducing enumeration costs when the number of target qubits is small.
  • Multithreading: OpenMP parallelizes update functions across CPU cores, increasing effective instruction throughput when arithmetic work is compute-bound and sufficiently distributed.The number of threads is controlled through OMP_NUM_THREADS.
  • Circuit optimization: Circuit optimization trades memory operations for arithmetic operations by merging gates, with light and heavy strategies offering different optimization costs and benefits.Light optimization greedily merges neighboring compatible gates; heavy optimization can merge more gates but takes longer, and its overall benefit depends on circuit structure and hardware.
  • GPU acceleration: GPU acceleration exploits higher bandwidth and peak performance, while Qulacs places state vectors and gate data across GPU memory types according to their capacities and access costs.Whole state vectors use global memory, and GPU-resident states can support processing on selected devices or simultaneous multi-GPU tasks.

6 Numerical performance

Qulacs benchmarks show exponential scaling with qubit count, while specialized representations, optimized interfaces, parallelism, and circuit optimization substantially affect practical simulation time. Performance depends on workload size, memory behavior, cache capacity, and optimization settings.

  • Basic gates: All basic-gate application times grow exponentially with the total number of qubits.For small circuits, Python-to-C++ call overhead causes gate timings to converge.
  • Basic gates: Dense matrix-gate times increase with target-qubit count, while m = 1, 2 are faster because Qulacs applies specific optimizations.Their similar timings indicate memory-operation costs, rather than arithmetic-operation costs, dominate in that regime.
  • Basic gates: Diagonal, Pauli rotation, and permutation gate times are independent of target-qubit count m; diagonal gates with m = 1 receive additional optimization.The authors recommend diagonal rather than dense matrix gates when the number of target qubits is large.
  • Basic gates: Controlled-gate timings show no clear scaling with control-qubit count because SIMD optimization and memory-operation costs dominate.Timing jumps at 17 and 22 qubits occur when the state vector exceeds cache capacity, changing memory bandwidth discontinuously.
  • General quantum maps: CPTP maps and instruments are about 10 times slower than dense matrix gates, whereas probabilistic maps have similar performance to dense matrix gates.CPTP maps and instruments additionally calculate Kraus-operator probabilities and allocate and release a temporary buffer.
  • Interface overhead: Python-to-C++ calls cost about 0.3 µs, and using Qulacs as a C++ library can increase speed by up to about seven times below 10 qubits.The interface overhead is not negligible for small quantum circuits.
  • SIMD, OpenMP, and GPU: SIMD is consistently faster than non-SIMD execution; OpenMP helps above roughly 14 qubits for m = 1, 2 and 10 qubits for m = 3, 4, while GPUs help at large sizes.OpenMP and GPU execution introduce overhead, including about 10 µs for GPU variants, so Qulacs disables OpenMP automatically for small cases.
  • Parallelization efficiency: At n = 15, parallelization efficiency saturates around t = 10 and then declines as thread count increases because parallelization overhead dominates.Efficiency improves with larger qubit counts until an exceptional superlinear improvement at n = 22 caused by cache placement across two CPUs.

7 Comparison with existing simulators

Qulacs is compared with existing simulators using single-thread CPU, multithread CPU, and GPU benchmarks under carefully specified but not perfectly identical conditions. It is among the fastest in several practically important regions, particularly for small circuits.

  • Benchmark setup: The benchmark evaluates random quantum circuits under single-thread CPU, multithread CPU, and GPU settings across several libraries.The framework uses alternating rotation and CNOT layers repeated ten times, with library-specific installation and evaluation settings documented.
  • Benchmark caveats: Benchmark differences of a few percent in multithread and GPU results are not meaningful because those timings fluctuate across runs and environments.Comparisons are also affected by library purpose and design; some competing libraries support distributed computing rather than single-node optimization.
  • Multithread CPU: Qulacs has the fastest multithread execution for small circuits, while larger circuits show convergence among several libraries without circuit optimization.With multithreading enabled, memory operations rather than arithmetic operations determine execution time, causing several implementations to approach similar times.
  • GPU acceleration: GPU circuit optimization is consistently beneficial because its overhead is negligible relative to GPU function-call overhead.Heavy optimization with block size four is reported as optimal in the tested GPU benchmarks and surpasses light optimization above 19 qubits.
  • Overall comparison: Qulacs is one of the fastest simulators in several benchmark regions, with particularly significant speed-ups for small numbers of qubits.The paper identifies small-circuit performance as important for exploring quantum computing possibilities.

8 Conclusion and Outlook

Qulacs is presented as a fast, versatile simulator optimized through gate-specific updates, SIMD, multi-threading, GPU acceleration, and circuit optimization. Benchmarks compare it with existing libraries, while future work targets specialized algorithms for Clifford and matchgate circuits.

  • Conclusion and Outlook: Qulacs combines gate-matrix-specific update functions with SIMD, OpenMP multi-threading, GPU acceleration, and circuit optimization for numerical speed-up.These techniques are used to improve simulation performance across several hardware and circuit-optimization settings.
  • Conclusion and Outlook: The paper evaluates concrete simulation times for several quantum gates and measures speed-ups from the optimization techniques.
  • Conclusion and Outlook: Benchmarks show advantages for Qulacs in several scenarios, including use as a backend for layered simulations in Cirq and OpenFermion.The simulator focuses on fundamental operations while supporting these higher-level libraries as backends.
  • Conclusion and Outlook: Specialized algorithms for circuits composed only of Clifford gates or matchgates are identified as planned future additions for faster simulation.Such circuits can already be efficiently simulated through specialized algorithms, but Qulacs plans to implement support for them.

A C++ example codes

The C++ example demonstrates creating, modifying, updating, and releasing quantum states and gates through an API designed to closely match the Python library. It constructs dense and SWAP gates, applies them to a two-qubit state, and prints gate and state information.

  • C++ example codes: The example creates a quantum state, sets a computational-basis state, loads a sub-state, and initializes a Haar-random state.The listed procedures include set_computational_basis, load, and set_Haar_random_state operations.
  • C++ example codes: The program constructs a 4×4 dense matrix gate and a SWAP gate, then updates the quantum state with both gates.The dense gate uses an Eigen complex matrix, while the SWAP gate is created through the gate interface.
  • C++ example codes: The C++ API uses names and designs almost identical to the Python library, with small differences such as supplying complex matrices through Eigen.
Loading 2011.13524v4…