pasqal-io / qadence

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

[Feature] Time dependent generator #395

Closed RolandMacDoland closed 4 months ago

RolandMacDoland commented 6 months ago

Initial proposal of time-dependent generator block.

Code to test some capabilities of current implementation:

from qadence.blocks.time_block import TDGenerator
from qadence.parameters import Parameter
from pprint import pprint

# create parametrized blocks
t = Parameter("t")
block1 = tag(t * X(0), "block1")
block2 = tag((t**2) * Y(1), "block2")

# create time-dependent generator objects
td_gen1 = TDGenerator.from_block(100, block1)
td_gen2 = TDGenerator.from_block(200, block2)

# perform chain operation on time-dependent generator objects
td_gen3 = td_gen1 * td_gen2 * td_gen1

pprint(td_gen3.schedule, sort_dicts=False)

print("actual generator matrix:")
print(td_gen3(torch.tensor(0.15)))

As it can be seen from this code snippet, the TDGenerator object can be called with a time argument that results in a tensor representing the corresponding generator at some time t. Now it is easy to pass this TDGenerator object to dynamiqs or krylov solvers to actually get the time evolution of the system. The main questions/suggestions now are the following:

  1. HamEvo can be modified to accept TDGenerator objects as generator and then in the backend it can be checked whether pyq or Schrodinger equation solver must handle the simulation. In this way HamEvo act as a placeholder that potentially can store time-dependent blocks.
  2. Do we allow TDGenerator objects to be part of the circuit on their own, without being encapsulated in HamEvo?
  3. Do we create a separate backend for Schrodinger equation solvers or integrate them into pyq?
  4. What is the place of TDGenerator in the hierarchy of blocks, e.g., should it inherit from AbstractBlock or be completely standalone?
jpmoutinho commented 5 months ago

Adding to_check label since it's being developed now but it still needs to be properly checked in the new expression system.