unitaryfund / mitiq

Mitiq is an open source toolkit for implementing error mitigation techniques on most current intermediate-scale quantum computers.
https://mitiq.readthedocs.io
GNU General Public License v3.0
363 stars 160 forks source link

Create `group_by_strategy` function for Calibrator #2012

Closed natestemen closed 11 months ago

natestemen commented 1 year ago

After running the calibration experiments and seeing the entire list of results, a user might want to know how each Strategy performed across all BenchmarkProblems

cal = Calibrator(executor, frontend="...")
cal.run()
cal.group_by_strategy()
>>> new table with one line per strategy

Function name subject to change.

kozhukalov commented 1 year ago

Please assign this to me

kozhukalov commented 1 year ago

@natestemen @andreamari There are couple more similar issues #2014 and #2013 regarding calibration logs. I would like to suggest something better than just adding error values and noise level. Anyway there could potentially many other benchmarks/strategies and maintaining this kind of code https://github.com/unitaryfund/mitiq/blob/master/mitiq/calibration/calibrator.py#L104-L149 is gonna be painful because we will have different sets of columns for strategies/benchmarks. And this group_by_strategy/group_by_problem is gonna make the calibration logging even less maintainable.

What if we have only these two kinds of tables?

The database like table

┌─────────────────────────┬────────────────────────────────────────────┬──────────────────────────────┐
│ performance             │ benchmark                                  │ strategy                     │
├─────────────────────────┼────────────────────────────────────────────┼──────────────────────────────┤
│ ✔                       │ Type: rb                                   │ Technique: ZNE               │
│ Noisy error: 0.1087     │ Ideal distribution: {'00': 1.0}            │ Factory: Richardson          │
│ Mitigated error: 0.0196 │ Num qubits: 2                              │ Scale factors: 1.0, 2.0, 3.0 │
│                         │ Circuit depth: 335                         │ Scale method: fold_global    │
│                         │ Two qubit gate count: 76                   │                              │
├─────────────────────────┼────────────────────────────────────────────┼──────────────────────────────┤
│ ✔                       │ Type: ghz                                  │ Technique: ZNE               │
│ Noisy error: 0.0102     │ Ideal distribution: {'00': 0.5, '11': 0.5} │ Factory: Richardson          │
│ Mitigated error: 0.0062 │ Num qubits: 2                              │ Scale factors: 1.0, 2.0, 3.0 │
│                         │ Circuit depth: 2                           │ Scale method: fold_global    │
│                         │ Two qubit gate count: 1                    │                              │
├─────────────────────────┼────────────────────────────────────────────┼──────────────────────────────┤
│ ✔                       │ Type: rb                                   │ Technique: ZNE               │
│ Noisy error: 0.1087     │ Ideal distribution: {'00': 1.0}            │ Factory: Richardson          │
│ Mitigated error: 0.0323 │ Num qubits: 2                              │ Scale factors: 1.0, 3.0, 5.0 │
│                         │ Circuit depth: 335                         │ Scale method: fold_global    │
│                         │ Two qubit gate count: 76                   │                              │
├─────────────────────────┼────────────────────────────────────────────┼──────────────────────────────┤
│ ✘                       │ Type: ghz                                  │ Technique: ZNE               │
│ Noisy error: 0.0102     │ Ideal distribution: {'00': 0.5, '11': 0.5} │ Factory: Richardson          │
│ Mitigated error: 0.013  │ Num qubits: 2                              │ Scale factors: 1.0, 3.0, 5.0 │
│                         │ Circuit depth: 2                           │ Scale method: fold_global    │
│                         │ Two qubit gate count: 1                    │                              │
└─────────────────────────┴────────────────────────────────────────────┴──────────────────────────────┘

and this is the group_by (cartesian product) version of the same table and it is easy to transpose it if necessary

┌───────────────────────────────────┬──────────────────────────────────────────────┬──────────────────────────────┐
│ Type: rb                          │ Type: ghz                                    │ benchmark/strategy           │
│ Ideal distribution: {'00': 1.0}   │ Ideal distribution: {'00': 0.5, '11': 0.5}   │                              │
│ Num qubits: 2                     │ Num qubits: 2                                │                              │
│ Circuit depth: 335                │ Circuit depth: 2                             │                              │
│ Two qubit gate count: 85          │ Two qubit gate count: 1                      │                              │
│                                   │                                              │                              │
├───────────────────────────────────┼──────────────────────────────────────────────┼──────────────────────────────┤
│ ✔                                 │ ✘                                            │ Technique: ZNE               │
│ Noisy error: 0.0951               │ Noisy error: 0.0073                          │ Factory: Richardson          │
│ Mitigated error: 0.027            │ Mitigated error: 0.0515                      │ Scale factors: 1.0, 2.0, 3.0 │
│                                   │                                              │ Scale method: fold_global    │
├───────────────────────────────────┼──────────────────────────────────────────────┼──────────────────────────────┤
│ ✔                                 │ ✘                                            │ Technique: ZNE               │
│ Noisy error: 0.0951               │ Noisy error: 0.0073                          │ Factory: Richardson          │
│ Mitigated error: 0.0287           │ Mitigated error: 0.0219                      │ Scale factors: 1.0, 3.0, 5.0 │
│                                   │                                              │ Scale method: fold_global    │
└───────────────────────────────────┴──────────────────────────────────────────────┴──────────────────────────────┘

Another benefit of using such kind of logging is that the code for the machine readable report will be almost the same (only rendering will be different)