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
5.02k stars 2.32k forks source link

Light Cone Transpiler Pass #12792

Open MarcDrudis opened 1 month ago

MarcDrudis commented 1 month ago

What should we add?

I think it would be a good idea to add a Transpiler pass that computes the light cone of an observable. For those who are not familiar, a light cone is the set of gates in a circuit that affect the measurement of a subset of the qubits. For example, if you have a shallow EfficientSU2 ansatz with pairwise entanglement on 127 qubits and you are trying to measure an expectation value on a single qubit you can typically reduce the circuit to a 20 qubit circuit (just making up the number, in practice it depends). I use it a lot in my research and I know of other researchers that do it as well. We all typically have a naive implementation of it, but it would be a powerful tool to have one that handles edge cases directly implemented into Qiskit.

I can take care of this issue as I already have code that does it. Before tacking this problem, however, it would be wise to first implement the proposal in #12790 to allow for computation of light cones also in parameterized circuits.

spiccinelli commented 1 month ago

I would be interested in participating and happy to help 😄

Cryoris commented 1 month ago

This sounds like a nice addition. Though the main motivation might come from classically simulating the circuit, this could be useful when compiling circuits for hardware as we could simplify the compilation problem. Reducing the circuit size could also potentially allow for better routing, but also requires some care (e.g. regarding the user-provided initial layout).

If we'd select the "active" qubits by the presence of the measurement we might need to take special care of mid-circuit measurements. For example, we might only care about the final measurements and could allow removing mid-circuit measurements if they are part of a control-flow that doesn't affect the target measurements. But we can discuss these details at a later stage.

alexanderivrii commented 1 month ago

I think Andrew Eddins (@aeddins-ibm) already has a pass that does exactly this.

aeddins-ibm commented 1 month ago

Hi @alexanderivrii, thanks for pointing that out. @Cryoris reached out to me separately to coordinate, and I believe we are on the same page that my rough-draft code may be used as a starting point if that turns out to be helpful.