{"id":20271655,"url":"https://github.com/ymd-h/diffqc","last_synced_at":"2025-04-11T04:29:47.385Z","repository":{"id":65316001,"uuid":"585082331","full_name":"ymd-h/diffqc","owner":"ymd-h","description":"Differentiable Quantum Circuit Simulator for Quantum Machine Learning","archived":false,"fork":false,"pushed_at":"2023-01-24T22:41:35.000Z","size":167,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-07T17:48:58.955Z","etag":null,"topics":["machine-learning","python","quantum-computing"],"latest_commit_sha":null,"homepage":"https://ymd-h.github.io/diffqc/","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/ymd-h.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":"2023-01-04T09:19:00.000Z","updated_at":"2024-02-08T02:37:24.000Z","dependencies_parsed_at":"2023-02-12T14:15:14.820Z","dependency_job_id":null,"html_url":"https://github.com/ymd-h/diffqc","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymd-h%2Fdiffqc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymd-h%2Fdiffqc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymd-h%2Fdiffqc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymd-h%2Fdiffqc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ymd-h","download_url":"https://codeload.github.com/ymd-h/diffqc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224622812,"owners_count":17342462,"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","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":["machine-learning","python","quantum-computing"],"created_at":"2024-11-14T12:39:01.016Z","updated_at":"2024-11-14T12:39:01.597Z","avatar_url":"https://github.com/ymd-h.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# diffqc: Differentiable Quantum Circuit Simulator for Quantum Machine Learning\n\n![](https://img.shields.io/pypi/v/diffqc)\n![](https://img.shields.io/pypi/l/diffqc)\n\n## 1. Overview\n\u003e **Note**  \n\u003e This project started as diffq, but because of accidental name conflict,\n\u003e we changed name to diffqc.\n\ndiffqc is a python package providing differentiable quantum circuit simulator.\nThe main target is quantum machine learning.\n\ndiffqc is built on [JAX](https://jax.readthedocs.io/en/latest/), so\nthat it is\n* GPU friendly,\n* easily vectorized,\n* differentiable, but\n* supported environments are limited. (Ref.\n[\"Installation\" section at JAX README](https://github.com/google/jax#installation))\n\n## 2. Features\ndiffqc provides 2 types of operations, `dense` and `sparse`. Both have\nsame operations and only internal representations are different.\n\n### 2.1 `dense` operation\nIn `dense` operation, complex coefficients of all possible\n`2**nqubits` states are traced. This is simple matrix calculation but\nrequires exponentially large memory when `nqubits` is large.\n\n### 2.2 `sparse` operation\n\n\u003e **Warning**  \n\u003e `sparse` module is under depelopment, and is not ready to use.\n\nIn `sparse` operation, only neccessary states are traced. This might\nreduce memory requirements at large `nqubits` system, but it can be\ncomputationally inefficient.\n\n### 2.3 Builtin Algorithm `lib`\nBuiltin algorithms are implemented at `diffqc.lib`. To support both\n`dense` and `sparse` operation, operation module is passed to 1st\nargument.\n\n\n* `GHZ(op, c: jnp.ndarray, wires: Tuple[int])`\n  * Create Greenberger-Horne-Zeilinger state [2]\n  * `|00...0\u003e` -\u003e `(|00...0\u003e + |11...1\u003e)/sqrt(2)`\n* `QFT(op, c: jnp.ndarray, wires: Tuple[int])`\n  * Quantum Fourier Transform (without last swap) [3]\n* `QPE(op, c: jnp.ndarray, wires: Tuple[int], U: jnp.ndarray, aux: Tuple[int])`\n  * Quantum Phase Estimation [4]\n  * `wires`: Eigen Vector\n  * `U`: Unitary Matrix\n  * `aux`: Auxiliary qubits. These should be `|00...0\u003e`.\n\n\n### 2.4 PennyLane Plugin\n\n\u003e **Warning**  \n\u003e PennyLane plugin is planned, but is still under development, and is not ready yet.\n\n[PennyLane](https://pennylane.ai/) is a quantum machine learning\nframework. By using PennyLane, we can choose machine learning\nframework (e.g. [TensorFlow](https://www.tensorflow.org/),\n[PyTorch](https://pytorch.org/)) and real/simulation quantum device\nindependently, and can switch relatively easy.\n\n## 3. Example Usage\n- example/00-circuit-basics.py\n  - Basic Usage of diffqc\n- example/01-qcl-flax.py\n  - QCL[1] Classification of [Iris](https://scikit-learn.org/stable/datasets/toy_dataset.html#iris-dataset) with [Flax](https://flax.readthedocs.io/en/latest/index.html)\n- example/02-cnn-like-qcl-flax.py\n  - CNN-like QCL[1] Classification of [Digits](https://scikit-learn.org/stable/datasets/toy_dataset.html#digits-dataset) with [Flax](https://flax.readthedocs.io/en/latest/index.html)\n- example/03-pennylane.py\n  - PennyLane Plugin\n- example/04-builtin-variational-circuit-centric.py\n  - Builtin Variational Circuit: Circuit Centric Block described at [5]\n  - According to [6], this is one of the best circuit.\n- example/05-builtin-variational-josephson-sampler.py\n  - Builtin Variational Circuit: Josephson Sampler described at [7]\n  - According to [6], this is one of the best circuit.\n\n## 4. References\n- JAX\n  - [Official Site](https://jax.readthedocs.io/en/latest/)\n  - [Repository at GitHub](https://github.com/google/jax)\n- PennyLane\n  - [Official Site](https://pennylane.ai/)\n  - [Repository at GitHub](https://github.com/PennyLaneAI/pennylane)\n- TensorFlow\n  - [Official Site](https://www.tensorflow.org/)\n  - [Repository at GitHub](https://github.com/tensorflow/tensorflow)\n- PyTorch\n  - [Official Site](https://pytorch.org/)\n  - [Repository at GitHub](https://github.com/pytorch/pytorch)\n- Flax\n  - [Official Site](https://flax.readthedocs.io/en/latest/index.html)\n  - [Repository at GitHub](https://github.com/google/flax)\n- [1] K. Mitarai et al. \"Quantum Circuit Learning\", Phys. Rev. A 98, 032309 (2018)\n  - DOI: https://doi.org/10.1103/PhysRevA.98.032309\n  - arXiv: https://arxiv.org/abs/1803.00745\n- [2] D. M. Greenberger et al., \"Going Beyond Bell's Theorem\", arXiv:0712.0921\n  - arXiv: https://arxiv.org/abs/0712.0921\n- [3] D. Coppersmith, \"An approximate Fourier transform useful in quantum factoring\",\n  IBM Research Report RC19642\n  - arXiv: https://arxiv.org/abs/quant-ph/0201067\n- [4] A. Kitaev, \"Quantum measurements and the Abelian Stabilizer Problem\",\n  arXiv:quant-ph/9511026\n  - arXiv: https://arxiv.org/abs/quant-ph/9511026\n- [5] M. Schuld et al., \"Circuit-centric quantum classifiers\",\n  Phys. Rev. A 101, 032308 (2020)\n  - DOI: https://doi.org/10.1103/PhysRevA.101.032308\n  - arXiv: https://arxiv.org/abs/1804.00633\n- [6] S. Sim et al., \"Expressibility and entangling capability of\n  parameterized quantum circuits for hybrid quantum-classical algorithms\",\n  Adv. Quantum Technol. 2 (2019) 1900070\n  - DOI: https://doi.org/10.1002/qute.201900070\n  - arXiv: https://arxiv.org/abs/1905.10876\n- [7] M. R. Geller, \"Sampling and scrambling on a chain of superconducting qubits\",\n  Phys. Rev. Applied 10, 024052 (2018)\n  - DOI: https://doi.org/10.1103/PhysRevApplied.10.024052\n  - arXiv: https://arxiv.org/abs/1711.11026\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fymd-h%2Fdiffqc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fymd-h%2Fdiffqc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fymd-h%2Fdiffqc/lists"}