Qiskit-Extensions / qiskit-experiments

Qiskit Experiments
https://qiskit-extensions.github.io/qiskit-experiments/
Apache License 2.0
152 stars 123 forks source link

ParallelExperiment of QV Experiments Transpilation Issue #845

Closed albertzhu01 closed 4 months ago

albertzhu01 commented 2 years ago

Informations

What is the current behavior?

Running a ParallelExperiment of QV Experiments on a device backend results in the following error:

QiskitError                               Traceback (most recent call last)
Input In [7], in <cell line: 32>()
     30 # Run QV experiments in parallel
     31 parallel_QV_exp = ParallelExperiment(QV_exps)
---> 32 parallel_QV_data = parallel_QV_exp.run(backend).block_for_results()

File ~/qiskit-experiments/qiskit_experiments/framework/base_experiment.py:265, in BaseExperiment.run(self, backend, analysis, timeout, **run_options)
    262 experiment._finalize()
    264 # Generate and transpile circuits
--> 265 transpiled_circuits = experiment._transpiled_circuits()
    267 # Initialize result container
    268 experiment_data = experiment._initialize_experiment_data()

File ~/qiskit-experiments/qiskit_experiments/framework/composite/parallel_experiment.py:78, in ParallelExperiment._transpiled_circuits(self)
     77 def _transpiled_circuits(self):
---> 78     return self._combined_circuits(device_layout=True)

File ~/qiskit-experiments/qiskit_experiments/framework/composite/parallel_experiment.py:154, in ParallelExperiment._combined_circuits(self, device_layout)
    152         if inst.name == "delay":
    153             continue
--> 154         raise QiskitError(
    155             "Component experiment has been transpiled outside of the "
    156             "allowed physical qubits for that component. Check the "
    157             "experiment is valid on the backends coupling map."
    158         ) from ex
    159     circuit._append(inst, mapped_qargs, mapped_cargs)
    161 # Add subcircuit metadata

QiskitError: 'Component experiment has been transpiled outside of the allowed physical qubits for that component. Check the experiment is valid on the backends coupling map.'

Steps to reproduce the problem

from qiskit_experiments.framework import ParallelExperiment
from qiskit_experiments.library import QuantumVolume
import qiskit

qiskit.IBMQ.load_account()
provider = qiskit.IBMQ.get_provider(hub="ibm-q-internal", group="deployed", project="default")
backend = provider.get_backend('ibm_hanoi')

# Initialize seed and groups of qubits to run QV on
seed = 123
qubits_list = [
    [0, 1, 2, 3], [4, 6, 7, 10], [5, 8, 9, 11], [12, 13, 14, 15, 16], [17, 18, 21, 23, 24], [19, 20, 22, 25, 26]
]

# Create QV experiments
QV_exps = [
    QuantumVolume(
        qubits, 
        seed=seed
    )
    for qubits in qubits_list
]

# Set transpile options
transpile_options = {"basis_gates": backend.configuration().basis_gates, "optimization_level": 3}
for QV_exp in QV_exps:
    QV_exp.set_transpile_options(**transpile_options)
    QV_exp.set_experiment_options(trials=100)

# Run QV experiments in parallel
parallel_QV_exp = ParallelExperiment(QV_exps)
parallel_QV_data = parallel_QV_exp.run(backend).block_for_results()

What is the expected behavior?

A job should be created and run successfully. A ParallelExperiment of Mirror RB experiments on the same groups of qubits and the same device backend does not produce this error and runs successfully.

Suggested solutions

albertzhu01 commented 2 years ago

The error is triggered when the instruction is a barrier, and it looks like a QV experiment places a barrier on all qubits of the device (not just the ones in the sub experiment) when it measures the qubits in the sub experiment. This seems like it has to do with how the qubits are measured

coruscating commented 4 months ago

@mtreinish said the larger barriers have been fixed in Qiskit 1.0 and a test confirms this. I think https://github.com/Qiskit/qiskit/issues/8910 can be closed as well.