Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Provider should raise early if circuit uses faulty qubits or gates #568

Closed
kdk opened this issue Apr 5, 2023 · 1 comment · Fixed by #571
Closed

Provider should raise early if circuit uses faulty qubits or gates #568

kdk opened this issue Apr 5, 2023 · 1 comment · Fixed by #571
Labels
type: enhancement Existing functionality improvement

Comments

@kdk
Copy link
Member

kdk commented Apr 5, 2023

What is the expected enhancement?

Currently, if a user submits a circuit which uses gates or qubits which are marked as faulty, they will get an opaque IBMJobFailureError from the backend compilation service.

It should be possible, when backends have faulty qubits or gates, to scan submitted circuits and raise early if there is an instruction on a faulty gate or qubit. This can help users avoid waiting in the queue for jobs which cannot run successfully, and gives an opportunity to inform the user to either use different physical qubits, or re-transpile their circuit with a different seed or settings .

@blakejohnson
Copy link

Code snippet that may be a good starting point for validating input circuits (hat tip to @mtreinish):

def check_circuit(tqc: QuantumCircuit, backend):
    faulty_qubits = backend.properties().faulty_qubits()
    faulty_gates = backend.properties().faulty_gates()
    faulty_edges = [tuple(gate.qubits) for gate in faulty_gates if len(gate.qubits) > 1]

    for inst in tqc.data:
        if inst.operation.name == 'barrier':
            continue
        qubit_indices = tuple(tqc.find_bit(x).index for x in inst.qubits)
        if any(x in faulty_qubits for x in qubit_indices):
            raise Exception(f"Circuit contains instruction {inst} operating on a faulty qubit") # perhaps tell the user which one?
        if len(qubit_indices) == 2 and qubit_indices in faulty_edges:
            raise Exception(f"Circuit contains instruction {instr} operating on a faulty edge {qubit_indices}")

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: enhancement Existing functionality improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants