WagnerGroup / pyqmc

Python library for real space quantum Monte Carlo
MIT License
82 stars 33 forks source link

Support batch optimization in linemin #429

Closed lkwagner closed 2 months ago

lkwagner commented 8 months ago

After discussion with Will, we came up with the following improvement:

The call signature of line minimimization is:

def line_minimization(
    wf,
    coords,
    pgrad_acc,
    steprange=0.2,
    max_iterations=30,
    warmup_options=None,
    vmcoptions=None,
    lmoptions=None,
    correlatedoptions=None,
    update_kws=None,
    verbose=False,
    npts=5,
    hdf_file=None,
    client=None,
    npartitions=None,
):

The proposed change would allow pgrad_acc (the updater, such as StochasticReconfiguration) to be a list of updater objects. Linemin will proceed as normal except

    for it in range(iteration_offset, max_iterations):

becomes

    for it in range(iteration_offset, max_iterations):
        for micro_it in range(micro_it_offset, len(pgrad_acc)):

The variables now have an extra index; i.e., energy would be [iteration, micro_iteration] and the micro iteration is saved in the HDF5 file.

lkwagner commented 8 months ago

Ah, and gradient_generator can now take a batch parameter which does some reasonable automatic partitioning of batches. I was thinking by key, and anymo_coeff parameters also separated by orbital.

lkwagner commented 2 months ago

Resolved!