PennyLaneAI / catalyst

A JIT compiler for hybrid quantum programs in PennyLane
https://docs.pennylane.ai/projects/catalyst
Apache License 2.0
142 stars 36 forks source link

Implement an option to print out instructions in the null device #1316

Open jay-selby opened 1 week ago

jay-selby commented 1 week ago

Context

The PennyLane plugin should have an Boolean option print_instructions (other names can also be proposed) with a default False value. This option must forwarded to the C++ device constructor.

In the runtime plugin, the QuantumDevice should be able to print out the following instructions when the option is set to true:

The format should be kept as simple as possible while providing the necessary information (numerical parameters, wires, control wires, control values, adjoint), for example:

H(0)
RY(0.5, wires=0)
C(Z(1), control=[2, 3, 4])
Adjoint(Y(0))

Observables should be printed as part of the measurement process, not upon their construction, for example:

Expval(Y(0))
Var(Z(0) x (Y(1))
Sample(wires=[0, 1, 2], shots=100)

Installation help

Complete instructions to install Catalyst from source can be found here. Note that due to the size of the llvm-project it can take a while (~3 hrs on a personal laptop) to compile.