qiskit-community / qiskit-metal

Quantum Hardware Design. Open-source project for engineers and scientists to design superconducting quantum devices with ease.
https://qiskit-community.github.io/qiskit-metal/
Apache License 2.0
270 stars 201 forks source link

Export Metal Calibrations for Noise Model #135

Open splch opened 3 years ago

splch commented 3 years ago

What is the feature being requested?

An option for exporting custom hardware calibrations from Qiskit Metal. This feature should mesh well with the existing Qiskit ecosystem, so I propose having a calibration .csv available for generation similar to quantum-computing.ibm.com's "Download Calibrations" button.

IMG_4952

What are use cases for this feature?

I believe this feature would be helpful to computer scientists involved in quantum computing. It would allow users to take advantage of the wide range of existing features offered by the Qiskit frameworks. For example, this calibration .csv could be easily used to create a Noise Model in Qiskit and visualize performance, run simulations, publish research, etc.

Screen Shot 2020-12-02 at 8 05 22 AM Code

splch commented 3 years ago

I don't have a background in physics, so I'm not sure if an approximate gate error/thermal relaxation can be derived from what Qiskit Metal offers.

But, I think it'd be helpful to at least offer to export the coupling_map.


from qiskit import QuantumCircuit, execute
from qiskit import Aer
from qiskit.visualization import plot_histogram

from qiskit.test.mock import FakeBackend
from qiskit.providers.models import BackendConfiguration

import qiskit.providers.aer.noise as noise
class MetalBackend(FakeBackend):
    def __init__(self, coupling_map):
        configuration = BackendConfiguration(
            backend_name='metal_backend',
            backend_version='0.0.0',
            n_qubits=len({q for p in coupling_map for q in p}),
            basis_gates=['u1', 'u2', 'u3', 'cx'],
            gates=[],
            local=True,
            simulator=True,
            conditional=False,
            open_pulse=False,
            memory=False,
            max_shots=8192,
            coupling_map=coupling_map,
        )

        super().__init__(configuration)

        prob_1 = 0.2    # 1-qubit gate
        prob_2 = 0.4    # 2-qubit gate
        noise_model = noise.NoiseModel()
        noise_model.add_all_qubit_quantum_error(noise.depolarizing_error(prob_1, 1), ['u1', 'u2', 'u3'])
        noise_model.add_all_qubit_quantum_error(noise.depolarizing_error(prob_2, 2), ['cx'])

        self.noise_model = noise_model
cmap = [[0, 1], [1, 0]]

metal_qc = MetalBackend(cmap)
# Make a circuit
circ = QuantumCircuit(2, 2)
circ.h(0)
circ.cx(0, 1)
circ.measure([0, 1], [0, 1])

circ.draw('mpl')

output_3_0

# Perform a noise simulation
result = execute(circ, Aer.get_backend('qasm_simulator'),
                coupling_map=metal_qc.configuration().coupling_map,
                basis_gates=metal_qc.configuration().basis_gates,
                noise_model=metal_qc.noise_model).result()
counts = result.get_counts()
plot_histogram(counts)

output_4_0

JeremyDrysdale-ibm commented 3 years ago

@ThomasGM4 Thoughts?