Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service creates ECR instructions that are incompatible with IBM Strasbourg #73

Closed
pandasa123 opened this issue Sep 17, 2024 · 4 comments · Fixed by #74
Closed

Service creates ECR instructions that are incompatible with IBM Strasbourg #73

pandasa123 opened this issue Sep 17, 2024 · 4 comments · Fixed by #74
Assignees
Labels
bug Something isn't working

Comments

@pandasa123
Copy link

pandasa123 commented Sep 17, 2024

Description

While testing IBM Circuit Function, we noticed a few jobs would fail. Upon further investigation, this was isolated to the Transpiler Service adding instructions labelled ecr_[int].

Expected behaviour

The circuit should transpile with native basis gates applicable to IBM Strasbourg. While this system does have ecr gates, it should not have the _[int] suffix

Reproducible code example

Thanks to @mberna for creating this example

from qiskit.circuit import QuantumCircuit
from qiskit import transpile
from qiskit_ibm_transpiler.transpiler_service import TranspilerService
from qiskit_ibm_runtime import QiskitRuntimeService
 
num_qubits = 16
circuit = QuantumCircuit(num_qubits)
for i in range(num_qubits-1):
    circuit.ecr(i,i+1)

runtime_service = QiskitRuntimeService(channel="ibm_quantum")
backend = runtime_service.backend("ibm_strasbourg")

isa_circuit = transpile(circuit, backend)
cloud_transpiler_service = TranspilerService(
    backend_name="ibm_strasbourg",
    ai="false",
    optimization_level=3,
)
transpiled_circuit = cloud_transpiler_service.run(circuit)
print([data.name for data in transpiled_circuit.data])
@cbjuan
Copy link
Member

cbjuan commented Sep 17, 2024

As commented privately, this error doesn't come out from the Qiskit transpiler service, but from main Qiskit.

We observe the same behaviors when running

from qiskit.circuit import QuantumCircuit
from qiskit import qasm2, transpile
from qiskit_ibm_runtime import QiskitRuntimeService
 
num_qubits = 16
circuit = QuantumCircuit(num_qubits)
for i in range(num_qubits-1):
    circuit.ecr(i,i+1)

runtime_service = QiskitRuntimeService(channel="ibm_quantum")
backend = runtime_service.backend("ibm_sherbrooke")

def transpile_qasm(qc):
    qc = qasm2.loads(qasm2.dumps(qc), custom_instructions=qasm2.LEGACY_CUSTOM_INSTRUCTIONS)
    tqc = transpile(qc, backend=backend, optimization_level=3, seed_transpiler=123)
    tqc = qasm2.loads(qasm2.dumps(tqc), custom_instructions=qasm2.LEGACY_CUSTOM_INSTRUCTIONS)
    return tqc

transpiled_circuit = transpile_qasm(circuit)
print({data.name for data in transpiled_circuit.data})

@jyu00
Copy link

jyu00 commented Sep 19, 2024

@cbjuan Why does the transpiler service needs to convert the circuit to QASM2? What about circuits that contain control flows (which is not supported by QASM2)?

@cbjuan
Copy link
Member

cbjuan commented Sep 19, 2024

The service currently support QASM2 and 3 (not only v 2). We're starting to work on supporting QPY too. Yet, even if we support QPY we will continue supporting QASM2/3 since there are some users who don't have a way to use QPY.

@jyu00
Copy link

jyu00 commented Sep 19, 2024

ok that's good to know. Once QPY is available that can be used as the default instead of QASM2, given QASM2 is the oldest and least supported format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants