ITensorNetworks.jl icon indicating copy to clipboard operation
ITensorNetworks.jl copied to clipboard

Pass common keyword arguments to local updaters in a NamedTuple `internal_kwargs`

Open mtfishman opened this issue 1 year ago • 4 comments

Pass common keyword arguments to local updaters in a keyword argument internal_kwargs that stores them in a NamedTuple instead of individually/splatted into the updater. Many updaters don't use most of the keyword arguments being passed to them from alternating_update: https://github.com/ITensor/ITensorNetworks.jl/tree/v0.11.6/src/solvers/local_solvers so that would simplify the code a lot.

I plan to use that design in ITensorTDVP.jl v0.4: https://github.com/ITensor/ITensorTDVP.jl/pull/74 and I think it is quite nice, since then updaters only need to do a bit of extra work to extract the keyword arguments they are actually using. updater_kwargs will still be splatted into the updaters.

@b-kloss I think we discussed this design and decided against it but now I'm convinced it is the way to go since it makes most updater definitions a lot simpler.

mtfishman avatar May 13 '24 19:05 mtfishman

I agree this sounds nice. I like the options in Julia for extracting keyword arguments now too, like the (; a,b,c) destructuring syntax if that's applicable here.

emstoudenmire avatar May 13 '24 20:05 emstoudenmire

Sounds good. I assume the idea is to put the common keyword arguments into the existing NamedTuple internal_kwargs, which is currently reserved for keyword arguments that can only be inferred when the sweep_plan is created? Or would these be kept in a separate one?

b-kloss avatar May 13 '24 22:05 b-kloss

I guess so, I forget why in the current code certain keyword arguments are going into internal_kwargs while others are not but I don't see why they couldn't all just go into a single internal_kwargs.

mtfishman avatar May 13 '24 22:05 mtfishman

I agree this sounds nice. I like the options in Julia for extracting keyword arguments now too, like the (; a,b,c) destructuring syntax if that's applicable here.

That syntax is relevant here, see examples in https://github.com/ITensor/ITensorTDVP.jl/pull/74.

mtfishman avatar May 13 '24 22:05 mtfishman