Yao currently contains builtin automatic differentiation engine (an operator overloading based) especially for quantum circuits. It uses the reversible context of quantum computation to optimize the performance during simulation, thus you may find this is way faster than any other AD engine at the moment.
As for expectation, the usage is pretty simple, since the evluation of expectations are just
expect(H, rand_state(10)=>circuit)
to get the gradients, simply add an adjoint
expect'(H, rand_state(10)=>circuit)
which will return the pair of gradients, one is the gradient of input register and the other is the gradient of circuit parameters.
The builtin AD engine for Yao only provides the differentiation of quantum circuits, but you can plug it into a general AD engine, such as Zygote, since we have ported these rules to ChainRules.
Modules = [YaoBlocks.AD]
Order = [:function, :macro]