qmctorch.solver.solver_base module

class qmctorch.solver.solver_base.SolverBase(wf=None, sampler=None, optimizer=None, scheduler=None, output=None, rank=0)[source]

Bases: object

Base Class for QMC solver

Parameters:
  • wf (qmctorch.WaveFunction, optional) – wave function. Defaults to None.

  • sampler (qmctorch.sampler, optional) – Sampler. Defaults to None.

  • optimizer (torch.optim, optional) – optimizer. Defaults to None.

  • scheduler (torch.optim, optional) – scheduler. Defaults to None.

  • output (str, optional) – hdf5 filename. Defaults to None.

  • rank (int, optional) – rank of he process. Defaults to 0.

configure_resampling(mode='update', resample_every=1, nstep_update=25)[source]

Configure the resampling

Parameters:
  • mode (str, optional) – method to resample : ‘full’, ‘update’, ‘never’ Defaults to ‘update’.

  • resample_every (int, optional) – Number of optimization steps between resampling Defaults to 1.

  • nstep_update (int, optional) – Number of MC steps in update mode. Defaults to 25.

track_observable(obs_name)[source]

define the observalbe we want to track

Parameters:

obs_name (list) – list of str defining the observalbe. Each str must correspond to a WaveFuncion method

store_observable(pos, local_energy=None, ibatch=None, **kwargs)[source]

store observale in the dictionary

Parameters:
  • obs_dict (dict) – dictionary of the observalbe

  • pos (torch.tensor) – positions of th walkers

  • local_energy (torch.tensor, optional) – precomputed values of the local energy. Defaults to None

  • ibatch (int) – index of the current batch. Defaults to None

print_observable(cumulative_loss, verbose=False)[source]

Print the observalbe to csreen

Parameters:
  • cumulative_loss (float) – current loss value

  • verbose (bool, optional) – print all the observables. Defaults to False

resample(n, pos)[source]

Resample the wave function

Parameters:
  • n (int) – current epoch value

  • pos (torch.tensor) – positions of the walkers

Returns:

new positions of the walkers

Return type:

(torch.tensor)

single_point(with_tqdm=True, hdf5_group='single_point')[source]

Performs a single point calculatin

Parameters:
  • with_tqdm (bool, optional) – use tqdm for samplig. Defaults to True.

  • hdf5_group (str, optional) – hdf5 group where to store the data. Defaults to ‘single_point’.

Returns:

contains the local energy, positions, …

Return type:

SimpleNamespace

save_checkpoint(epoch, loss)[source]

save the model and optimizer state

Parameters:
  • epoch (int) – epoch

  • loss (float) – current value of the loss

  • filename (str) – name to save the file

load_checkpoint(filename)[source]

load a model/optmizer

Parameters:

filename (str) – filename

Returns:

epoch number and loss

Return type:

tuple

sampling_traj(pos=None, with_tqdm=True, hdf5_group='sampling_trajectory')[source]

Compute the local energy along a sampling trajectory

Parameters:
  • pos (torch.tensor) – positions of the walkers along the trajectory

  • hdf5_group (str, optional) – name of the group where to store the data. Defaults to ‘sampling_trajecory’

Returns:

contains energy/positions/

Return type:

SimpleNamespace

print_parameters(grad=False)[source]

print parameter values

Parameters:

grad (bool, optional) – also print the gradient. Defaults to False.

optimization_step(lpos)[source]

Performs one optimization step

Parameters:

walkers (lpos {torch.tensor} -- positions of the) –

save_traj(fname, obs)[source]

Save trajectory of geo_opt

Parameters:

fname (str) – file name

run(nepoch, batchsize=None, loss='variance')[source]
log_data()[source]

Log basic information about the sampler.