pasqal-io / qadence

Digital-analog quantum programming interface
https://pasqal-io.github.io/qadence/latest/
Apache License 2.0
71 stars 21 forks source link

[Bug] HamEvo with FeatureParameter gets handled as a time-dependent hamiltonian in PyQ #602

Open jpmoutinho opened 2 weeks ago

jpmoutinho commented 2 weeks ago

Short description

Currently if you do

from qadence import HamEvo, FeatureParameter, TimeParameter

phi = FeatureParameter("phi")

hamiltonian = phi * Z(0)

evo = HamEvo(hamiltonian, phi)

Qadence assumes that this is a time-independent Hamiltonian (evo.is_time_dependent = False), essentially representing exp(-i phiˆ2 Z(0)). So it will not complain that there is a duration missing. However, in pyqtorch it will instantiate something equivalent to doing:

from pyqtorch import X, HamiltonianEvolution, Scale

hamiltonian = Scale(X(0), "phi")

evo = HamiltonianEvolution(hamiltonian, "phi")

And here pyqtorch will assume that this is a time-dependent Hamiltonian (evo.has_time_param = True). On execution, it will fail because it will try to integrate this for a certain duration, which qadence provided as None.

Opening the issue in Qadence because that's where the bug originates from, but actually I think this will require a fix in PyQ.

What is the expected result?

Unclear what is the best solution for this. We don't have parameter types in PyQ and we might want to avoid adding those.

What is the actual result?

No response

Steps/Code to reproduce

Already above.

Tracebacks (optional)

No response

Environment details (optional)

No response

Would you like to work on this issue?

None