When calling HamEvo on diagonal Hamiltonians the dense matrix is built but then only the diagonal is taken.
This is currently done in the PyQHamiltonianEvolution class in qadence/backends/pyqtorch/convert_ops.py, where the __init__ method first builds the full matrix hmat, and then the _unitary method defines the evolution function for diagonal operators which runs diagonal() on the full hamiltonian matrix.
We should instead build only the diagonal. For non-parametric block this is directly possible with the function block_to_diagonal, as done in the PyQObservable class in the same file.
Handling parametric blocks is out of the scope of this issue, and can be done separately. It requires further development in the block_to_tensor side as detailed in #394.
NOTE: Due to ongoing changes in the codebase, we might need to implement this directly in the PyQTorch backend (pasqal-io/pyqtorch#175).
When calling
HamEvoon diagonal Hamiltonians the dense matrix is built but then only the diagonal is taken.This is currently done in the
PyQHamiltonianEvolutionclass inqadence/backends/pyqtorch/convert_ops.py, where the__init__method first builds the full matrixhmat, and then the_unitarymethod defines the evolution function for diagonal operators which runsdiagonal()on the full hamiltonian matrix.We should instead build only the diagonal. For non-parametric block this is directly possible with the function
block_to_diagonal, as done in thePyQObservableclass in the same file.Handling parametric blocks is out of the scope of this issue, and can be done separately. It requires further development in the
block_to_tensorside as detailed in #394.NOTE: Due to ongoing changes in the codebase, we might need to implement this directly in the PyQTorch backend (pasqal-io/pyqtorch#175).