Skip to main content

A DQCsim frontend for cQASM files

Project description

DQCsim cQASM frontend

PyPi

See also: DQCsim and libqasm.

This repository contains some glue code to allow DQCsim to run cQASM files (file extension *.cq).

Status

The implementation is currently incomplete. The following things are missing:

  • The error model specified in the cQASM file is ignored. You'll have to configure stuff related to error modeling yourself through the respective simulation backend and/or operators.

  • measure_parity is not implemented.

Install

You can install using pip using pip install dqcsim-cqasm 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-cqasm; 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 setup.py 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 release.md for more info.

Usage

Once the plugin is installed, DQCsim will parse any file with a .cq file extension as a cQASM file through this plugin, so something like dqcsim test.cq qx should work (assuming dqcsim-qx is installed and test.cq exists).

The frontend ignores any arguments passed to its run callback and doesn't have anything useful to return (it just echoes back what you passed it).

As with QX, the display_binary "gate" is used to print simulation results to the terminal by means of printing the most recent measurement state. The frontend also outputs the measurement register contents at the end of the program as the ArbData returned by the run() call, in the following format:

{
    "qubits": [
        {  /* data for qubit 0 */
            "value": <value in qubit measurement register as 0 or 1>,
            "average": <measurement averaging register value>,
            "raw": <raw value returned by backend; 0 or 1, or null for undefined>,
            "json": <JSON part of the optional ArbData associated with the measurement>,
            "binary": [
                [<bytes of binary string 0 of ArbData associated with measurement>],
                [<bytes of binary string 1>],
                <etc., empty list if no ArbData>
            ]
        },
        {<data for qubit 1>},
        {<data for qubit 2>},
        <etc. for all qubits>
    ]
}

The raw, json, and binary keys are not present when the qubit was never measured at all. value defaults to 0 in that case. average is only present when the qubit has been measured since the latest reset_averaging operation.

The display "gate" doesn't provide any additional information over display_binary, as DQCsim frontends don't know what the actual quantum state is; this information is private to the backend. Refer to the documentation of the backend for ways to get additional information, if any. Be aware that DQCsim's qubit numbering starts at one, so the cQASM frontend adds 1 to the zero-referenced cQASM qubit indices to convert.

There is currently no way to attach arbs to gates or to the qubits themselves. If you need to do this, you can write an operator and insert it immediately behind the cQASM frontend.

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

dqcsim_cqasm-0.0.3-cp38-none-manylinux2010_x86_64.whl (258.8 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

dqcsim_cqasm-0.0.3-cp37-none-manylinux2010_x86_64.whl (258.8 kB view details)

Uploaded CPython 3.7 manylinux: glibc 2.12+ x86-64

dqcsim_cqasm-0.0.3-cp36-none-manylinux2010_x86_64.whl (258.8 kB view details)

Uploaded CPython 3.6 manylinux: glibc 2.12+ x86-64

dqcsim_cqasm-0.0.3-cp35-none-manylinux2010_x86_64.whl (258.8 kB view details)

Uploaded CPython 3.5 manylinux: glibc 2.12+ x86-64

File details

Details for the file dqcsim_cqasm-0.0.3-cp38-none-manylinux2010_x86_64.whl.

File metadata

  • Download URL: dqcsim_cqasm-0.0.3-cp38-none-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 258.8 kB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.10

File hashes

Hashes for dqcsim_cqasm-0.0.3-cp38-none-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 d4eabe22613a8a478aa1c0cf48a1a6ef56647268bd8f235b048e5429fa960f57
MD5 0b5dc9f89514d9ca1694629087fe7522
BLAKE2b-256 4a10286efc58cc4667b8daa6bd64a6c1f26da5d63d7253041bf45b87a23303c3

See more details on using hashes here.

File details

Details for the file dqcsim_cqasm-0.0.3-cp37-none-manylinux2010_x86_64.whl.

File metadata

  • Download URL: dqcsim_cqasm-0.0.3-cp37-none-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 258.8 kB
  • Tags: CPython 3.7, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.10

File hashes

Hashes for dqcsim_cqasm-0.0.3-cp37-none-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 13e99dd326d8649009fbfb3ab2644b67d122aa944ef5177729e6ed529a52ccf5
MD5 edf96c667c052539835fe03702c3a7d4
BLAKE2b-256 377bafe07f40c3bcc74bafee353e30029ed0acca298c289fd272e38c68b2c28b

See more details on using hashes here.

File details

Details for the file dqcsim_cqasm-0.0.3-cp36-none-manylinux2010_x86_64.whl.

File metadata

  • Download URL: dqcsim_cqasm-0.0.3-cp36-none-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 258.8 kB
  • Tags: CPython 3.6, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.10

File hashes

Hashes for dqcsim_cqasm-0.0.3-cp36-none-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 f085e66a3ac7dac746c402af29ec9b448521d1f9f7f1511af431da3d29152f9d
MD5 140be7e4f8c98f0137356bae1cae61bb
BLAKE2b-256 69761f6e1b066270621b2e83838aadbcec56bfeb8e475375f2b93d14c64b1b53

See more details on using hashes here.

File details

Details for the file dqcsim_cqasm-0.0.3-cp35-none-manylinux2010_x86_64.whl.

File metadata

  • Download URL: dqcsim_cqasm-0.0.3-cp35-none-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 258.8 kB
  • Tags: CPython 3.5, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.10

File hashes

Hashes for dqcsim_cqasm-0.0.3-cp35-none-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 d0930a7bef16516d8347a690a516c0beea02157bdd1ecf41799eee82baed9d6c
MD5 e674f2ac44a69652046f4d414693b76b
BLAKE2b-256 2dafce153359022b95b588d25a2e1a4dcdd0125e6ce004e58e7b7ae224df307b

See more details on using hashes here.

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