qiskit icon indicating copy to clipboard operation
qiskit copied to clipboard

Transpile error with dynamic circuit on backend

Open dhhoe opened this issue 1 year ago • 9 comments

Environment

  • Qiskit version: 1.1
  • Python version: 3.12.3
  • Operating system: Windows 10

What is happening?

I get the following error: TranspilerError: "The control-flow construct 'if_else' is not supported by the backend." when running backend = service.get_backend(backend_name). This is from the code in cell [5] given at: https://github.com/derek-wang-ibm/coding-with-qiskit/blob/main/episode-5-dynamic-circuits.ipynb

How can we reproduce the issue?

Try running the code as noted above. The only thing I changed in the code was: backend_name = "ibm_sherbrooke" (since "ibm_cusco" as given in the original code is locked for me).

What should happen?

It should work as in Derek Wang's video: https://www.youtube.com/watch?v=QDPtcwhpQkE

Any suggestions?

I noticed a similar error was reported before but it said it was fixed: https://github.com/Qiskit/qiskit-ibm-runtime/issues/1253

dhhoe avatar Jun 21 '24 22:06 dhhoe

Hey @dhhoe I ran this fine on ibm_sherbrooke. Did you only try once?

nihaocami avatar Jun 23 '24 00:06 nihaocami

@chrisamirani, I just tried it again and still get the error. Are you using Qiskit 1.1.0? I noticed in the video where it works, Derek is using v. 1.0.

dhhoe avatar Jun 23 '24 01:06 dhhoe

@chrisamirani, I just tried it again and still get the error. Are you using Qiskit 1.1.0? I noticed in the video where it works, Derek is using v. 1.0.

Yes I am on 1.1.0. hmm strange. can you post the full error log?

Correction: Actually while the job itself seemed to have been successful and the final cell ran without errors for me, I just checked the IBM jobs console for that job and saw this error Qpy to QASM conversion failed: OpenQASM 2 cannot represent 'if_else', which acts on 2 classical bits.

which is similar to the issue you're having. Could be a bug.

nihaocami avatar Jun 23 '24 02:06 nihaocami

@chrisamirani, Here's the full error log:

TranspilerError Traceback (most recent call last) File c:\Users\dhhoe\Miniconda3\envs\qk-py312\Lib\site-packages\qiskit\transpiler\passmanager.py:463, in _replace_error..wrapper(*meth_args, **meth_kwargs) 462 try: --> 463 return meth(*meth_args, **meth_kwargs) 464 except PassManagerError as ex:

File c:\Users\dhhoe\Miniconda3\envs\qk-py312\Lib\site-packages\qiskit\transpiler\passmanager.py:225, in PassManager.run(self, circuits, output_name, callback, num_processes) 223 callback = _legacy_style_callback(callback) --> 225 return super().run( 226 in_programs=circuits, 227 callback=callback, 228 output_name=output_name, 229 num_processes=num_processes, 230 )

File c:\Users\dhhoe\Miniconda3\envs\qk-py312\Lib\site-packages\qiskit\passmanager\passmanager.py:232, in BasePassManager.run(self, in_programs, callback, num_processes, **kwargs) 230 if len(in_programs) == 1 or not should_run_in_parallel(num_processes): 231 out = [ --> 232 _run_workflow(program=program, pass_manager=self, callback=callback, **kwargs) 233 for program in in_programs 234 ] 235 if len(in_programs) == 1 and not is_list:

File c:\Users\dhhoe\Miniconda3\envs\qk-py312\Lib\site-packages\qiskit\passmanager\passmanager.py:292, in _run_workflow(program, pass_manager, **kwargs) ... 463 return meth(*meth_args, **meth_kwargs) 464 except PassManagerError as ex: --> 465 raise TranspilerError(ex.message) from ex

TranspilerError: "The control-flow construct 'if_else' is not supported by the backend."

dhhoe avatar Jun 23 '24 03:06 dhhoe

@dhhoe Thx. Now circling back to your original issue description when you say "The only thing I changed in the code was: backend_name = "ibm_sherbrooke"" , did you also happen to change the job_id later on to match the job_id produced in step 3?

nihaocami avatar Jun 23 '24 03:06 nihaocami

@chrisamirani the error occurs in 'Step 2' in the code, so I don't get to 'Step 4' where I need to update the job_id. Thx for the help.

dhhoe avatar Jun 23 '24 03:06 dhhoe

@chrisamirani the error occurs in 'Step 2' in the code, so I don't get to 'Step 4' where I need to update the job_id. Thx for the help.

Yeah unfortunately I can't reproduce. Maybe other folks can help here. Good luck!

nihaocami avatar Jun 23 '24 04:06 nihaocami

It sounds like a version mismatch. I'd update to the latest versions of qiskit-aer and qiskit-ibm-runtime.

yaelbh avatar Jun 23 '24 08:06 yaelbh

@yaelbh okay, I updated qiskit from v. 1.1.0 to 1.1.1 and updated qiskit-ibm-runtime from v. 0.24.0 to v. 0.24.1 and it runs without errors now.

dhhoe avatar Jun 23 '24 19:06 dhhoe

Just an additional comment that backend.operation_names lists the instruction names that the backend supports.

jsaroni avatar Jul 02 '24 22:07 jsaroni

Can we consider this issue fixed in 1.1.1?

1ucian0 avatar Aug 07 '24 10:08 1ucian0

Yes, the problem was solved once I upgraded from 1.1.0 to 1.1.1. Thanks. - DH

Loyola University Maryland Internal Use Only From: Luciano Bello @.> Sent: Wednesday, August 7, 2024 6:38 AM To: Qiskit/qiskit @.> Cc: David Hoe @.>; Mention @.> Subject: [EXTERNAL] Re: [Qiskit/qiskit] Transpile error with dynamic circuit on backend (Issue #12642)

EXTERNAL SENDER

Can we consider this issue fixed in 1.1.1?

Reply to this email directly, view it on GitHubhttps://github.com/Qiskit/qiskit/issues/12642#issuecomment-2273161670, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASIGRLRB75WYJ6FM7TM5SI3ZQH2IFAVCNFSM6AAAAABJWZ3F3GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZTGE3DCNRXGA. You are receiving this because you were mentioned.Message ID: @.***>

dhhoe avatar Aug 07 '24 18:08 dhhoe