Skip to main content

M3: Matrix-free measurement mitigation

Project description

mthree

License PyPI version pypi workflow

Matrix-free Measurement Mitigation (M3).

M3 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).

Documentation

Online Documentation @ Qiskit.org

Installation

You can pip install M3 in using PyPi via:

pip install mthree

This will install an OpenMP optimized version on Linux, and serial versions for OSX and Windows. Alternatively, one can install from source:

pip install .

To enable openmp one must have an openmp 4.0+ enabled compiler and install with:

MTHREE_OPENMP=1 pip install .

OpenMP on OSX

On OSX one must install GCC using homebrew:

brew install gcc

Then installation with openmp can be accomplished using a call like:

MTHREE_OPENMP=1 CC=gcc-14 CXX=g++14 python setup.py install

Note that previously the instructions said to install LLVM and NOT GCC. However, in the latest version of OSX (Sequoia) LLVM based installations will build, but segfault upon execution. GCC however works fine, thus the change above.

Usage

Basic usage

M3 is simple to use:

import mthree
# Specify a mitigator object targeting a given backend
mit = mthree.M3Mitigation(backend)

# Compute the 1Q calibration matrices for the given qubits and given number of shots
# By default it is over all backend qubits at 10000 shots.
mit.cals_from_system(qubits, shots)

# Apply mitigation to a given dict of raw counts over the specified qubits
m3_quasi = mit.apply_correction(raw_counts, qubits)

Note that here qubits is a list of which qubits are measured to yield the bits in the output. For example the list [4,3,1,2,0] indicates that a measurement on physical qubit 4 was written to classical bit zero in the output bit-strings, physical qubit 3 maps to classical bit 1, etc. The fact that the zeroth bit is right-most in the bitstring is handled internally.

Error bounds

It is possible to compute error bounds in a similarly efficient manner. This is not done by default, but rather turned on using:

m3_quasi = mit.apply_correction(raw_counts, qubits, return_mitigation_overhead=True)

Then the distribution itself can be called to return things like the expectation value and the standard deviation:

expval, stddev = quasi.expval_and_stddev()

Closest probability distribution

The results of M3 mitigation are quasi-probabilities that nominally contain small negative values. This is suitable for use in computing corrected expectation values or sampling problems where one is interested in the highest probability bit-string. However, if one needs a true probability distribution then it is possible to convert from quasi-probabilites to the closest true probability distribution in L2-norm using:

closest_probs = m3_quasi.nearest_probability_distribution()

License

License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mthree-2.8.0.tar.gz (1.1 MB view details)

Uploaded Source

Built Distributions

mthree-2.8.0-cp312-cp312-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.12 Windows x86-64

mthree-2.8.0-cp312-cp312-win32.whl (1.6 MB view details)

Uploaded CPython 3.12 Windows x86

mthree-2.8.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

mthree-2.8.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl (4.7 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ i686

mthree-2.8.0-cp312-cp312-macosx_12_0_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.12 macOS 12.0+ x86-64

mthree-2.8.0-cp312-cp312-macosx_12_0_universal2.whl (2.2 MB view details)

Uploaded CPython 3.12 macOS 12.0+ universal2 (ARM64, x86-64)

mthree-2.8.0-cp311-cp311-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.11 Windows x86-64

mthree-2.8.0-cp311-cp311-win32.whl (1.6 MB view details)

Uploaded CPython 3.11 Windows x86

mthree-2.8.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

mthree-2.8.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl (4.7 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686

mthree-2.8.0-cp311-cp311-macosx_12_0_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.11 macOS 12.0+ x86-64

mthree-2.8.0-cp311-cp311-macosx_12_0_universal2.whl (2.2 MB view details)

Uploaded CPython 3.11 macOS 12.0+ universal2 (ARM64, x86-64)

mthree-2.8.0-cp310-cp310-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.10 Windows x86-64

mthree-2.8.0-cp310-cp310-win32.whl (1.6 MB view details)

Uploaded CPython 3.10 Windows x86

mthree-2.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

mthree-2.8.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl (4.5 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686

mthree-2.8.0-cp310-cp310-macosx_12_0_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.10 macOS 12.0+ x86-64

mthree-2.8.0-cp310-cp310-macosx_12_0_universal2.whl (2.2 MB view details)

Uploaded CPython 3.10 macOS 12.0+ universal2 (ARM64, x86-64)

mthree-2.8.0-cp39-cp39-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.9 Windows x86-64

mthree-2.8.0-cp39-cp39-win32.whl (1.6 MB view details)

Uploaded CPython 3.9 Windows x86

mthree-2.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

mthree-2.8.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl (4.5 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686

mthree-2.8.0-cp39-cp39-macosx_12_0_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.9 macOS 12.0+ x86-64

mthree-2.8.0-cp39-cp39-macosx_12_0_universal2.whl (2.2 MB view details)

Uploaded CPython 3.9 macOS 12.0+ universal2 (ARM64, x86-64)

File details

Details for the file mthree-2.8.0.tar.gz.

File metadata

  • Download URL: mthree-2.8.0.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for mthree-2.8.0.tar.gz
Algorithm Hash digest
SHA256 bd8c426253b0b6acd1788a73c42f59192301e5b06cbd00e01c3ab59b9e95cbf1
MD5 7eb62bf387c64eac14f20756f1d4fd1b
BLAKE2b-256 ba30f8b27aa79954310f2f1116ea855c2b7dfdcd02d2c78c9238edc97362961f

See more details on using hashes here.

File details

Details for the file mthree-2.8.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: mthree-2.8.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for mthree-2.8.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 81d1e5d4a5e80a0344239b95f7d4a163db081ad114919200c83055375602cfdd
MD5 602a038e2e0c72d9b036be3f0bd7abc7
BLAKE2b-256 c3dffa4020eec4689d6266aae2c0702584fdc222fa67b131861dd2c6251ec876

See more details on using hashes here.

File details

Details for the file mthree-2.8.0-cp312-cp312-win32.whl.

File metadata

  • Download URL: mthree-2.8.0-cp312-cp312-win32.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.12, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for mthree-2.8.0-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 c3e353784602e5d190b75f5de280ad224d354db8e5bb755a2d7db21f4ecc2d17
MD5 8f71f000dd6f6de6a28789973352e158
BLAKE2b-256 a9272d51115f4ba37fbd18d37480affa150ef93d06b6fc637fcaee3d48db940c

See more details on using hashes here.

File details

Details for the file mthree-2.8.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mthree-2.8.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d7753b5e248a8d6a0c8572f64be8cf6a857e4b52ae3b012150855656e1f4a730
MD5 1ebab5d9192017f464fdcc5c60e6d204
BLAKE2b-256 99d89ff1c3a31ac2d9eb4497e60c76a3ee31e3d5144d6eb5d5a20c886c158178

See more details on using hashes here.

File details

Details for the file mthree-2.8.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for mthree-2.8.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 1c7af5a54a9802078aa769f2310f176271d7cb7064f98d994edfb6615d2e6024
MD5 624c81b782c25a4ea89def19ce311dcc
BLAKE2b-256 1b97c427328e2cc27ed51cbdfe050b1826bd81a787ba4c1d523dd2f15d212842

See more details on using hashes here.

File details

Details for the file mthree-2.8.0-cp312-cp312-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for mthree-2.8.0-cp312-cp312-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 9e4773f9fe5597b8df0c82797bb70c282dfe492e333a2175462b0713e1440d2d
MD5 6ae496d85c35f7eac514cff5bbce73ef
BLAKE2b-256 d058f6d2c8a7b5303951ef9d53df94a591951ef0a1cba31e87f574958f6c83b4

See more details on using hashes here.

File details

Details for the file mthree-2.8.0-cp312-cp312-macosx_12_0_universal2.whl.

File metadata

File hashes

Hashes for mthree-2.8.0-cp312-cp312-macosx_12_0_universal2.whl
Algorithm Hash digest
SHA256 07c0183e675b23ba82818b1e1b56b85392de1fec9100e8159dd82adc43541455
MD5 69ff3919bd78094eb9d472eaee7e6b87
BLAKE2b-256 23f493e5b6c542a062ccd785fed9763b28e2e595c90eb7e5488eeb10a3478df2

See more details on using hashes here.

File details

Details for the file mthree-2.8.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: mthree-2.8.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for mthree-2.8.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 076c273d0e257f5be6b04e9031d56b1815ca8b592c55272a39741acf149e8ed6
MD5 05c7b2287ae6027cd7f251a10b2b6590
BLAKE2b-256 1149723799fc90b5eb1958c5de52984252dfa518488158c87310ac01af54eb79

See more details on using hashes here.

File details

Details for the file mthree-2.8.0-cp311-cp311-win32.whl.

File metadata

  • Download URL: mthree-2.8.0-cp311-cp311-win32.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.11, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for mthree-2.8.0-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 8abb5d5bae52e640229fffdea725f5f13f258572804bb03b1e328ebc1b5b5143
MD5 6f00041d2820bbe295a1f5cc7dae8fd6
BLAKE2b-256 32688546842b0dd766a0c6ec249bfb9ec1a3229f19af34106ca8588a4a1cf50d

See more details on using hashes here.

File details

Details for the file mthree-2.8.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mthree-2.8.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2d653c8e2c29b475c01416f16d900754f39f244dea7507154712a7d9c3758fe9
MD5 53a2f40e109be05055ab497c3b3a7fc2
BLAKE2b-256 d9094ec41518bc200bcbad966eb73e191396aceb0be833062f92770db0d01182

See more details on using hashes here.

File details

Details for the file mthree-2.8.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for mthree-2.8.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 ef9a8257f793f376b37a6a967964968969b4017497406482b4692681568679b3
MD5 acaf4b35b780c27843dc18b05be054bf
BLAKE2b-256 209d61c813b6a36fb226aa7ece03783de4ca5ff93b9921fa98762584eb910670

See more details on using hashes here.

File details

Details for the file mthree-2.8.0-cp311-cp311-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for mthree-2.8.0-cp311-cp311-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 9efca2c9db559b6ebe1ae71b78a827fa35136c7e4eafdf2e1006055a72dd2ff4
MD5 867a9e823720ddd00ac9c8d96918da27
BLAKE2b-256 71bf989a820eb87e602c6c8f33159b1024e0cf8ae570e74123cff9e5c02ac1f0

See more details on using hashes here.

File details

Details for the file mthree-2.8.0-cp311-cp311-macosx_12_0_universal2.whl.

File metadata

File hashes

Hashes for mthree-2.8.0-cp311-cp311-macosx_12_0_universal2.whl
Algorithm Hash digest
SHA256 d5f87346f2592fea191e2934b628d3e9117245c66aa891292c4fe3520d291418
MD5 d98895065e11ad7dbd9ee34c0f9ce74a
BLAKE2b-256 430b4024b7beb5bca30123edfc154b24362a67f5aa547ffbe0976e50e126e73a

See more details on using hashes here.

File details

Details for the file mthree-2.8.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: mthree-2.8.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for mthree-2.8.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 1860224f71320d0994801e0545c832bfa9cca54064e1057b7659b4d84004c680
MD5 8debfe50581a71c3c57962a7fdafbfd6
BLAKE2b-256 93c1759f047f0a61f462c11828ec35452e27c96b5c3fcbd6a170596d953df825

See more details on using hashes here.

File details

Details for the file mthree-2.8.0-cp310-cp310-win32.whl.

File metadata

  • Download URL: mthree-2.8.0-cp310-cp310-win32.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.10, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for mthree-2.8.0-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 8c84a823948a4e1d43d54ce64d7e21a6ea02518ae107f3f4f71e93ff211715e9
MD5 6362ba3f220bb80ecad5886b3c4368ea
BLAKE2b-256 c842557f614c6bac1eb733f179289441f4a2a95ac6ad7275426a6610a626cf36

See more details on using hashes here.

File details

Details for the file mthree-2.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mthree-2.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e81e0d4f7601dfabe15074f72de3b32157d7bb4faa4aa06a3728e1b583bf5b00
MD5 b69b8d6fd82eb787b82e77f4504932de
BLAKE2b-256 6b72510a8b5c71e1a1ef25b8d979604450439d18bd467ebc59a86ace71f84a99

See more details on using hashes here.

File details

Details for the file mthree-2.8.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for mthree-2.8.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 9a7eda25c540c3c6d2a4d3cbca65f85744342c17163a6f69878804c8e534259b
MD5 3970b8131541165415f1a3e95ff65b35
BLAKE2b-256 7d2a0399cae87ca236d8589de7b32d2729731181115402bc6a807c719eeb7fb1

See more details on using hashes here.

File details

Details for the file mthree-2.8.0-cp310-cp310-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for mthree-2.8.0-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 583d8c5564eb15fa026b14d827435aa36044c66176ebf0788f2e4599aea8f75c
MD5 524ac54816d271347250dc23d7059123
BLAKE2b-256 54a3119ed341665310e89effb5607cae0237c90b5b80257f687be577addf5fa5

See more details on using hashes here.

File details

Details for the file mthree-2.8.0-cp310-cp310-macosx_12_0_universal2.whl.

File metadata

File hashes

Hashes for mthree-2.8.0-cp310-cp310-macosx_12_0_universal2.whl
Algorithm Hash digest
SHA256 816d6c86eb1b6b910292cb90cf6aca8c29606d56bad6d6589d38f5d1ff16e09f
MD5 bd2c720106d17f71aefbd97f9d9d09b5
BLAKE2b-256 aa72d7030ed93539165df8a1da7e35fe22aa35136fa85c04e0f329f19f98daf3

See more details on using hashes here.

File details

Details for the file mthree-2.8.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: mthree-2.8.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for mthree-2.8.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 0b16e15a0ff2907bd0f5b6c825c854c1a8dffb323a663705bc366b4685115998
MD5 df51cd7a7cb878ca332896de31246e50
BLAKE2b-256 911a0a3eb040ef3041fe4fbae1502684a718627f211c101b2a47cd76760a3ff7

See more details on using hashes here.

File details

Details for the file mthree-2.8.0-cp39-cp39-win32.whl.

File metadata

  • Download URL: mthree-2.8.0-cp39-cp39-win32.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for mthree-2.8.0-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 817500018cbd15030e7b4f11121f3ac2960bf2f3de93990f1d3952422dcd9650
MD5 21c551a71b72c20501fa657fb27483ba
BLAKE2b-256 1d1dc0c9ae46658d28be23a92903a183801713bc7c2ca7335d57ee6686233b54

See more details on using hashes here.

File details

Details for the file mthree-2.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mthree-2.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 70e7c172387889d82a8824f407464a14b5707f8fb5f9d651f29cca082f28c85d
MD5 ad92bdec3e2d1ef61e8e5965f84ab74e
BLAKE2b-256 6edaf5c50dd8d5e8c0ac10cf230709b3c3df8810cce8c879fa0dd08eb607c82d

See more details on using hashes here.

File details

Details for the file mthree-2.8.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for mthree-2.8.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 320450f40a7f2008279d3966e4b4d1770edbbd95956874b4ed3c96bec356edc6
MD5 e2e92e1a102d77e37696e5db255de527
BLAKE2b-256 14f0898a87210cf060f0a0ab33f3ee7b2645779e20a510126c6863c5edbb8f71

See more details on using hashes here.

File details

Details for the file mthree-2.8.0-cp39-cp39-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for mthree-2.8.0-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 b99701b943ff7dc5a1d7ad747ee73ec23adfacc21bd6cd7a982ec0c78dddf45e
MD5 997c819a47922bf0f46660aa97426deb
BLAKE2b-256 fa2990ba565f33f6dc3f65668816d33964883b11046f331b702a2325131e90d5

See more details on using hashes here.

File details

Details for the file mthree-2.8.0-cp39-cp39-macosx_12_0_universal2.whl.

File metadata

File hashes

Hashes for mthree-2.8.0-cp39-cp39-macosx_12_0_universal2.whl
Algorithm Hash digest
SHA256 d25e909c496d517367e37a449334d8158b5055d8c6cfce4be9bd74141c7055ca
MD5 625062195bf8a50c1ba9a065c18af7b8
BLAKE2b-256 1644bd06b381b47c044ccfc250379759f67d9e39e0f1edf54230e81c9351c455

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page