Skip to content

[Refactoring] Avoid calling block to tensor on diagonal Hamiltonians #368

Description

@jpmoutinho

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).

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions