{ "info": { "author": "Steven Oud", "author_email": "soud@pm.me", "bugtrack_url": null, "classifiers": [ "Environment :: Console", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3 :: Only", "Topic :: Software Development :: Assemblers" ], "description": "# qsy\nA quantum computer state vector/stabilizer circuit simulator and assembly\nlanguage.\n\n## Table of Contents\n* [Installation](#installation)\n* [qsy](#qsy-1)\n * [Example](#example)\n* [qsyASM](#qsyasm)\n * [Usage](#usage)\n * [Example](#example-1)\n * [Syntax](#syntax)\n * [Operations](#operations)\n * [Adjoint Operation](#adjoint-operation)\n * [List of Operations](#list-of-operations)\n * [Registers](#registers)\n * [Measurement](#measurement)\n * [Efficient simulation of stabilizer circuits](#efficient-simulation-of-stabilizer-circuits)\n* [License](#license)\n\n## Installation\n```\n$ pip install qsy\n```\n\nThis will install the Python library qsy and command-line tool qsyasm.\n\n## qsy\nqsy is a Python library for simulating quantum circuits.\n\n### Example\nThe following code creates an entangled state and prints its state vector in\nDirac notation.\n```python\nfrom qsy import QuantumRegister, gates\n\nqr = QuantumRegister(2)\nqr.apply_gate(gates.H, 0)\nqr.apply_gate(gates.CX, 0, 1)\n\nprint(qr.to_dirac())\n```\nThe output will be:\n```\n+0.70711|00> +0.70711|11>\n```\n\n## qsyASM\nqsyASM is a quantum assembly language acting as front-end for qsy. It allows\nyou to quickly write and debug quantum programs. It also allows for efficient\nsimulation of stabilizer circuits using the `chp` back-end.\n\n### Usage\n```\nusage: qsyasm [-h] [-V] [-v] [-t] [-b B] [-s SHOTS] [--ignore-print-warning]\n [--skip-zero-amplitudes]\n filename\n\nqsyasm assembly runner\n\npositional arguments:\n filename qsyasm file to execute\n\noptional arguments:\n -h, --help show this help message and exit\n -V, --version show program's version number and exit\n -v, --verbose verbose output\n -t, --time time program execution\n -b B, --backend B simulator back-end to use: chp or statevector\n (default: statevector)\n -s SHOTS, --shots SHOTS\n amount of shots to run\n --ignore-print-warning\n ignore register too large to print warning\n --skip-zero-amplitudes\n don't print states with an amplitude of 0\n```\n\n### Example\nThe following qsyASM program creates an entangled state and measures to a\nclassical register:\n```asm\nqreg[2] q\ncreg[2] c\n\nh q[0]\ncx q[0], q[1]\n\nmeas q, c\n```\nRunning it:\n```\n$ qsyasm examples/qsyasm/bell.qs\nq[2]: +1|11>\n +0 | 00\n +0 | 01\n +0 | 10\n +1 | 11\nc[2]: 11\n```\nOr running it a number of times:\n```\n$ qsyasm examples/qsyasm/bell.qs --shots=1024\nq[2]: +1|00>\n +1 | 00\n +0 | 01\n +0 | 10\n +0 | 11\nc[2]: {'11': 550, '00': 474}\n```\nMore examples such as the quantum phase estimation algorithm can be found in the\n[examples/qsyasm](examples/qsyasm) folder.\n\n### Syntax\nThe structure of a qsyASM program consists of a list of instructions. An\ninstruction is defined as an operation followed by its arguments.\n\n#### Operations\nThe instruction\n```asm\ncx q[0], q[1]\n```\napplies a CNOT operation with control qubit `q[0]` and target qubit `q[1]`.\nSome operations take an angle (in radians) as argument. The parameterized operation\n```asm\nrz(pi/2) q[0]\n```\nrotates `q[0]` \u03c0/2 radians around the Z axis. Expressions are allowed in\nparameterized operations. Expression operators supported are `+`, `-`, `*`, `/`\nand `**` (power). The variable `pi` is available for convenience.\n\n##### Adjoint Operation\nTo apply the adjoint of a gate, the `adj` keyword is available. For example, to\napply the adjoint of S (S dagger):\n```asm\nadj s q[0]\n```\n\n##### List of Operations\n| Gate | qsyASM operation |\n|----------|----------------------------------|\n| Pauli I | `i target` |\n| Pauli X | `x target` |\n| Pauli Y | `y target` |\n| Pauli Z | `z target` |\n| Hadamard | `h target` |\n| S | `s target` |\n| T | `t target` |\n| Rx | `rx(angle) target` |\n| Ry | `ry(angle) target` |\n| Rz | `rz(angle) target` |\n| CNOT | `cx control, target` |\n| CZ | `cz control, target` |\n| CRx | `crx(angle) control, target` |\n| CRy | `cry(angle) control, target` |\n| CRz | `crz(angle) control, target` |\n| Toffoli | `ccx controlA, controlB, target` |\n\n#### Registers\nDefining a quantum register is done with the `qreg` operation. The instruction\n```asm\nqreg[5] q\n```\ndefines a 5 qubit quantum register named `q`. Likewise, a classical register (useful for measuring) can be defined as\n```asm\ncreg[5] c\n```\nQubits in a quantum register are initiated to |0\u27e9, and bits in a classical register to 0.\n\n#### Measurement\nMeasurement can be done on individual qubits, or a complete quantum state. The program\n```asm\nqreg[5] q\ncreg[1] c\n\nh q[0]\n\nmeas q[0], c[0]\n```\nmeasures `q[0]` to `c[0]`, collapsing the state and storing the result in `c[0]`. The measurement result can be ignored by only passing one argument to `meas`:\n```asm\nmeas q[0]\n```\n\nTo measure a complete quantum state you can pass the whole quantum and classical register:\n```asm\nqreg[3] q\ncreg[3] c\n\n; 3 qubit GHZ state\nh q[0]\ncx q[0], q[1]\ncx q[0], q[2]\n\nmeas q, c\n```\ncollapsing the quantum register `q` and storing the measurement result in `c`. This only works when the quantum register and classical register are equal in size.\n\n### Efficient simulation of stabilizer circuits\nCircuits consisting only of CNOT, H, S, X, Y, Z and CZ gates can be efficiently\nsimulated with the CHP back-end. Using any other operations with the CHP\nback-end will result in an error.\n\nFor example, we can simulate a partially entangled 750 qubit state:\n```\n$ qsyasm examples/qsyasm/750_qubits.qs --backend=chp\nc[750]: 000000000000000000000000000000000000000000000000001111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n```\n\nThis back-end is an implementation of the CHP simulator described by\nScott Aaronson and Daniel Gottesman in their paper \"Improved Simulation of Stabilizer Circuits\"\n([arXiv:quant-ph/0406196](https://arxiv.org/abs/quant-ph/0406196)).\n\n## License\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file\nfor the full license.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "https://github.com/soudy/qsy/archive/v0.4.4.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/soudy/qsy", "keywords": "quantum,computing,simulator,stabilizer,circuit,assembly,chp,statevector", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "qsy", "package_url": "https://pypi.org/project/qsy/", "platform": "", "project_url": "https://pypi.org/project/qsy/", "project_urls": { "Download": "https://github.com/soudy/qsy/archive/v0.4.4.tar.gz", "Homepage": "https://github.com/soudy/qsy" }, "release_url": "https://pypi.org/project/qsy/0.4.4/", "requires_dist": null, "requires_python": "", "summary": "A quantum computer state vector/stabilizer circuit simulator and assembly language", "version": "0.4.4" }, "last_serial": 5380845, "releases": { "0.2": [ { "comment_text": "", "digests": { "md5": "964995d9859c12dc73f892ef3e1bcc48", "sha256": "944d733451dd2ba6983964ef22756e111d9c44e4bcfa8676148f3811859b9de6" }, "downloads": -1, "filename": "qsy-0.2.tar.gz", "has_sig": false, "md5_digest": "964995d9859c12dc73f892ef3e1bcc48", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16905, "upload_time": "2019-05-05T10:56:07", "url": "https://files.pythonhosted.org/packages/06/bf/1d5bad494a4986ef00c6b6dfb2579ea8e39978cb09a3d692b7bd4f91dac4/qsy-0.2.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "f61ac7bed3fe710a244736f986a23c23", "sha256": "a3952939410b34eeac1450d8677b9e54cd9b9d8f057efa9d14887d7007e2c347" }, "downloads": -1, "filename": "qsy-0.4.tar.gz", "has_sig": false, "md5_digest": "f61ac7bed3fe710a244736f986a23c23", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17205, "upload_time": "2019-05-06T17:19:39", "url": "https://files.pythonhosted.org/packages/a8/f9/e3e798ad78788e313958bf17e79c29152f5ab09e799db565bb551ce6fbf4/qsy-0.4.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "724b88bbcc30008d8010f63c05c4a298", "sha256": "694c490d13cb86da6f571980c0681e48a60bf3e53479229432d4265f71598c6e" }, "downloads": -1, "filename": "qsy-0.4.1.tar.gz", "has_sig": false, "md5_digest": "724b88bbcc30008d8010f63c05c4a298", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17323, "upload_time": "2019-05-06T19:40:55", "url": "https://files.pythonhosted.org/packages/1f/2d/608d94aa61993b4b316c426f9b169beb31830b1ebfdd91082a2520d9c85b/qsy-0.4.1.tar.gz" } ], "0.4.2": [ { "comment_text": "", "digests": { "md5": "4808507bde6c1dbab931befadfd0c1f4", "sha256": "1eb30198191f031cac970d6525a121780d84b3a40901a8b933088068d89a6feb" }, "downloads": -1, "filename": "qsy-0.4.2.tar.gz", "has_sig": false, "md5_digest": "4808507bde6c1dbab931befadfd0c1f4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17593, "upload_time": "2019-05-14T18:55:41", "url": "https://files.pythonhosted.org/packages/60/45/875584191f71580e0daad35798eea9496ddf74ff0fdfd9175dd71e277edd/qsy-0.4.2.tar.gz" } ], "0.4.3": [ { "comment_text": "", "digests": { "md5": "1c4b136c5b567114f910bd79aadc933e", "sha256": "0e13aa0c8970bc8e63a885428f3d3e5627fd1c9db25d94307b206b618733dde6" }, "downloads": -1, "filename": "qsy-0.4.3.tar.gz", "has_sig": false, "md5_digest": "1c4b136c5b567114f910bd79aadc933e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17711, "upload_time": "2019-05-28T09:49:21", "url": "https://files.pythonhosted.org/packages/5a/f0/2afcbb680c52f6f4133124bfbd4be51c2f3db2d26cfe5ad32e12e452e56d/qsy-0.4.3.tar.gz" } ], "0.4.4": [ { "comment_text": "", "digests": { "md5": "4c4914ec071f3ca00f03fcb054ec5116", "sha256": "4b25b89f4a6913fe23adc5ca1049b40b0b24f2b64f92b77a3bc71a55b0b5aaea" }, "downloads": -1, "filename": "qsy-0.4.4.tar.gz", "has_sig": false, "md5_digest": "4c4914ec071f3ca00f03fcb054ec5116", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14882, "upload_time": "2019-06-10T12:02:40", "url": "https://files.pythonhosted.org/packages/f5/4f/b93fbc9aa9c819fc9739e804390a801dd9ed7c4ce61c00036daac65cd5ef/qsy-0.4.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4c4914ec071f3ca00f03fcb054ec5116", "sha256": "4b25b89f4a6913fe23adc5ca1049b40b0b24f2b64f92b77a3bc71a55b0b5aaea" }, "downloads": -1, "filename": "qsy-0.4.4.tar.gz", "has_sig": false, "md5_digest": "4c4914ec071f3ca00f03fcb054ec5116", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14882, "upload_time": "2019-06-10T12:02:40", "url": "https://files.pythonhosted.org/packages/f5/4f/b93fbc9aa9c819fc9739e804390a801dd9ed7c4ce61c00036daac65cd5ef/qsy-0.4.4.tar.gz" } ] }