{"id":17614957,"url":"https://github.com/vprusso/qustop","last_synced_at":"2026-01-31T03:31:50.639Z","repository":{"id":146071551,"uuid":"348209691","full_name":"vprusso/qustop","owner":"vprusso","description":":stop_sign: QUSTOP : QUantum STate OPtimizer ","archived":false,"fork":false,"pushed_at":"2022-04-15T03:21:01.000Z","size":1058,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-12T03:49:32.969Z","etag":null,"topics":["quantum-computation","quantum-information","quantum-state-distinguishability","quantum-state-optimization"],"latest_commit_sha":null,"homepage":"https://qustop.readthedocs.io/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vprusso.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","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},"funding":{"github":["vprusso"],"custom":["https://www.paypal.me/vincentrusso1"]}},"created_at":"2021-03-16T04:09:31.000Z","updated_at":"2024-09-04T11:03:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"f28b1367-7542-4a7a-a8ac-9c322a6b09db","html_url":"https://github.com/vprusso/qustop","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/vprusso/qustop","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vprusso%2Fqustop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vprusso%2Fqustop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vprusso%2Fqustop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vprusso%2Fqustop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vprusso","download_url":"https://codeload.github.com/vprusso/qustop/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vprusso%2Fqustop/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28928148,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T02:59:34.861Z","status":"ssl_error","status_checked_at":"2026-01-31T02:59:05.369Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["quantum-computation","quantum-information","quantum-state-distinguishability","quantum-state-optimization"],"created_at":"2024-10-22T18:59:25.930Z","updated_at":"2026-01-31T03:31:50.625Z","avatar_url":"https://github.com/vprusso.png","language":"Python","funding_links":["https://github.com/sponsors/vprusso","https://www.paypal.me/vincentrusso1"],"categories":[],"sub_categories":[],"readme":"# ![logo](./docs/figures/logo.svg \"logo\") \n\n# QUSTOP\n\n[![build status](http://img.shields.io/travis/vprusso/toqito.svg?style=plastic)](https://travis-ci.org/vprusso/qustop)\n[![doc status](https://readthedocs.org/projects/toqito/badge/?version=latest\u0026style=plastic)](https://qustop.readthedocs.io/en/latest/)\n[![codecov](https://codecov.io/gh/vprusso/toqito/branch/main/graph/badge.svg?style=plastic)](https://codecov.io/gh/vprusso/qustop)\n\n*NOTE*: The `qustop` package is still is under development. \n\nThe `qustop` (QUantum STate OPtimizer) package is a Python toolkit for studying\nvarious quantum state optimization scenarios including calculating optimal\nvalues for quantum state distinguishability, quantum state exclusion, quantum\nstate cloning, and more.\n\n## Applications\n\nThe `qustop` package can be used to:\n\n- Calculate and approximate optimal probabilities of distinguishing quantum\n  states over positive, PPT, and separable measurements with either minimum-error\n  or unambiguously.\n\n- Calculate and approximate optimal probabilities of excluding quantum states\n  with either minimum-error or unambiguously.\n\n## Installation\n\nSee the [installation guide](https://qustop.readthedocs.io/en/latest/getting_started.html).\n\n## Usage\n\nSee the [documentation](https://qustop.readthedocs.io/en/latest/index.html).\n\n## Examples\n\nFor more examples, please consult\n[`qustop/examples`](https://github.com/vprusso/qustop/tree/main/examples/)\nas well as the `qustop` [introductory\ntutorial](https://qustop.readthedocs.io/en/latest/intro_tutorial.html).\n\n### Quantum state distinguishability\n\nFurther examples on quantum state distinguishability can be found in the\n[`qustop/examples/opt_dist`](https://github.com/vprusso/qustop/tree/main/examples/opt_dist)\ndirectory.\n\nConsider the following Bell states:\n\n![\\Large x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2c}](https://latex.codecogs.com/svg.latex?\\Large\u0026space;|\\psi_0\\rangle=\\frac{|00\\rangle+|11\\rangle}{\\sqrt{2}},\\quad|\\psi_1\\rangle=\\frac{|01\\rangle+|10\\rangle}{\\sqrt{2}},) \n\n![\\Large x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2c}](https://latex.codecogs.com/svg.latex?\\Large\u0026space;|\\psi_2\\rangle=\\frac{|01\\rangle-|10\\rangle}{\\sqrt{2}},\\quad|\\psi_3\\rangle=\\frac{|00\\rangle-|11\\rangle}{\\sqrt{2}}.) \n\nWe will be using these states to consider a number of applications in the realm\nof quantum state distinguishability.\n\n#### Distinguishing two orthogonal states\n\nA result of [arXiv:0007098](https://arxiv.org/abs/quant-ph/0007098) states that\nany two orthogonal pure states can be distinguished perfectly by LOCC\nmeasurements. As the optimal probability of distinguishing via LOCC\nmeasurements is a lower bound on positive, PPT, separable, etc., we should\nexpect to also see a value of `1` to indicate perfect probability of\ndistinguishing.\n\n```python\nfrom toqito.states import bell\nfrom qustop import State, Ensemble, OptDist\n\ndims = [2, 2]\nstates = [\n    State(bell(0) * bell(0).conj().T, dims),\n    State(bell(1) * bell(1).conj().T, dims)\n]\nprobs = [1/2, 1/2]\nensemble = Ensemble(states, probs)\n\nsep_res = OptDist(ensemble, \"sep\", \"min-error\")\nsep_res.solve()\n\nppt_res = OptDist(ensemble, \"ppt\", \"min-error\")\nppt_res.solve()\n\npos_res = OptDist(ensemble, \"pos\", \"min-error\")\npos_res.solve()\n```\n\nChecking the respective values of the solved instances, we see that all of the\nvalues are equal to one, which indicate that the two pure states are indeed\nperfectly distinguishable under PPT, separable, and positive measurements.\n\n```python\n\u003e\u003e\u003e print(pos_res.value)\n0.9999999999384911\n\u003e\u003e\u003e print(ppt_res.value)\n1.0000000047560667\n\u003e\u003e\u003e print(sep_res.value)\n0.9999999995278338\n```\n\n#### Four indistinguishable orthogonal maximally entangled states\n\nIt was shown in [arXiv:1205.1031](https://arxiv.org/abs/1205.1031) and later\nextended in [arXiv:1307.3232](https://arxiv.org/abs/1307.3232) that for the\nfollowing set of states\n\n![\\Large x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2c}](https://latex.codecogs.com/svg.latex?\\Large\u0026space;\\rho_0=|\\psi_0\\rangle|\\psi_0\\rangle\\langle\\psi_0|\\langle\\psi_0|,\\quad\\rho_1=|\\psi_1\\rangle|\\psi_3\\rangle\\langle\\psi_1|\\langle\\psi_3|,) \n\n![\\Large x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2c}](https://latex.codecogs.com/svg.latex?\\Large\u0026space;\\rho_2=|\\psi_2\\rangle|\\psi_3\\rangle\\langle\\psi_2|\\langle\\psi_3|,\\quad\\rho_3=|\\psi_3\\rangle|\\psi_3\\rangle\\langle\\psi_3|\\langle\\psi_3|,) \n\nthat the optimal probability of distinguishing via a PPT measurement should\nyield an optimal probability of 7/8.\n\n```python\nimport numpy as np\n\nfrom toqito.states import bell\nfrom qustop import State, Ensemble, OptDist\n\ndims = [2, 2, 2, 2]\nrho_0 = np.kron(bell(0), bell(0)) * np.kron(bell(0), bell(0)).conj().T\nrho_1 = np.kron(bell(2), bell(1)) * np.kron(bell(2), bell(1)).conj().T\nrho_2 = np.kron(bell(3), bell(1)) * np.kron(bell(3), bell(1)).conj().T\nrho_3 = np.kron(bell(1), bell(1)) * np.kron(bell(1), bell(1)).conj().T\n\nensemble = Ensemble([\n    State(rho_0, dims), State(rho_1, dims),\n    State(rho_2, dims), State(rho_3, dims)\n])\n\nsd = OptDist(ensemble, \"ppt\", \"min-error\")\nsd.solve()\n```\n\nIndeed the optimal value obtained via `qustop` is equal to 7/8:\n\n```python\n# 7/8 \\approx 0.875\n\u003e\u003e\u003e print(sd.value)\n0.8749769201568257\n```\n\nIt was also shown in [arXiv:1205.1031](https://arxiv.org/abs/1205.1031) that the optimal\nprobability of distinguishing amongst these same state unambiguously via PPT measurements was\nequal to 3/4.\n\n```python\nsd = OptDist(ensemble, \"ppt\", \"unambiguous\")\nsd.solve()\n\n# 3/4 = 0.75\n\u003e\u003e\u003e print(sd.value)\n0.749999999939434\n```\n\n#### Entanglement cost of distinguishing Bell states\n\nOne may ask whether the ability to distinguish a state can be improved by\nmaking use of an auxiliary resource state.\n\n![\\Large x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2c}](https://latex.codecogs.com/svg.latex?\\Large\u0026space;|\\tau_{\\epsilon}\\rangle=\\sqrt{\\frac{1+\\epsilon}{2}}|00\\rangle+\\sqrt{\\frac{1-\\epsilon}{2}}|11\\rangle),\n\nfor some \u0026epsilon; in [0, 1].\n\nIt was shown in [arXiv:1408.6981](https://arxiv.org/abs/1408.6981) that the\nprobability of distinguishing four Bell states with a resource state via PPT\nmeasurements or separable measurements is given by the closed-form expression\n\n![\\Large x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2c}](https://latex.codecogs.com/svg.latex?\\Large\u0026space;\\text{opt}_{\\text{PPT}}(\\eta)=\\text{opt}_{\\text{SEP}}(\\eta)=\\frac{1}{2}\\left(1+\\sqrt{1-\\epsilon^2}\\right)) \n\nwhere the ensemble is defined as\n\n![\\Large x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2c}](https://latex.codecogs.com/svg.latex?\\Large\u0026space;\\eta=\\left\\(|\\psi_0\\rangle\\otimes|\\tau_{\\epsilon}\\rangle,\\quad|\\psi_1\\rangle\\otimes|\\tau_{\\epsilon}\\rangle,\\quad|\\psi_2\\rangle\\otimes|\\tau_{\\epsilon}\\rangle,\\quad|\\psi_3\\rangle\\otimes|\\tau_{\\epsilon}\\rangle\\right\\))\n\n\nUsing `qustop`, we may encode this scenario as follows.\n\n```python\nimport numpy as np\n\nfrom toqito.states import basis, bell\nfrom qustop import State, Ensemble, OptDist\n\n\ne_0, e_1 = basis(2, 0), basis(2, 1)\n\neps = 0.5\ntau = np.sqrt((1 + eps) / 2) * np.kron(e_0, e_0) + np.sqrt((1 - eps) / 2) * np.kron(e_1, e_1)\n\ndims = [2, 2, 2, 2]\nstates = [\n    State(np.kron(bell(0), tau), dims),\n    State(np.kron(bell(1), tau), dims),\n    State(np.kron(bell(2), tau), dims),\n    State(np.kron(bell(3), tau), dims),\n]\nprobs = [1 / 4, 1 / 4, 1 / 4, 1 / 4]\nensemble = Ensemble(states, probs)\n\nsep_res = OptDist(ensemble, \"sep\", \"min-error\")\nsep_res.solve()\n\nppt_res = OptDist(ensemble, \"ppt\", \"min-error\")\nppt_res.solve()\n\neq = 1 / 2 * (1 + np.sqrt(1 - eps ** 2))\n```\n\nNote that when we print out the optimal values for both separable and PPT\nmeasurements that the values obtained agree with the closed form expression.\n\n```python\n\u003e\u003e\u003e print(eq)\n0.9330127018922193\n\u003e\u003e\u003e print(ppt_res.value)\n0.933010488554166\n\u003e\u003e\u003e print(sep_res.value)\n0.9330124607534689\n```\n\nIt was also shown in [arXiv:1408.6981](https://arxiv.org/abs/1408.6981) that\nthe closed-form probability of distinguishing three Bell states with a resource\nstate using separable measurements to be given by the closed-form expression:\n\n![\\Large x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2c}](https://latex.codecogs.com/svg.latex?\\Large\u0026space;\\text{opt}_{\\text{SEP}}(\\eta)=\\frac{1}{3}\\left(2+\\sqrt{1-\\epsilon^2}\\right)) \n\nwhere the ensemble is defined as\n\n![\\Large x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2c}](https://latex.codecogs.com/svg.latex?\\Large\u0026space;\\eta=\\left\\(|\\psi_0\\rangle\\otimes|\\tau_{\\epsilon}\\rangle,\\quad|\\psi_1\\rangle\\otimes|\\tau_{\\epsilon}\\rangle,\\quad|\\psi_2\\rangle\\otimes|\\tau_{\\epsilon}\\rangle\\right\\))\n\nUsing `qustop`, we may encode this scenario as follows.\n\n```python\nimport numpy as np\n\nfrom toqito.states import basis, bell\nfrom qustop import State, Ensemble, OptDist\n\n\ne_0, e_1 = basis(2, 0), basis(2, 1)\n\neps = 0.5\ntau = np.sqrt((1 + eps) / 2) * np.kron(e_0, e_0) + np.sqrt((1 - eps) / 2) * np.kron(e_1, e_1)\n\ndims = [2, 2, 2, 2]\nstates = [\n    State(np.kron(bell(0), tau), dims),\n    State(np.kron(bell(1), tau), dims),\n    State(np.kron(bell(2), tau), dims),\n]\nprobs = [1 / 3, 1 / 3, 1 / 3]\nensemble = Ensemble(states, probs)\n\nsep_res = OptDist(ensemble, \"sep\", \"min-error\", level=2)\nsep_res.solve()\n\neq = 1 / 3 * (2 + np.sqrt(1 - eps**2))\n```\n\nPritning the values of both the closed-form equation and the value obtained via\nthe SDP, we obtain:\n\n```python\n\u003e\u003e\u003e print(sep_res.value)\n0.9583057987150858\n\u003e\u003e\u003e print(eq)\n0.9553418012614794\n```\n\nNote that the value of `sep_res.value` is actually a bit higher than `eq`. This\nis because the separable value is calculated by a hierarchy of SDPs. At low\nlevels of the SDP, the problem can often converge to the optimal value, but\nother times it is necessary to compute higher levels of the SDP to eventually\narrive at the optimal value. While this is intractable in general, in practice,\nthe SDP can often converge or at least get fairly close to the optimal value\nfor small problem sizes.\n\n#### Werner hiding pairs\n\nIn [arXiv:0011042](https://arxiv.org/abs/quant-ph/0011042) and\n[arXiv:0103098](https://arxiv.org/abs/quant-ph/0103098) a quantum data hiding\nprotocol that encodes a classical bit in a Werner hiding pair was provided.\n\nA Werner hiding pair is defined as\n\n![\\Large x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2c}](https://latex.codecogs.com/svg.latex?\\Large\u0026space;\\sigma_0^n=\\frac{\\mathbb{I}\\otimes\\mathbb{I}+W_n}{n(n+1)}\\quad\\text{and}\\quad\\sigma_1^n=\\frac{\\mathbb{I}\\otimes\\mathbb{I}-W_n}{n(n-1)}) \n\nwhere \n\n![\\Large x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2c}](https://latex.codecogs.com/svg.latex?\\Large\u0026space;W_n=\\sum_{i,j=0}^{n-1}|i\\rangle\\langle\\text{}j|\\otimes|j\\rangle\\langle\\text{}i|\\in\\text{}U(\\mathbb{C}^n\\otimes\\mathbb{C}^n)) \n\nis the swap operator defined for some dimension n \u003e= 2.\n\nIt was show in [hdl:10012/9572](https://uwspace.uwaterloo.ca/handle/10012/9572) that \n\n![\\Large x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2c}](https://latex.codecogs.com/svg.latex?\\Large\u0026space;\\text{opt}_{\\text{PPT}}(\\eta)=\\frac{1}{2}+\\frac{1}{n+1}) \n\nwhere the ensemble is defined as\n\n![\\Large x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2c}](https://latex.codecogs.com/svg.latex?\\Large\u0026space;\\eta=\\(\\sigma_0,\\sigma_1\\).)\n\nUsing `qustop`, we may encode this scenario as follows.\n\n```python\nimport numpy as np\nfrom toqito.perms import swap_operator\nfrom qustop import Ensemble, State, OptDist\n\n\ndim = 2\nsigma_0 = (np.kron(np.identity(dim), np.identity(dim)) + swap_operator(dim)) / (dim * (dim + 1))\nsigma_1 = (np.kron(np.identity(dim), np.identity(dim)) - swap_operator(dim)) / (dim * (dim - 1))\n\nstates = [State(sigma_0, [2, 2]), State(sigma_1, [2, 2])]\nensemble = Ensemble(states)\n\nexpected_val = 1 / 2 + 1 / (dim + 1)\n\nsd = OptDist(ensemble=ensemble, \n             dist_measurement=\"ppt\",\n             dist_method=\"min-error\",\n             eps=1e-8)\n\nsd.solve()\n```\n\nWe can verify that the closed-form expression matches that of the value\nreturned from `qustop`.\n\n```python\nprint(sd.value)\n0.8333333333668715\nprint(expected_val)\n0.8333333333333333\n```\n\n### State exclusion\n\nThe primary difference between the quantum state distinguishability\nscenario and the quantum state exclusion scenario is that in the former,\nBob want to guess which state he was given, and in the latter, Bob wants to\nguess which state he was *not* given.\n\n\n\n### State cloning\n\n(Coming soon).\n\n## License\n\n[GNU GPL v.3.0.](https://github.com/vprusso/qustop/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvprusso%2Fqustop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvprusso%2Fqustop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvprusso%2Fqustop/lists"}