Open ChenZhao44 opened 2 years ago
Do you want to restrict the Hamiltonian or do the decomposition? The Pauli decomposition is straight forward, so I guess you mean how to use the correct representation, right?
If you want the representation, you can create a new data type PauliString
as shown here: https://github.com/QuantumBFS/YaoExtensions.jl/blob/master/src/block_extension/pauli_strings.jl .
Then, you need to implement the function to_basictypes
to define how your new block can be converted to basic block types like ChainBlock
and PutBlock
, it is useful when you
YaoPlots.jl
YaoToEinsum
.I think we can first restrict the observables to be Pauli? this is much simpler and covers the use cases as I don't think there are use case for non-Pauli from Clifford side at the moment?
Do you want to restrict the Hamiltonian or do the decomposition? The Pauli decomposition is straight forward, so I guess you mean how to use the correct representation, right?
If you want the representation, you can create a new data type PauliString as shown here: https://github.com/QuantumBFS/YaoExtensions.jl/blob/master/src/block_extension/pauli_strings.jl .
Pauli decomposition can be exponential. I was just wondering an existing data type for Pauli strings in Yao. So PauliString
seems perfect.
I think we can first restrict the observables to be Pauli? this is much simpler and covers the use cases as I don't think there are use case for non-Pauli from Clifford side at the moment?
I think the observable can be a sum of Paulis. I will firstly restrict it to be an Add
block consists of PauliString
s.
Maybe aliasing kron
is easier
julia> kron(X, Y, Z, I2) |> typeof
KronBlock{4, 4, Tuple{XGate, YGate, ZGate, I2Gate}}
julia> PauliString{N} = KronBlock{N, N, <:NTuple{N,Yao.YaoBlocks.PauliGate}}
KronBlock{N, N, Tuple{Vararg{YaoBlocks.ConstGate.PauliGate, N}}} where N
# define the constructor properly
julia> function PauliString(args::YaoBlocks.PauliGate...)
kron(args...)
end
julia> PauliString(X, Y, X)
nqubits: 3
kron
├─ 1=>X
├─ 2=>Y
└─ 3=>X
julia> PauliString(X, Y, X) isa PauliString
true
BUT, kron
may suffer from having exponential many types. Maybe you want a dynamic version?
In Yao, Hamiltonians are represented as general blocks. And
expect
function is implemented ascopy(st)' * apply!(st, H)
. It works perfect for pure states. But when using stabilizer tableau representation,apply!
means applying an operator on a density matrix. So we need to overloadexpect
for stabilizer states. Currently, QuantumClifford support expectation value of Pauli operators on stabilizer states. However, converting a general block into Pauli strings is not easy in general. We should have some requirements on the block that we use to represent Hamiltonians. Do you have any ideas on this issue? @Roger-luo @GiggleLiu