-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
RustThis PR or issue is related to Rust code in the repositoryThis PR or issue is related to Rust code in the repositorybugSomething isn't workingSomething isn't workingmod: transpilerIssues and PRs related to TranspilerIssues and PRs related to Transpiler
Milestone
Description
Environment
- Qiskit version: 1.2.0
- Python version: 3.10
- Operating system: macOS
What is happening?
Since moving to Rust space, the TwoQubitBasisDecomposer
has encoded an assumption that the given KAK gate is a Rust-space StandardGate
. This is true in most uses within Qiskit, but not necessarily user-defined targets.
How can we reproduce the issue?
from qiskit.circuit import library as std
from qiskit.synthesis import TwoQubitBasisDecomposer
# note that `CXGate(ctrl_state=0)` is not handled as a "standard" gate.
TwoQubitBasisDecomposer(std.CXGate(ctrl_state=0))(std.CXGate())
thread '<unnamed>' panicked at /Users/runner/work/qiskit/qiskit/crates/circuit/src/packed_instruction.rs:168:14:
the caller is responsible for knowing the correct type
stack backtrace:
[ ... snip ... ]
10: 0x10f2b719a - core::option::expect_failed::ha3671a0dd3229d4c
11: 0x10f1570ba - qiskit_accelerate::two_qubit_decompose::TwoQubitBasisDecomposer::__pymethod_to_circuit__::h78b6cbefd6ac2cc6
12: 0x10f0c6488 - pyo3::impl_::trampoline::trampoline::hb8b7fc9b34400178
13: 0x10f137668 - qiskit_accelerate::two_qubit_decompose::<impl pyo3::impl_::pyclass::PyMethods<qiskit_accelerate::two_qubit_decompose::TwoQubitBasisDecomposer> for pyo3::impl_::pyclass::PyClassImplCollector<qiskit_accelerate::two_qubit_decompose::TwoQubitBasisDecomposer>>::py_methods::ITEMS::trampoline::h3e5e5843f2694fc9
[ ... snip ...]
---------------------------------------------------------------------------
PanicException Traceback (most recent call last)
Cell In[1], line 4
1 from qiskit.circuit import library as std
2 from qiskit.synthesis import TwoQubitBasisDecomposer
----> 4 TwoQubitBasisDecomposer(std.CXGate(ctrl_state=0))(std.CXGate())
File ~/code/qiskit/venv310-other/lib/python3.10/site-packages/qiskit/synthesis/two_qubit/two_qubit_decompose.py:667, in TwoQubitBasisDecomposer.__call__(self, unitary, basis_fidelity, approximate, use_dag, _num_basis_uses)
665 else:
666 if getattr(self.gate, "_standard_gate", None):
--> 667 circ_data = self._inner_decomposer.to_circuit(
668 np.asarray(unitary, dtype=complex),
669 self.gate,
670 basis_fidelity,
671 approximate,
672 _num_basis_uses=_num_basis_uses,
673 )
674 return QuantumCircuit._from_circuit_data(circ_data)
675 else:
PanicException: the caller is responsible for knowing the correct type
What should happen?
We should be able to output the circuit in that case.
Any suggestions?
The decomposition is actually internally successful, the problem is just the assumption that after let kak_gate = kak_gate.extract::<OperationFromPython>()?;
, then kak_gate.operation
internally stores a StandardGate
.
We should actually check whether that's the case, and if not, avoid using the CircuitData::from_standard_gates
fast-path constructor an instead use a general-purpose one.
ElePT
Metadata
Metadata
Assignees
Labels
RustThis PR or issue is related to Rust code in the repositoryThis PR or issue is related to Rust code in the repositorybugSomething isn't workingSomething isn't workingmod: transpilerIssues and PRs related to TranspilerIssues and PRs related to Transpiler