Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.

Home Page:https://www.ibm.com/quantum/qiskit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

2Q gate synthesis with fractional gates

nkanazawa1989 opened this issue · comments

Environment

  • Qiskit version: main
  • Python version: doesn't matter
  • Operating system: doesn't matter

What is happening?

When I build a Qiskit Target that supports two qubit basis gates with arbitrary rotation angle, it cannot transpile the circuit if the added basis gate is other than RZXGate or RXXGate.

How can we reproduce the issue?

from qiskit.providers.fake_provider import GenericBackendV2
from qiskit import quantum_info as qi, transpile, QuantumCircuit

backend = GenericBackendV2(2, basis_gates=["rz", "rx", "rzz"])
qc = QuantumCircuit(2)
qc.unitary(qi.random_unitary(4), [0, 1])
isa = transpile(qc, target=backend.target)

this results in an error

TypeError: ParameterExpression with unbound parameters (dict_keys([Parameter(ϴ)])) cannot be cast to a float.

because it tries to get the unitary matrix of parameterized RZZGate(Parameter(ϴ)) instruction.

On the other hand, it transpiles circuit when I directly specify the basis gates.

isa = transpile(qc, basis_gates=["rz", "rx", "rzz"])

What should happen?

  • Qiskit transpiler should support arbitrary fractional two qubit basis gates, e.g. RZX, RXX, RYY, RZZ, RXY, ....
  • Transpiling with Target and giving basis_gates should behave identically.

This is related but might be a feature request; even if I give RZXGate(Parameter(ϴ)) in the target, current synthesis algorithm only picks pi/4 rotation. The synthesis pass should consider another angle if there is possibility of reducing the circuit depth.

Any suggestions?

No. I'm not familiar with synthesis passes.

Many components of transpiler is currently being ported to Rust.
Not, sure if the fix of this bug is supposed to be in the current python code base or the fix is planned in the future Rust code base.

Many components of transpiler is currently being ported to Rust.
Not, sure if the fix of this bug is supposed to be in the current python code base or the fix is planned in the future Rust code base.

While this pass will almost certainly be ported to be written in Rust in the near future, in the short term coming up with a fix for this makes sense. The exact time frame for the migration isn't clear, also a fix for the python implementation can be backported to stable releases for inclusion in a bugfix release.