Skip to main content

FiQCI EMS

FiQCI Error Mitigation Service (EMS) is a Python library for quantum error mitigation as part of the Finnish Quantum Computing Infrastructure (FiQCI). It wraps IQM quantum backends and applies error mitigation transparently, allowing users to run circuits with improved accuracy by specifying a mitigation level.

This python package can be pre-installed on a HPC system or installed by the user. The main goal of the project is to allow users using FiQCI quantum computers to easily add flags to run error mitigated quantum jobs.

Mitigation Levels

Sampler
Level Mitigation Applied Technique
0 None Raw results
1 Readout Error Mitigation M3 (matrix-free measurement mitigation)
2 Level 1 + Dynamical Decoupling Dynamical Decoupling
3 Level 2 + Pauli Twirling Pauli Twirling
Estimator
Level Mitigation Applied Technique
0 None Raw results
1 Readout Error Mitigation M3 (matrix-free measurement mitigation)
2 Level 1 + Dynamical Decoupling Dynamical Decoupling
3 Level 2 + Zero Noise Extrapolation Exponential Extrapolation, Local Folding

The default is level 1, which applies M3 readout error mitigation.

Installation

UV is recommended for installation

uv pip install fiqci-ems
#or
uv add fiqci-ems

Requires Python 3.11 or 3.12.

The example notebooks also need matplotlib, which Qiskit ships only as an optional extra:

uv pip install matplotlib
#or
uv add matplotlib

Usage

Start by initialising your IQM backend and a quantum circuit.

from iqm.qiskit_iqm import IQMProvider
from qiskit import QuantumCircuit, transpile

# Initialise backend
provider = IQMProvider()
backend = provider.get_backend()

# Define a quantum circuit
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()

# Transpile the circuit
qc_transpiled = transpile(qc, backend=backend, initial_layout=qubit_indices)

EMS provides three interfaces depending on your use case.

FiQCISampler - sampling interface

For users who need measurement counts with built-in mitigation:

from fiqci.ems import FiQCISampler

# Using mitigation_level
sampler = FiQCISampler(backend, mitigation_level=1)

# Execute the job
job = sampler.run(qc_transpiled, shots=2048)

# Get results
result = job.result()

# Or manually set mitigation options
sampler.rem(enabled=True, calibration_shots=2000, calibration_file="cals.json")

# See applied and available options
sampler.mitigation_options

FiQCIEstimator - expectation values

Computes expectation values of Pauli observables directly from circuits:

from fiqci.ems import FiQCIEstimator
from iqm.qiskit_iqm import transpile_to_IQM
from qiskit.quantum_info import SparsePauliOp

# Using mitigation_level
estimator = FiQCIEstimator(backend, mitigation_level=1)

# Transpile for the backend. remove_final_rzs=False is required: the estimator measures in the X and
# Y bases, and dropping the final RZ gates changes those expectation values.
tr_qc = transpile_to_IQM(qc, backend, remove_final_rzs=False, optimization_level=3)

# Define observables
observables = SparsePauliOp.from_list([("ZZ", 1), ("IX", 1)])

# Map observables to transpiled layout
device_observables = observables.apply_layout(tr_qc.layout)

# Execute the job
job_collection = estimator.run(tr_qc, observables=device_observables, shots=2048)

# Get expectation values
evs = job_collection.expectation_values()

# Access all jobs executed by estimator
jobs = job_collection.jobs()

# Or manually set mitigation options
estimator.rem(enabled=True, calibration_shots=2000, calibration_file="cals.json")

# See applied and available options
estimator.mitigation_options

FiQCIBackend - drop-in backend replacement

FiQCIBackend is used under the hood by both sampler and estimator. Wraps any IQM backend and applies error mitigation to run() calls:

from fiqci.ems import FiQCIBackend

# Using mitigation_level
backend = FiQCIBackend(backend, mitigation_level=1)

# Execute the job
job = backend.run(circuit, shots=1024)

# Get the results
result = job.result()

# Or manually set mitigation options
backend.rem(enabled=True, calibration_shots=2000, calibration_file="cals.json")

# See applied and available options
backend.mitigation_options

Access raw (pre-mitigation) counts via backend.raw_counts (populated only after the run's result() has been retrieved, since post-processing is computed lazily).

run() returns a lazy job handle immediately without waiting for results. The per-batch job_id()s and an aggregated status()/done() are available right away; error mitigation and result combination are computed on the first result() call. The handle also exposes job_ids() and partial_results() (per-batch results for batches that have already completed), and result() raises BatchFailedError identifying the failing batch if any batch fails.

If the backend rejects a circuit during submission, run() does not throw: it logs a warning, stops submitting, and returns a handle covering every batch. Submitted batches keep their job ids and status, the rejected batch reports ERROR, and skipped batches report CANCELLED (with a None job id). Inspect the outcome via statuses()/status()/partial_results().

Advanced Usage

It is also possible to manually configure and directly use the M3 mitigator without the wrapper classes above. Consult the docs for how this is done.

Configuration

All three interfaces accept the same core options:

Parameter Default Description
mitigation_level 1 Mitigation level (0-3)
calibration_shots 1000 Shots used for M3 calibration circuits
calibration_file None Path to save/load calibration data (JSON)

Mitigation can also be configured directly. See the docs for FiQCISampler, FiQCIEstimator, and FiQCIBackend to see all available options.

Documentation

Full documentation including API reference, guides, and Jupyter notebook examples is available at docs

Development

# Install with dev dependencies
uv sync

# Run tests
uv run pytest

# Run tests with coverage
uv run pytest --cov

# Lint and format
uv run ruff check --fix
uv run ruff format

# Type check
uv run pyrefly check

Building docs

#Install docs dependencies
uv sync --group docs

#Build docs
uv run sphinx-build docs/ docs/_build

License

Apache 2.0, see LICENSE for details.

Having trouble?

Contact servicedesk@csc.fi or raise an issue here.

Metadata

Release files for fiqci-ems 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fiqci-ems 1.1.0
File Size Uploaded Provenance Actions
fiqci_ems-1.1.0.tar.gz 484.4 kB Without provenance Details for fiqci_ems-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fiqci-ems 1.1.0
File Interpreter ABI Platform Actions
fiqci_ems-1.1.0-py3-none-any.whl Python 3 none any Details for fiqci_ems-1.1.0-py3-none-any.whl

Total release size: 545.5 kB

Release files / fiqci_ems-1.1.0.tar.gz

Download URL fiqci_ems-1.1.0.tar.gz
Size 484.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ed87b078172fec7ef8aca3b999f8cde55ad12fe126b82233b4a9d854d1eafa0d
BLAKE2b-256 checksum
How to use checksums
23b3f3084350735344b28b771aec98de41dbd509a44efacd0b67e9e8941379cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / fiqci_ems-1.1.0-py3-none-any.whl

Download URL fiqci_ems-1.1.0-py3-none-any.whl
Size 61.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
76f73ac9329e2abb9f4b259a834687b8da4981a47574cea352d19f9a90d4a187
BLAKE2b-256 checksum
How to use checksums
c2380542e1820e04152366718c809dbd331a762890449dcdd18f6f37d5b0558c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Security for fiqci-ems 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page