Skip to content

Commit

Permalink
Add log param to calibration guide (#2568)
Browse files Browse the repository at this point in the history
* Add log param to calibration guide

* Change from relative to absolute path

* Update log param description and links

* Update cross-reference

* Update run docstring with log param

* Remove meta data updates

* remove whitespace

* remove jupytext format
  • Loading branch information
bdg221 authored Nov 22, 2024
1 parent 0262bfc commit edeede6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
19 changes: 15 additions & 4 deletions docs/source/guide/calibrators.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ print(cal.get_cost())
cal.run()
```

## Verbose Log Output

To print results from the experiments the calibrator performs, the `log` parameter can be passed in to the `run` method with either the value of `flat` or `cartesian`. By using the `log` parameter, detailed information about each experiment is printed when the `run` method completes.

The detailed information can also be generated from the results of the calibrator after `run` is called by calling either {meth}`.log_results_flat` or {meth}`.log_results_cartesian`.

The two options display the information in different formats, though both use a cross (✘) or a check (✔) to signal whether the error mitigation expirement obtained an expectation value better than the non-mitigated one.

```{code-cell} ipython3
# cal.results.log_results_flat()
cal.results.log_results_cartesian()
```

## Applying the optimal error mitigation strategy

We first define randomized benchmarking circuit to test the effect of error mitigation.
Expand Down Expand Up @@ -86,12 +99,10 @@ def execute(circuit, noise_level=0.001):
cal.execute_with_mitigation(circuit, execute)
```

```{code-cell} ipython3
```

## Tutorial

You can find an example on quantum error mitigation calibration in the **[Examples](../examples/calibration-tutorial.md)** section of the documentation.
This example illustrates functionalities from the calibration module using ZNE
on a simulated IBM Quantum backend using Qiskit, defining a new settings object.

+++
8 changes: 7 additions & 1 deletion mitiq/calibration/calibrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,13 @@ def get_cost(self) -> Dict[str, int]:
}

def run(self, log: Optional[OutputForm] = None) -> None:
"""Runs all the circuits required for calibration."""
"""Runs all the circuits required for calibration.
args:
log: If set, detailed results of each experiment run by the
calibrator are printed. The value corresponds to the format of
the information and can be set to “flat” or “cartesian”.
"""
if not self.results.is_missing_data():
self.results.reset_data()

Expand Down

0 comments on commit edeede6

Please sign in to comment.