{"id":13743815,"url":"https://github.com/quantumlib/qsim","last_synced_at":"2025-05-14T09:06:24.190Z","repository":{"id":39580759,"uuid":"236547448","full_name":"quantumlib/qsim","owner":"quantumlib","description":"Schrödinger and Schrödinger-Feynman simulators for quantum circuits.","archived":false,"fork":false,"pushed_at":"2025-05-11T02:38:59.000Z","size":6193,"stargazers_count":546,"open_issues_count":68,"forks_count":172,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-05-14T09:04:08.766Z","etag":null,"topics":["algorithms","api","cirq","cpp","google-quantum","nisq","python","quantum","quantum-algorithms","quantum-circuit","quantum-circuit-simulator","quantum-computing","quantum-information","quantum-programming","quantum-simulation","quantum-simulator","schrodinger-equation","sdk","simulation"],"latest_commit_sha":null,"homepage":"https://quantumai.google/qsim","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quantumlib.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-27T17:19:36.000Z","updated_at":"2025-05-12T17:03:49.000Z","dependencies_parsed_at":"2023-11-17T20:02:26.433Z","dependency_job_id":"c72a2455-f8a0-4379-94b7-010806ec01b9","html_url":"https://github.com/quantumlib/qsim","commit_stats":{"total_commits":1053,"total_committers":42,"mean_commits":"25.071428571428573","dds":0.603988603988604,"last_synced_commit":"1a7cab45413c8e3f3e541847f0454d2054c0b979"},"previous_names":[],"tags_count":53,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantumlib%2Fqsim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantumlib%2Fqsim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantumlib%2Fqsim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantumlib%2Fqsim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quantumlib","download_url":"https://codeload.github.com/quantumlib/qsim/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254110374,"owners_count":22016391,"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":["algorithms","api","cirq","cpp","google-quantum","nisq","python","quantum","quantum-algorithms","quantum-circuit","quantum-circuit-simulator","quantum-computing","quantum-information","quantum-programming","quantum-simulation","quantum-simulator","schrodinger-equation","sdk","simulation"],"created_at":"2024-08-03T05:00:57.638Z","updated_at":"2025-05-14T09:06:24.169Z","avatar_url":"https://github.com/quantumlib.png","language":"C++","readme":"# qsim and qsimh\n\nQuantum circuit simulators qsim and qsimh. These simulators were used for cross\nentropy benchmarking in\n[[1]](https://www.nature.com/articles/s41586-019-1666-5).\n\n[[1]](https://www.nature.com/articles/s41586-019-1666-5), F. Arute et al,\n\"Quantum Supremacy Using a Programmable Superconducting Processor\",\nNature 574, 505, (2019).\n\n## qsim\n\nqsim is a Schrödinger full state-vector simulator. It computes all the *2\u003csup\u003en\u003c/sup\u003e*\namplitudes of the state vector, where *n* is the number of qubits.\nEssentially, the simulator performs matrix-vector multiplications repeatedly.\nOne matrix-vector multiplication corresponds to applying one gate.\nThe total runtime is proportional to *g2\u003csup\u003en\u003c/sup\u003e*, where *g* is the number of\n2-qubit gates. To speed up the simulator, we use gate fusion\n[[2]](https://arxiv.org/abs/1601.07195) [[3]](https://arxiv.org/abs/1704.01127),\nsingle precision arithmetic, AVX/FMA instructions for vectorization and OpenMP\nfor multi-threading.\n\n[[2]](https://arxiv.org/abs/1601.07195) M. Smelyanskiy, N. P. Sawaya,\nA. Aspuru-Guzik, \"qHiPSTER: The Quantum High Performance Software Testing\nEnvironment\", arXiv:1601.07195 (2016).\n\n[[3]](https://arxiv.org/abs/1704.01127) T. Häner, D. S. Steiger,\n\"0.5 Petabyte Simulation of a 45-Qubit Quantum Circuit\", arXiv:1704.01127\n(2017).\n\n## qsimh\n\nqsimh is a hybrid Schrödinger-Feynman simulator\n[[4]](https://arxiv.org/abs/1807.10749). The lattice is split into two parts\nand the Schmidt decomposition is used to decompose 2-qubit gates on the\ncut. If the Schmidt rank of each gate is *m* and the number of gates on\nthe cut is *k* then there are *m\u003csup\u003ek\u003c/sup\u003e* paths. To simulate a circuit with\nfidelity one, one needs to simulate all the *m\u003csup\u003ek\u003c/sup\u003e* paths and sum the results.\n  The total runtime is proportional to *(2\u003csup\u003en\u003csub\u003e1\u003c/sub\u003e\u003c/sup\u003e + 2\u003csup\u003en\u003csub\u003e2\u003c/sub\u003e\u003c/sup\u003e)m\u003csup\u003ek\u003c/sup\u003e*, where *n\u003csub\u003e1\u003c/sub\u003e*\nand *n\u003csub\u003e2\u003c/sub\u003e* are the qubit numbers in the first and second parts. Path\nsimulations are independent of each other and can be trivially parallelized\nto run on supercomputers or in data centers. Note that one can run simulations\nwith fidelity *F \u003c 1* just by summing over a fraction *F* of all the paths.\n\nA two level checkpointing scheme is used to improve performance. Say, there\nare *k* gates on the cut. We split those into three parts: *p+r+s=k*, where\n*p* is the number of \"prefix\" gates, *r* is the number of \"root\" gates and\n*s* is the number of \"suffix\" gates. The first checkpoint is executed after\napplying all the gates up to and including the prefix gates and the second\ncheckpoint is executed after applying all the gates up to and including the\nroot gates. The full summation over all the paths for the root and suffix gates\nis performed.\n\nIf *p\u003e0* then one such simulation gives *F \u0026#8776; m\u003csup\u003e-p\u003c/sup\u003e* (for all the\nprefix gates having the same Schmidt rank *m*). One needs to run *m\u003csup\u003ep\u003c/sup\u003e*\nsimulations with different prefix paths and sum the results to get *F = 1*.\n\n[[4]](https://arxiv.org/abs/1807.10749) I. L. Markov, A. Fatima, S. V. Isakov,\nS. Boixo, \"Quantum Supremacy Is Both Closer and Farther than It Appears\",\narXiv:1807.10749 (2018).\n\n## C++ Usage\n\nThe code is basically designed as a library. The user can modify sample\napplications in [apps](https://github.com/quantumlib/qsim/tree/master/apps)\nto meet their own needs. The usage of sample applications is described in the\n[docs](https://github.com/quantumlib/qsim/blob/master/docs/usage.md).\n\n### Input format\n\nThe circuit input format is described in the\n[docs](https://github.com/quantumlib/qsim/blob/master/docs/input_format.md).\n\nNOTE: This format is deprecated, and no longer actively maintained.\n\n### Sample Circuits\n\nA number of sample circuits are provided in\n[circuits](https://github.com/quantumlib/qsim/tree/master/circuits).\n\n### Unit tests\n\nUnit tests for C++ libraries use the Google test framework, and are\nlocated in [tests](https://github.com/quantumlib/qsim/tree/master/tests).\nPython tests use pytest, and are located in\n[qsimcirq_tests](https://github.com/quantumlib/qsim/tree/master/qsimcirq_tests).\n\nTo build and run all tests, run:\n```\nmake run-tests\n```\nThis will compile all test binaries to files with `.x` extensions, and run each\ntest in series. Testing will stop early if a test fails. It will also run tests\nof the `qsimcirq` python interface. To run C++ or python tests only, run\n`make run-cxx-tests` or `make run-py-tests`, respectively.\n\nTo clean up generated test files, run `make clean` from the test directory.\n\n## Cirq Usage\n\n[Cirq](https://github.com/quantumlib/cirq) is a framework for modeling and\ninvoking Noisy Intermediate Scale Quantum (NISQ) circuits.\n\nTo get started simulating Google Cirq circuits with qsim, see the\n[tutorial](https://github.com/quantumlib/qsim/blob/master/docs/tutorials/qsimcirq.ipynb).\n\nMore detailed information about the qsim-Cirq API can be found in the\n[docs](https://github.com/quantumlib/qsim/blob/master/docs/cirq_interface.md).\n\n## Disclaimer\n\nThis is not an officially supported Google product.\n\n# How to cite qsim\n\nQsim is uploaded to Zenodo automatically. Click on this badge [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4023103.svg)](https://doi.org/10.5281/zenodo.4023103) to see all the citation formats for all versions.\n\nAn equivalent BibTex format reference is below for all the versions:\n\n```\n@software{quantum_ai_team_and_collaborators_2020_4023103,\n  author       = {Quantum AI team and collaborators},\n  title        = {qsim},\n  month        = Sep,\n  year         = 2020,\n  publisher    = {Zenodo},\n  doi          = {10.5281/zenodo.4023103},\n  url          = {https://doi.org/10.5281/zenodo.4023103}\n}\n```\n","funding_links":[],"categories":["C++","Simulation Tools","Quantum simulators"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquantumlib%2Fqsim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquantumlib%2Fqsim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquantumlib%2Fqsim/lists"}