Skip to main content

A DQCsim backend for the QX simulator

Project description

DQCsim QX backend


See also: DQCsim and QX.

This repository contains some glue code to use the QX simulator as a DQCsim backend.


The backend should support:

  • The following gates: H, cnot, Toffoli, I, X, Y, Z, S, S', T, T', CZ, swap, RX(angle), RY(angle), RZ(angle), measure X/Y/Z, prep X/Y/Z.
  • Depolarizing channel error model.
  • Dynamic qubit allocation upstream, as long as the number of qubits ever live at a time does not increase after the first measurement (prefixing the algorithm with an allocation of the desired number of qubits followed by a free of those qubits is enough to tell the backend you want to allocate that many).


You can install using pip using pip install dqcsim-qx or equivalent. If you're installing with --user, make sure that the path Python installs the executables into is in your system path, otherwise DQCsim will not be able to find the plugin. A simple way to see where the files are installed is to run pip uninstall dqcsim-qx; it shows which files it's about to delete before querying for confirmation.

Building/installing from source

  • Make sure all git submodules are checked out: git submodule update --init --recursive

  • Build the wheel file locally: python3 build bdist_wheel

  • Install the wheel file you just built: pip install target/python/dist/* (or equivalent)

Don't push a build like this to PyPI or attempt to distribute this wheel; it will likely only work locally due to hardcoded paths and the likes. Refer to for more info.


Once the plugin is installed, you can use it by selecting the qx backend in a DQCsim command.

The following ArbCmds are supported for initialization and at runtime from host or upstream unless otherwise specified:

  • qx.error: selects the error model using the JSON argument, which can be:

    • {"model": "none"} to disable error;
    • {"model": "depolarizing_channel", "error_probability": <float>} to select the depolarizing channel error model. Note that like QX itself, this model does not take gate timing into consideration; it simply inserts an X, Y, or Z gate with the given probability before any gate in the circuit.

    If the error model is modified during execution, the model is applied retroactively back to the previous measurement, because the backend queues up gates in a circuit until a measurement gate is seen.

  • qx.dump_state: dumps the state of the quantum register, flushing the aforementioned gate queue to synchronize the state of the quantum register.

  • qx.epsilon (only for init()): specifies the gate detection RMS tolerance using a JSON argument of the form {"epsilon": <float>}. Epsilon defaults to 1e-6.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page