{"id":13776809,"url":"https://github.com/ken-nakanishi/qupy","last_synced_at":"2025-10-21T19:42:23.531Z","repository":{"id":57459562,"uuid":"145424832","full_name":"ken-nakanishi/qupy","owner":"ken-nakanishi","description":"QuPy: Quantum circuit simulator for both CPU and GPU","archived":false,"fork":false,"pushed_at":"2019-05-21T05:53:22.000Z","size":76,"stargazers_count":43,"open_issues_count":2,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-24T23:44:15.187Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ken-nakanishi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-20T13:57:37.000Z","updated_at":"2025-03-31T15:43:07.000Z","dependencies_parsed_at":"2022-09-13T16:02:47.027Z","dependency_job_id":null,"html_url":"https://github.com/ken-nakanishi/qupy","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/ken-nakanishi/qupy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ken-nakanishi%2Fqupy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ken-nakanishi%2Fqupy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ken-nakanishi%2Fqupy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ken-nakanishi%2Fqupy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ken-nakanishi","download_url":"https://codeload.github.com/ken-nakanishi/qupy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ken-nakanishi%2Fqupy/sbom","scorecard":{"id":554849,"data":{"date":"2025-08-11","repo":{"name":"github.com/ken-nakanishi/qupy","commit":"313dce1258dafa497e4585240acbd726318f7439"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/16 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 20 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-20T12:02:49.589Z","repository_id":57459562,"created_at":"2025-08-20T12:02:49.589Z","updated_at":"2025-08-20T12:02:49.589Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280325269,"owners_count":26311417,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T18:00:33.393Z","updated_at":"2025-10-21T19:42:23.493Z","avatar_url":"https://github.com/ken-nakanishi.png","language":"Python","funding_links":[],"categories":["Quantum simulators"],"sub_categories":[],"readme":"# QuPy\n\n[![Build Status](https://travis-ci.org/ken-nakanishi/qupy.svg?branch=master)](https://travis-ci.org/ken-nakanishi/qupy)\n[![Downloads](https://pepy.tech/badge/qupy)](https://pepy.tech/project/qupy)\n[![Downloads](https://pepy.tech/badge/qupy/month)](https://pepy.tech/project/qupy/month)\n[![Downloads](https://pepy.tech/badge/qupy/week)](https://pepy.tech/project/qupy/week)\n\nQuPy is a quantum circuit simulator for both CPU and GPU.\n\nThe features of QuPy are as follows.\n- **fast**: You can experiment with your idea quickly!\n- **simple**: You can experiment with your idea easily!\n\nQuPy supports both Python 3 and Python 2.\n\nQuPy uses [CuPy](https://cupy.chainer.org/) to support GPU.\n\n## Install\n\n```bash\npip install qupy\n```\nor\n```bash\npip3 install qupy\n```\nor\n```bash\nconda install conda-forge::qupy\n```\n\n## GPU\nIf you use a GPU, install `cupy` and set the following environment variables.\n\n- QUPY_DTYPE\n    - Data type of the data array.\n    - `complex64` or `complex128` or `complex256`\n    - If you does not set QUPY_DTYPE, Data type is set `complex128`.\n- QUPY_GPU\n    - GPU machine number (integer).\n    - Set QUPY_GPU if you use GPU.\n    - If you don't set QUPY_GPU or you set QUPY_GPU=-1, your program will be running on the CPU.\n\nRead the [CuPy documentation](https://docs-cupy.chainer.org/en/stable/) for using CuPy.\n\n## Documents\nhttps://qupy.readthedocs.io/en/latest/qupy.html\n\n## Development\nYour contribution is welcome!\n\n## Example\n\n```python\n\u003e\u003e\u003e import numpy as np\n\u003e\u003e\u003e from qupy import Qubits\n\u003e\u003e\u003e from qupy.operator import H, X, rz, swap\n\n\u003e\u003e\u003e q = Qubits(3)\n\u003e\u003e\u003e print(q.get_state())\n[1.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j]\n\n\u003e\u003e\u003e q.gate(H, target=0)\n\u003e\u003e\u003e q.gate(H, target=1)\n\u003e\u003e\u003e print(q.get_state())\n[0.5+0.j 0. +0.j 0.5+0.j 0. +0.j 0.5+0.j 0. +0.j 0.5+0.j 0. +0.j]\n\n\u003e\u003e\u003e q.set_state('011')\n\u003e\u003e\u003e print(q.get_state())\n[0.+0.j 0.+0.j 0.+0.j 1.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j]\n\n\u003e\u003e\u003e q.gate(X, target=2)\n\u003e\u003e\u003e print(q.get_state())\n[0.+0.j 0.+0.j 1.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j]\n\n\u003e\u003e\u003e q.set_state([0, 1, 0, 0, 0, 0, 0, 0])\n\u003e\u003e\u003e print(q.get_state())\n[0.+0.j 1.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j]\n\n\u003e\u003e\u003e q.gate(X, target=2)\n\u003e\u003e\u003e print(q.get_state())\n[1.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j]\n\n\u003e\u003e\u003e q.gate(H, target=0)\n\u003e\u003e\u003e q.gate(H, target=1)\n\u003e\u003e\u003e q.gate(X, target=2, control=(0, 1))\n\u003e\u003e\u003e q.gate(X, target=0, control=1, control_0=2)\n\u003e\u003e\u003e q.gate(swap, target=(0, 2))\n\u003e\u003e\u003e q.gate(rz(np.pi / 8), target=2, control_0=1)\n\u003e\u003e\u003e print(q.get_state())\n[0.49039264-0.09754516j 0.49039264+0.09754516j 0.        +0.j\n 0.5       +0.j         0.        +0.j         0.        +0.j\n 0.        +0.j         0.5       +0.j        ]\n\n\u003e\u003e\u003e iswap = np.array([[1, 0, 0, 0],\n...                   [0, 0, 1j, 0],\n...                   [0, 1j, 0, 0],\n...                   [0, 0, 0, 1]])\n\n\u003e\u003e\u003e q.gate(iswap, target=(2, 1))\n\u003e\u003e\u003e print(q.get_state())\n[ 0.49039264-0.09754516j  0.        +0.j         -0.09754516+0.49039264j\n  0.5       +0.j          0.        +0.j          0.        +0.j\n  0.        +0.j          0.5       +0.j        ]\n\n\u003e\u003e\u003e res = q.project(target=0)\n\u003e\u003e\u003e print(res)\n0\n\u003e\u003e\u003e print(q.get_state())\n[ 0.56625665-0.11263545j  0.        +0.j         -0.11263545+0.56625665j\n  0.57735027+0.j          0.        +0.j          0.        +0.j\n  0.        +0.j          0.        +0.j        ]\n\n\u003e\u003e\u003e q.gate(H, target=1)\n\u003e\u003e\u003e q.gate(swap, target=(2, 0), control=1)\n\u003e\u003e\u003e print(q.get_state())\n[ 0.32075862+0.32075862j  0.40824829+0.j          0.4800492 -0.4800492j\n  0.        +0.j          0.        +0.j          0.        +0.j\n -0.40824829+0.j          0.        +0.j        ]\n\n\u003e\u003e\u003e res = q.project(target=1)\n\u003e\u003e\u003e print(res)\n1\n\u003e\u003e\u003e print(q.get_state())\n[ 0.        +0.j          0.        +0.j          0.60597922-0.60597922j\n  0.        +0.j          0.        +0.j          0.        +0.j\n -0.51534296+0.j          0.        +0.j        ]\n\n\u003e\u003e\u003e hamiltonian = {'XXI': 1, 'IIZ': -0.5}\n\u003e\u003e\u003e print(q.expect(hamiltonian))\n-0.4999999999999999\n\u003e\u003e\u003e hamiltonian = np.kron(np.kron(X, X), X)\n\u003e\u003e\u003e print(q.expect(hamiltonian))\n0.0\n```\n\n## Citation\n```\n@Misc{QuPy,\n  author = {Nakanishi, Ken M},\n  title = {{QuPy}: A quantum circuit simulator for both CPU and GPU},\n  year = {2018--},\n  url = \"https://github.com/ken-nakanishi/qupy\",\n  note = {[Online; accessed \u003ctoday\u003e]}\n}\n```\n\n## License\nMIT License (see LICENSE file).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fken-nakanishi%2Fqupy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fken-nakanishi%2Fqupy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fken-nakanishi%2Fqupy/lists"}