{"id":28552296,"url":"https://github.com/qiskit/qiskit-addon-mthree","last_synced_at":"2025-07-06T08:32:08.972Z","repository":{"id":37798957,"uuid":"396861869","full_name":"Qiskit/qiskit-addon-mthree","owner":"Qiskit","description":"Matrix-free Measurement Mitigation","archived":false,"fork":false,"pushed_at":"2025-03-27T22:41:59.000Z","size":6251,"stargazers_count":46,"open_issues_count":3,"forks_count":29,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-06-10T04:08:40.366Z","etag":null,"topics":["qiskit","qiskit-addon"],"latest_commit_sha":null,"homepage":"https://qiskit.github.io/qiskit-addon-mthree/","language":"Python","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/Qiskit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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,"zenodo":null}},"created_at":"2021-08-16T15:47:22.000Z","updated_at":"2025-06-08T05:43:07.000Z","dependencies_parsed_at":"2024-02-02T16:28:47.841Z","dependency_job_id":"92eb11a6-d327-46d9-857f-e8af9f68404c","html_url":"https://github.com/Qiskit/qiskit-addon-mthree","commit_stats":null,"previous_names":["qiskit-extensions/mthree","qiskit-partners/mthree","qiskit/qiskit-addon-mthree"],"tags_count":37,"template":false,"template_full_name":null,"purl":"pkg:github/Qiskit/qiskit-addon-mthree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qiskit%2Fqiskit-addon-mthree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qiskit%2Fqiskit-addon-mthree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qiskit%2Fqiskit-addon-mthree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qiskit%2Fqiskit-addon-mthree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Qiskit","download_url":"https://codeload.github.com/Qiskit/qiskit-addon-mthree/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qiskit%2Fqiskit-addon-mthree/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263870303,"owners_count":23522656,"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":["qiskit","qiskit-addon"],"created_at":"2025-06-10T04:08:37.072Z","updated_at":"2025-07-06T08:32:08.961Z","avatar_url":"https://github.com/Qiskit.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mthree\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0)\n[![PyPI version](https://badge.fury.io/py/mthree.svg)](https://badge.fury.io/py/mthree)\n[![pypi](https://img.shields.io/pypi/dm/mthree.svg)](https://pypi.org/project/mthree/)\n![workflow](https://github.com/Qiskit/qiskit-addon-mthree/actions/workflows/python-package-conda.yml/badge.svg)\n\nMatrix-free Measurement Mitigation (M3).\n\nM3 is a measurement mitigation technique that solves for corrected measurement probabilities using a dimensionality reduction step followed by either direct LU factorization or a preconditioned iterative method that nominally converges in O(1) steps, and can be computed in parallel. For example, M3 can compute corrections on 42 qubit GHZ problems in under two seconds on a quad-core machine (depending on the number of unique bitstrings in the output).\n\n## Documentation\n\n[Online Documentation](https://qiskit.github.io/qiskit-addon-mthree/)\n\n## Installation\n\nYou can `pip` install M3 in using PyPi via:\n\n```bash\npip install mthree\n```\n\nThis will install an OpenMP optimized version on Linux, and serial versions for OSX and Windows.  Alternatively, one can install from source:\n\n```bash\npip install .\n```\n\nTo enable openmp one must have an openmp 4.0+ enabled compiler and install with:\n\n```bash\nMTHREE_OPENMP=1 pip install .\n```\n\n### OpenMP on OSX\n\nOn OSX one must install GCC using homebrew:\n\n```bash\nbrew install gcc\n```\n\nThen installation with openmp can be accomplished using a call like:\n\n```bash\nMTHREE_OPENMP=1 CC=gcc-14 CXX=g++14 python setup.py install\n```\n\nNote that previously the instructions said to install LLVM and NOT GCC.  However,\nin the latest version of OSX (Sequoia) LLVM based installations will build, but segfault\nupon execution. GCC however works fine, thus the change above.\n\n\n## Usage\n\n### Basic usage\n\nM3 is simple to use:\n\n```python\nimport mthree\n# Specify a mitigator object targeting a given backend\nmit = mthree.M3Mitigation(backend)\n\n# Compute the 1Q calibration matrices for the given qubits and given number of shots\n# By default it is over all backend qubits at 10000 shots.\nmit.cals_from_system(qubits, shots)\n\n# Apply mitigation to a given dict of raw counts over the specified qubits\nm3_quasi = mit.apply_correction(raw_counts, qubits)\n```\n\nNote that here `qubits` is a list of which qubits are measured to yield the bits in the output.\nFor example the list `[4,3,1,2,0]` indicates that a measurement on physical qubit 4 was written to\nclassical bit zero in the output bit-strings, physical qubit 3 maps to classical bit 1, etc.\nThe fact that the zeroth bit is right-most in the bitstring is handled internally.\n\n### Error bounds\n\nIt is possible to compute error bounds in a similarly efficient manner.  This is not done\nby default, but rather turned on using:\n\n```python\nm3_quasi = mit.apply_correction(raw_counts, qubits, return_mitigation_overhead=True)\n```\n\nThen the distribution itself can be called to return things like the expectation value and the\nstandard deviation:\n\n```python\nexpval, stddev = quasi.expval_and_stddev()\n```\n\n### Closest probability distribution\n\nThe results of M3 mitigation are quasi-probabilities that nominally contain small negative values.\nThis is suitable for use in computing corrected expectation values or sampling problems\nwhere one is interested in the highest probability bit-string.  However, if one needs\na true probability distribution then it is possible to convert from quasi-probabilites to\nthe closest true probability distribution in L2-norm using:\n\n```python\nclosest_probs = m3_quasi.nearest_probability_distribution()\n```\n\n## License\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqiskit%2Fqiskit-addon-mthree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqiskit%2Fqiskit-addon-mthree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqiskit%2Fqiskit-addon-mthree/lists"}