Parameter Optimization
Hamster.run_calculation — Method
run_calculation(::Val{:optimization}, comm, conf::Config; rank=0, nranks=1)Performs the optimization using gradient descent of an effective Hamiltonian model using the specified configuration. The routine iteratively adjusts model parameters to minimize the loss over a training set, while optionally validating performance on a separate validation set.
Workflow
Configuration Sampling
- Partition configuration indices into training (
train_config_inds) and validation (val_config_inds) sets. - Distribute indices among parallel ranks.
- Partition configuration indices into training (
Translation Vectors (if
hr_fit)- Retrieve translation vectors
Rsfor high-rank fitting, used in constructing the Hamiltonian basis.
- Retrieve translation vectors
Training Data Preparation
- Load the training structures (
train_strcs) from the selected configurations. - Construct the corresponding basis functions (
train_bases). - Initialize an
EffectiveHamiltonian(ham_train) with the training data.
- Load the training structures (
Validation Data Preparation
- Load validation structures (
val_strcs) and construct basis functions (val_bases). - Initialize an
EffectiveHamiltonian(ham_val) for validation, including only the relevant data points.
- Load validation structures (
Data Loader and Optimizer Initialization
- Create a
DataLoader(dl) containing training and validation datasets. - Initialize a gradient descent optimizer (
optim) using the extracted training parameters.
- Create a
Profiler Setup
- Create a
HamsterProfiler(prof) to record losses, timings, and parameter evolution during optimization.
- Create a
Model Optimization
- Execute
optimize_model!, iterating over training and validation data to update model parameters. - On rank 0, optionally write optimized parameters to output files.
- Execute
Required Inputs
- Structural configurations:
train_mode = md: seeget_xdatcarandget_sc_poscartrain_mode = pc: seeget_poscar
- Eigenvalue training data: see
get_train_data - Eigenvalue validation data (optional): see
get_val_dataIf not provided, the training data is split according toval_ratio.
Input Tags (Optimizer)
- Configuration tags that specify how optimization is performed (see here).
Output Files
hamster.out— standard Hamster output.hamster_out.h5— HDF5 file containing:- Loss values over iterations
- Timings