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

HighLevelSynthesis raises an error with 1.3.0rc1 (no error with 1.2.4 and main branch) #13412

Closed
t-imamichi opened this issue Nov 8, 2024 · 2 comments · Fixed by #13417
Closed
Labels
bug Something isn't working synthesis
Milestone

Comments

@t-imamichi
Copy link
Member

t-imamichi commented Nov 8, 2024

Environment

  • Qiskit version: 1.3.0rc1
  • Python version: 3.12.7
  • Operating system: macOS 15.1

What is happening?

HighLevelSynthesis raises an error with only 1.3.0rc1. 1.2.4 and main branch work fine.

How can we reproduce the issue?

from qiskit import QuantumCircuit
from qiskit.circuit.library import QAOAAnsatz
from qiskit.quantum_info import SparsePauliOp
from qiskit.transpiler import PassManager
from qiskit.transpiler.passes import HighLevelSynthesis

qc = QAOAAnsatz(SparsePauliOp("Z"), initial_state=QuantumCircuit(1))
pm = PassManager([HighLevelSynthesis(basis_gates=["PauliEvolution"])])
qc2 = pm.run(qc)
print(qc2)

What should happen?

# 1.2.4 and main branch
   ┌──────────────────┐┌──────────────────┐
q: ┤ exp(-it Z)(γ[0]) ├┤ exp(-it X)(β[0]) ├
   └──────────────────┘└──────────────────┘
# 1.3.0rc1
Traceback (most recent call last):
  File "/Users/ima/envs/qiskit130/lib/python3.12/site-packages/qiskit/transpiler/passmanager.py", line 464, in wrapper
    return meth(*meth_args, **meth_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ima/envs/qiskit130/lib/python3.12/site-packages/qiskit/transpiler/passmanager.py", line 226, in run
    return super().run(
           ^^^^^^^^^^^^
  File "/Users/ima/envs/qiskit130/lib/python3.12/site-packages/qiskit/passmanager/passmanager.py", line 232, in run
    _run_workflow(program=program, pass_manager=self, callback=callback, **kwargs)
  File "/Users/ima/envs/qiskit130/lib/python3.12/site-packages/qiskit/passmanager/passmanager.py", line 292, in _run_workflow
    passmanager_ir, final_state = flow_controller.execute(
                                  ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ima/envs/qiskit130/lib/python3.12/site-packages/qiskit/passmanager/base_tasks.py", line 218, in execute
    passmanager_ir, state = next_task.execute(
                            ^^^^^^^^^^^^^^^^^^
  File "/Users/ima/envs/qiskit130/lib/python3.12/site-packages/qiskit/transpiler/basepasses.py", line 195, in execute
    new_dag, state = super().execute(
                     ^^^^^^^^^^^^^^^^
  File "/Users/ima/envs/qiskit130/lib/python3.12/site-packages/qiskit/passmanager/base_tasks.py", line 98, in execute
    ret = self.run(passmanager_ir)
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ima/envs/qiskit130/lib/python3.12/site-packages/qiskit/transpiler/passes/synthesis/high_level_synthesis.py", line 279, in run
    out_dag = self._run(dag, tracker, context, use_ancillas=True, top_level=True)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ima/envs/qiskit130/lib/python3.12/site-packages/qiskit/transpiler/passes/synthesis/high_level_synthesis.py", line 379, in _run
    synthesized, synthesized_context = self._synthesize_operation(
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ima/envs/qiskit130/lib/python3.12/site-packages/qiskit/transpiler/passes/synthesis/high_level_synthesis.py", line 606, in _synthesize_operation
    synthesized = self._run(
                  ^^^^^^^^^^
  File "/Users/ima/envs/qiskit130/lib/python3.12/site-packages/qiskit/transpiler/passes/synthesis/high_level_synthesis.py", line 379, in _run
    synthesized, synthesized_context = self._synthesize_operation(
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ima/envs/qiskit130/lib/python3.12/site-packages/qiskit/transpiler/passes/synthesis/high_level_synthesis.py", line 606, in _synthesize_operation
    synthesized = self._run(
                  ^^^^^^^^^^
  File "/Users/ima/envs/qiskit130/lib/python3.12/site-packages/qiskit/transpiler/passes/synthesis/high_level_synthesis.py", line 379, in _run
    synthesized, synthesized_context = self._synthesize_operation(
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ima/envs/qiskit130/lib/python3.12/site-packages/qiskit/transpiler/passes/synthesis/high_level_synthesis.py", line 606, in _synthesize_operation
    synthesized = self._run(
                  ^^^^^^^^^^
  File "/Users/ima/envs/qiskit130/lib/python3.12/site-packages/qiskit/transpiler/passes/synthesis/high_level_synthesis.py", line 379, in _run
    synthesized, synthesized_context = self._synthesize_operation(
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ima/envs/qiskit130/lib/python3.12/site-packages/qiskit/transpiler/passes/synthesis/high_level_synthesis.py", line 606, in _synthesize_operation
    synthesized = self._run(
                  ^^^^^^^^^^
  File "/Users/ima/envs/qiskit130/lib/python3.12/site-packages/qiskit/transpiler/passes/synthesis/high_level_synthesis.py", line 379, in _run
    synthesized, synthesized_context = self._synthesize_operation(
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ima/envs/qiskit130/lib/python3.12/site-packages/qiskit/transpiler/passes/synthesis/high_level_synthesis.py", line 606, in _synthesize_operation
    synthesized = self._run(
                  ^^^^^^^^^^
  File "/Users/ima/envs/qiskit130/lib/python3.12/site-packages/qiskit/transpiler/passes/synthesis/high_level_synthesis.py", line 379, in _run
    synthesized, synthesized_context = self._synthesize_operation(
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ima/envs/qiskit130/lib/python3.12/site-packages/qiskit/transpiler/passes/synthesis/high_level_synthesis.py", line 570, in _synthesize_operation
    synthesized = self._get_custom_definition(operation, indices)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ima/envs/qiskit130/lib/python3.12/site-packages/qiskit/transpiler/passes/synthesis/high_level_synthesis.py", line 655, in _get_custom_definition
    raise TranspilerError(f"HighLevelSynthesis was unable to synthesize {inst}.")
qiskit.transpiler.exceptions.TranspilerError: "HighLevelSynthesis was unable to synthesize Instruction(name='u', num_qubits=1, num_clbits=0, params=[0.0, 0.0, ParameterExpression(2.0*γ[0])])."

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

Traceback (most recent call last):
  File "/Users/ima/tasks/4_2024/qiskit/terra/tmp/synth.py", line 9, in <module>
    qc2 = pm.run(qc)
          ^^^^^^^^^^
  File "/Users/ima/envs/qiskit130/lib/python3.12/site-packages/qiskit/transpiler/passmanager.py", line 466, in wrapper
    raise TranspilerError(ex.message) from ex
qiskit.transpiler.exceptions.TranspilerError: "HighLevelSynthesis was unable to synthesize Instruction(name='u', num_qubits=1, num_clbits=0, params=[0.0, 0.0, ParameterExpression(2.0*γ[0])])."

Any suggestions?

No response

@t-imamichi t-imamichi added bug Something isn't working synthesis labels Nov 8, 2024
@t-imamichi t-imamichi changed the title HighLevelSynthesis raises an error with 1.3.0rc1 (not 1.2.4 and main branch) HighLevelSynthesis raises an error with 1.3.0rc1 (no error with 1.2.4 and main branch) Nov 8, 2024
@Cryoris
Copy link
Contributor

Cryoris commented Nov 8, 2024

The issue seems to be that HLS sees that we have a plugin available for PauliEvolution and calls that, even though it is already in the basis_gates. We're looking into it.

As a workaround until then, does it work for you to use

qc = QAOAAnsatz(...., flatten=True)

or just a manual decompose, to remove that outer wrapping layer, instead of calling HLS?

@t-imamichi
Copy link
Member Author

Thank you. I'm not in a hurry. So, I wait for #13417.

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

Successfully merging a pull request may close this issue.

3 participants