Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Time-dependent block implementation #21

Open
vytautas-a opened this issue Jul 3, 2024 · 3 comments
Open

[Feature] Time-dependent block implementation #21

vytautas-a opened this issue Jul 3, 2024 · 3 comments
Labels

Comments

@vytautas-a
Copy link

Current implementation of time-dependent block in qadence is using all the usual blocks to build the generator for HamEvo with two additional twists. First, the parameter that denotes time is a Parameter instance with an additional flag is_time=True. Currently it can be created using TimeParameter helper function in a similar way to FeatureParameter and VariationalParameter:

def TimeParameter(name: str) -> Parameter:
    """Shorthand for `Parameter(..., trainable=False, is_time=True)`."""
    return Parameter(name, trainable=False, is_time=True)

Second, the composite block acting as the generator has a property is_time_dependent=True (implemented in AbstractBlock class):

@property
def is_time_dependent(self) -> bool:
    from qadence.blocks.utils import parameters

    params: list[sympy.Basic] = parameters(self)
    return any(getattr(p, "is_time", False) for p in params)

Basically, that's all that distinguishes an arbitrary block from a time-dependent one.

@kaosmicadei
Copy link
Contributor

How does it translate to PyQ?

@RolandMacDoland
Copy link
Contributor

How does it translate to PyQ?

I think this is exactly what @vytautas-a is working on atm by implementing time-dependent solvers in PyQ.

@kaosmicadei
Copy link
Contributor

From the expression side, it would require only a shortcut constructor.

def time_parameter(name: str) -> Expression:
    return Expression.symbol(name, time_parameter=True)

But it will not affect how the expressions handle that symbol.

From the platform side, we can add flags to the Alloc type in the Qadence IR similar to QuInstruct.

Then, a type symbol could be passed to the model as Alloc(1, trainable=True, time_parameter=True).

Regarding the operation, in addition to the prefix dyn_ in the operation's name (dyn_evo and dyn_qubit are the current suggestions), we can add a flag like time_dependent=True to t.

@RolandMacDoland RolandMacDoland changed the title Time-dependent block implementation [Feature] Time-dependent block implementation Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants