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

Transpiler crashes on IBM Brisbane #88

Open
glanzz opened this issue Sep 22, 2024 · 8 comments
Open

Transpiler crashes on IBM Brisbane #88

glanzz opened this issue Sep 22, 2024 · 8 comments

Comments

@glanzz
Copy link

glanzz commented Sep 22, 2024

Running the following circuit fails on IBM Brisbane backend specifically when optimization level set to 2 or more.

Python Version: 3.11.9
Qiskit Version: 1.2.1
Qiskit IBM Transpiler Version: 0.7.0

from qiskit import QuantumCircuit
from qiskit_ibm_transpiler.transpiler_service import TranspilerService



qc = QuantumCircuit(6)
qc.h(0)
qc.x(1)
qc.x(4)
qc.swap(1,3)
qc.ecr(5,4)
qc.cx(4,1)
qc.ccx(5,2,0)
qc.ccz(2,5,0)
qc.sxdg(1)
qc.sx(1)
qc.ccz(2,5,0)
qc.ccx(5,2,0)
qc.cx(4,1)
qc.ecr(5,4)
qc.swap(1,3)
qc.h(0)
qc.measure_all()

print(qc)

for j in range(1,4):
    cloud_transpiler_service = TranspilerService(
        backend_name="ibm_brisbane",
        ai="false",
        optimization_level=j,
    )
    transpiled_circuit = cloud_transpiler_service.run(qc)
    print(f" Passed optimization level {j}")

Transpilation will be successful for optimization level 1 but fails for optimization level 2 or more with the following error:

        ┌───┐             ┌───┐                    ┌───┐┌───┐         ░ ┌─┐               
   q_0: ┤ H ├─────────────┤ X ├─■────────────────■─┤ X ├┤ H ├─────────░─┤M├───────────────
        ├───┤        ┌───┐└─┬─┘ │ ┌──────┐┌────┐ │ └─┬─┘├───┤         ░ └╥┘┌─┐            
   q_1: ┤ X ├───X────┤ X ├──┼───┼─┤ √Xdg ├┤ √X ├─┼───┼──┤ X ├───X─────░──╫─┤M├────────────
        └───┘   │    └─┬─┘  │   │ └──────┘└────┘ │   │  └─┬─┘   │     ░  ║ └╥┘┌─┐         
   q_2: ────────┼──────┼────■───■────────────────■───■────┼─────┼─────░──╫──╫─┤M├─────────
                │      │    │   │                │   │    │     │     ░  ║  ║ └╥┘┌─┐      
   q_3: ────────X──────┼────┼───┼────────────────┼───┼────┼─────X─────░──╫──╫──╫─┤M├──────
        ┌───┐┌──────┐  │    │   │                │   │    │  ┌──────┐ ░  ║  ║  ║ └╥┘┌─┐   
   q_4: ┤ X ├┤1     ├──■────┼───┼────────────────┼───┼────■──┤1     ├─░──╫──╫──╫──╫─┤M├───
        └───┘│  Ecr │       │   │                │   │       │  Ecr │ ░  ║  ║  ║  ║ └╥┘┌─┐
   q_5: ─────┤0     ├───────■───■────────────────■───■───────┤0     ├─░──╫──╫──╫──╫──╫─┤M├
             └──────┘                                        └──────┘ ░  ║  ║  ║  ║  ║ └╥┘
meas: 6/═════════════════════════════════════════════════════════════════╩══╩══╩══╩══╩══╩═
                                                                         0  1  2  3  4  5 
 Passed opt level 1

ERROR:qiskit_ibm_transpiler.wrappers.transpile:Error transforming the result to a QuantumCircuit object
Traceback (most recent call last):
  File "/Users/***/scripts/qiskit1.2.1/lib/python3.11/site-packages/qiskit_ibm_transpiler/utils.py", line 116, in get_circuit_from_qasm
    qasm2.loads(
  File "/Users/***/scripts/qiskit1.2.1/lib/python3.11/site-packages/qiskit/qasm2/__init__.py", line 587, in loads
    return _parse.from_bytecode(
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/***/scripts/qiskit1.2.1/lib/python3.11/site-packages/qiskit/qasm2/parse.py", line 214, in from_bytecode
    for op in bc:
qiskit.qasm2.exceptions.QASM2ParseError: "<input>:1,4396: 'rzx_140108262515216_140109994476304' is not defined in this scope"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/***/scripts/qiskit1.2.1/lib/python3.11/site-packages/qiskit/qasm3/__init__.py", line 342, in loads
    return qiskit_qasm3_import.parse(program)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/***/scripts/qiskit1.2.1/lib/python3.11/site-packages/qiskit_qasm3_import/api.py", line 27, in parse
    return convert(openqasm3.parse(string))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/***/scripts/qiskit1.2.1/lib/python3.11/site-packages/qiskit_qasm3_import/api.py", line 21, in convert
    return ConvertVisitor().convert(node).circuit
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/***/scripts/qiskit1.2.1/lib/python3.11/site-packages/qiskit_qasm3_import/converter.py", line 147, in convert
    state: State = self.visit(node, State(source))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/***/scripts/qiskit1.2.1/lib/python3.11/site-packages/openqasm3/visitor.py", line 44, in visit
    return visitor(node, context)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/***/scripts/qiskit1.2.1/lib/python3.11/site-packages/qiskit_qasm3_import/converter.py", line 288, in visit_Program
    context = self.visit(statement, context)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/***/scripts/qiskit1.2.1/lib/python3.11/site-packages/openqasm3/visitor.py", line 44, in visit
    return visitor(node, context)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/***/scripts/qiskit1.2.1/lib/python3.11/site-packages/qiskit_qasm3_import/converter.py", line 293, in visit_Include
    raise_from_node(node, "non-stdgates imports not currently supported")
  File "/Users/***/scripts/qiskit1.2.1/lib/python3.11/site-packages/qiskit_qasm3_import/exceptions.py", line 31, in raise_from_node
    raise ConversionError(message, node)
qiskit_qasm3_import.exceptions.ConversionError: 1,14: non-stdgates imports not currently supported

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/***/scripts/mycircuit.py", line 51, in <module>
    transpiled_circuit = cloud_transpiler_service.run(qc)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/***/scripts/qiskit1.2.1/lib/python3.11/site-packages/qiskit_ibm_transpiler/transpiler_service.py", line 111, in run
    transpile_result = self.transpiler_service.transpile(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/***/scripts/qiskit1.2.1/lib/python3.11/site-packages/qiskit_ibm_transpiler/wrappers/transpile.py", line 90, in transpile
    transpiled_circuits.append(_get_circuit_from_result(res, orig_circ))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/***/scripts/qiskit1.2.1/lib/python3.11/site-packages/qiskit_ibm_transpiler/wrappers/transpile.py", line 103, in _get_circuit_from_result
    transpiled_circuit = get_circuit_from_qasm(transpile_resp["qasm"])
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/***/scripts/qiskit1.2.1/lib/python3.11/site-packages/qiskit_ibm_transpiler/utils.py", line 122, in get_circuit_from_qasm
    return get_circuit_from_qasm.fix_ecr(qasm3.loads(qasm_string))
                                         ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/***/scripts/qiskit1.2.1/lib/python3.11/site-packages/qiskit/utils/lazy_tester.py", line 149, in out
    return function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/***/scripts/qiskit1.2.1/lib/python3.11/site-packages/qiskit/qasm3/__init__.py", line 344, in loads
    raise QASM3ImporterError(str(exc)) from exc
qiskit.qasm3.exceptions.QASM3ImporterError: '1,14: non-stdgates imports not currently supported'
@y4izus
Copy link
Collaborator

y4izus commented Sep 23, 2024

Thank you @glanzz for submitting the issue. Some of our team members are trying to reproduce the error, but we are not able to do it. Could you check if it's still happening for you? Thank you!

@glanzz
Copy link
Author

glanzz commented Sep 23, 2024

I was able to reproduce it multiple times yesterday, seems like the issue is fixed.

@y4izus
Copy link
Collaborator

y4izus commented Sep 24, 2024

So, it's now working for you too, right?? if you agree, I'm gonna close the issue :)

@glanzz
Copy link
Author

glanzz commented Sep 25, 2024

@y4izus I am able to reproduce the issue today !

@glanzz
Copy link
Author

glanzz commented Sep 25, 2024

Seems like the QASM response from cloud transpiler is sending rzx gate. And the conversion from QASM to QuantumCircuit obejct is failing when there is rzx gate in it.

@victor-villar
Copy link
Collaborator

Hi @glanzz ! Thanks for reporting again, I have been able to reproduce now, but with ai=true instead of ai=false. Can you confirm if this is the case for you as well? Is it also happening with ai=false?

@glanzz
Copy link
Author

glanzz commented Sep 27, 2024

Yes, I am able to reproduce with ai=True as well as ai=False.

@jesus-talavera-ibm
Copy link
Contributor

Hi @glanzz, can you check if this issue is still happening in last version? We started using QPY as exchange format with service, so QASM issue should not appear anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants