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

Add translation to RX(X) basis to equivalence library #7332

Closed
Cryoris opened this issue Dec 1, 2021 · 3 comments · Fixed by #7407
Closed

Add translation to RX(X) basis to equivalence library #7332

Cryoris opened this issue Dec 1, 2021 · 3 comments · Fixed by #7407
Labels
good first issue Good for newcomers type: enhancement It's working, but needs polishing

Comments

@Cryoris
Copy link
Contributor

Cryoris commented Dec 1, 2021

What is the expected enhancement?

Allow using RX and RXX as basis gates by adding appropriate entries to the equivalence library:

  • RZ = H RX H (and RZZ = HH RXX HH)
  • RY = Sdg RX S (and equivalently for 2 qubits)

Currently this translation is not supported:

>>> from qiskit import QuantumCircuit, transpile
>>> qc = QuantumCircuit(1)
>>> qc.ry(0.1, 0);
>>> transpile(qc, basis_gates=["rx", "h", "s", "sdg"])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jul/Qiskit/qiskit-terra/qiskit/compiler/transpiler.py", line 319, in transpile
    circuits = parallel_map(_transpile_circuit, list(zip(circuits, transpile_args)))
  File "/Users/jul/Qiskit/qiskit-terra/qiskit/tools/parallel.py", line 132, in parallel_map
    return [task(values[0], *task_args, **task_kwargs)]
  File "/Users/jul/Qiskit/qiskit-terra/qiskit/compiler/transpiler.py", line 407, in _transpile_circuit
    circuit, callback=transpile_config["callback"], output_name=transpile_config["output_name"]
  File "/Users/jul/Qiskit/qiskit-terra/qiskit/transpiler/passmanager.py", line 216, in run
    return self._run_single_circuit(circuits, output_name, callback)
  File "/Users/jul/Qiskit/qiskit-terra/qiskit/transpiler/passmanager.py", line 272, in _run_single_circuit
    result = running_passmanager.run(circuit, output_name=output_name, callback=callback)
  File "/Users/jul/Qiskit/qiskit-terra/qiskit/transpiler/runningpassmanager.py", line 123, in run
    dag = self._do_pass(pass_, dag, passset.options)
  File "/Users/jul/Qiskit/qiskit-terra/qiskit/transpiler/runningpassmanager.py", line 154, in _do_pass
    dag = self._run_this_pass(pass_, dag)
  File "/Users/jul/Qiskit/qiskit-terra/qiskit/transpiler/runningpassmanager.py", line 166, in _run_this_pass
    new_dag = pass_.run(dag)
  File "/Users/jul/Qiskit/qiskit-terra/qiskit/transpiler/passes/basis/basis_translator.py", line 114, in run
    "over library {}.".format(source_basis, target_basis, self._equiv_lib)
qiskit.transpiler.exceptions.TranspilerError: "Unable to map source basis {('ry', 1)} to target basis {'reset', 'snapshot', 's', 'delay', 'barrier', 'h', 'measure', 'sdg', 'rx'} over library <qiskit.circuit.equivalence.EquivalenceLibrary object at 0x7f9058c20a90>."
@Cryoris Cryoris added type: enhancement It's working, but needs polishing good first issue Good for newcomers labels Dec 1, 2021
@ajavadia
Copy link
Member

ajavadia commented Dec 9, 2021

basis_gates=["rx", "rz"] works.

So I agree that it should be enough to add the equivalence relations you have highlighted.

@Osmanilge
Copy link

Hello I want to assigned for this issue. I am new in qiskit but I am interested in Qiskit so may you inform me about issue? I hope this issue is suitable for me.

@Cryoris
Copy link
Contributor Author

Cryoris commented Jan 26, 2022

Currently, @tyrolize is already working on this issue with their PR #7407 🙂

@javabster javabster moved this to PR Open in Contributor Monitoring Jun 22, 2022
@javabster javabster moved this from PR open / Contributor working on it to Waiting for maintainer response in Contributor Monitoring Aug 1, 2022
@1ucian0 1ucian0 moved this from Waiting for maintainer response to PR open / Contributor working on it in Contributor Monitoring Aug 4, 2022
@1ucian0 1ucian0 moved this from PR open / Contributor working on it to Waiting for maintainer response in Contributor Monitoring Aug 4, 2022
@github-project-automation github-project-automation bot moved this from Waiting for maintainer response to Done in Contributor Monitoring Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers type: enhancement It's working, but needs polishing
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants