The ConcretizedCallable and Embedding classes were added as a prototype way to handle parameter expressions. However, they have since been adapted into Qadence 2 Platforms, and we might not need to keep them in PyQ.
The ConcretizedCallable itself can be used as a torch specific expression, that is evaluated based on a values dict. Renaming it as Expr, it could take the following form:
If we then allow all parameters to accept an Expr instance, instead of just str, probably we would no longer need the Embedding class, since the values dict would just get sent into the Expr tree.
(and similarly for the tensor method). Then we can write stuff like:
import torch
import pyqtorch as pyq
## Creating an expression and embedding
expr = "z" ** pyq.log(1.0 / (1.0 + (2.0 * pyq.sin("x")) + "y"))
## Passing the expression to a block parameter
op = pyq.Scale(pyq.I(0), expr)
values = {"x": torch.tensor(1.0), "y": torch.tensor(-1.0), "z": torch.tensor(2.0)}
matrix = op.tensor(values)
matrix[..., 0].real
---
tensor([[0.6971, 0.0000],
[0.0000, 0.6971]])
Currently, the one other use of the Embedding class is to reembed the time values in the time-dependent hamiltonian evolution. But if instead there is an Expr there where one of the inputs is some parameter "t", we can probably just call it with updated values of "t".
Describe the feature
The
ConcretizedCallable
andEmbedding
classes were added as a prototype way to handle parameter expressions. However, they have since been adapted into Qadence 2 Platforms, and we might not need to keep them in PyQ.The
ConcretizedCallable
itself can be used as a torch specific expression, that is evaluated based on a values dict. Renaming it asExpr
, it could take the following form:If we then allow all parameters to accept an
Expr
instance, instead of juststr
, probably we would no longer need theEmbedding
class, since thevalues
dict would just get sent into theExpr
tree.For example, the
Scale
forward currently reads:Instead, it could be:
(and similarly for the
tensor
method). Then we can write stuff like:Currently, the one other use of the
Embedding
class is to reembed the time values in the time-dependent hamiltonian evolution. But if instead there is anExpr
there where one of the inputs is some parameter"t"
, we can probably just call it with updated values of "t".It should be implemented because
No response
Additional context
No response
Would you like to work on this issue?
None