Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
4.85k stars 2.29k forks source link

Circuit construction from higher-order objects #4700

Open ajavadia opened 3 years ago

ajavadia commented 3 years ago

We should be able to construct circuits lazily from objects before they are synthesized. The synthesis happens later, and it may fail if a physical synthesis is not known. This already exists for some things, but this is an issue to keep track of future additions.

It would be good for the circuit constructor to have a whitelist of things that can be legally added (currently it's just anything that implements a to_instruction() method).

Start of a list: [ ] Operator (matrix op) --> remove UnitaryGate [ ] Clifford [ ] Pauli [ ] Isometry --> remove Isometry instruction and consolidate under quantum_info [ ] State (treated as state preparation) [ ] DiagonalOp --> remove DiagonalGate and represent as an operator [ ] SparseCircuitOp (better name?) --> can be used for QuantumError, Linear Combination of Unitaries, Expectation values, [ ] Oracles (done in #4522 )

Cryoris commented 3 years ago

I like the idea to make the synthesis happen later and have abstract blocks inside the circuit, however I think it's also quite a nice feature to be able to just give an object a to_instruction and then being able to append it to the circuit. Especially in times of separated Qiskit elements this might even be a necessary feature, otherwise we cannot append objects only existing in Aer/Ignis/Aqua. For example the Aqua operators should be appendable to a circuit to make phase estimation work nicely. So I think it would be great to add this feature but maybe we should keep the flexibility of just needing to_instruction in parallel. (At least as long as we didn't merge the elements 😉 )

eliarbel commented 2 years ago

@ajavadia I think that quantum circuit white listing should eventually be based on the Operation class, i.e. QuantumCircuit can only append objects of classes derived from Operation