CppMPS: MPS-like emulator capable of running on multiple HPC nodes

CppMPS relies on the same state-vector representation as MPS, but is implemented in C++ and can be executed on multiple HPC nodes (using the Message Passing Interface - MPI - protocol). This emulator is often faster MPS even for single-node CPU emulations but MPS implements more execution policy than CppMPS.

By default, every job submitted to this emulator will be preprocessed to improve the performances of the emulation. The pre-processing is composed of:

Using the right number of nodes

The number of HPC nodes required to run this emulator will rely on the bond-dimension \(\chi\) (passed as argument of this emulator), the amount of RAM \(MEM_{node}\) available on each node, and the number of qubits \(n_{qubits}\) to emulate.

The number of qubits per nodes is -, the number of nodes is -

Mathematical formula

The number of qubits emulatable on each node is given by:

\[n_{qubits\_per\_node} = \left\lfloor \frac{\frac{MEM_{node}}{8B} - \chi}{4 \cdot \chi^2 + \chi} \right\rfloor\]

Then, the number of nodes is given by:

\[n_{nodes} = \left\lceil \frac{n_{qubits}}{n_{qubits\_per\_nodes} - 1} \right\rceil\]

Example of a simulation on a cluster

Running CppMPS requires to provide two scripts, a Python script and a Slurm script. These two scripts are:

  • A python script describing the quantum program to be emulated, and ressembles a program used by other Qaptiva emulators:

    from qat.core import Job
    from qat.plugins import ScipyMinimizePlugin
    from qat.qpus import CppMPS
    
    variational_job = Job.load("my_variational_job.job")
    result = (ScipyMinimizePlugin() | CppMPS()).submit(variational_job)
    
    print(f"Minimal value: {result.value}")
    

    Note

    Please note that neither the number of nodes, nor the number of processes per nodes have to be specified in this Python script. These value are inherited from the Slurm script.

  • A Slurm script specifying the resources to used, and executing the python script defined above. The Slurm script may look like:

    #!/bin/bash
    
    #SBATCH --partition XXX // partition of the cluster to be used
    #SBATCH --nodes 8 // number of nodes
    #SBATCH --time 24:00:00 // time limit of the simulation job
    #SBATCH --job-name my_variational_job // name of the job
    #SBATCH --output slurm-%A_%x_%N_%t.out // SLURM output file format
    #SBATCH --error slurm-%A_%x_%N_%t.err // SLURM error file format
    #SBATCH --exclusive // reserve the nodes on exclusive mode
    
    module load qaptiva-hpc
    python3 -u my_variational_job.py  # Script defined above
    

Your Slurm script can then be scheduled using:

sbatch my_slurm_script.sh

The output of your Python script will be dumped in a file managed by Slurm (see filename specified by --output and --error in the Slurm script). The content of this file may look like:

Minimal value: 52.3