cagrikymk / JAX-ReaxFF

JAX-ReaxFF: A Gradient Based Framework for Extremely Fast Optimization of Reactive Force Fields
GNU General Public License v3.0
56 stars 23 forks source link

How to set up the L-BFGS-B and SLSQP methods #9

Open Zyms425 opened 1 year ago

Zyms425 commented 1 year ago

Hello author, I am currently studying your Jax Reaxff and I am not familiar with the L-BFGS-B and SLSQP methods. I have seen that your example submission command is

jaxreaxff --init FF Datasets/cobalt/ffield lit \

--params Datasets/cobalt/params \

--geo Datasets/cobalt/geo \

--train_ file Datasets/cobalt/trainset.in \

--num e minim_ steps 200 \

--e minim LR 1e-3 \

--out_ folder ffields \

--save_ opt all \

--num_ trials 1 \

--num_ steps 20 \

--init FF type fixed \

--backend cpu

How can I use L-BFGS-B and SLSQP methods correctly? If I could get your help, I would be very grateful

cagrikymk commented 1 year ago

Hi, I hardcoded the parameters for the optimizations methods (SLSQP and L-BFGS-B), so you only need to specify the optimization method using --opt_method (--opt_method L-BFGS-B or --opt_method SLSQP).

Also, I highly suggest to use the gpu backend after installing the gpu version of JAX (using --backend GPU).

Zyms425 commented 1 year ago

Hello, excuse me.May I ask this question?

Run-Time and Training Performance Evaluation. In JAX-ReaxFF, as mentioned above, two different gradient- based optimization algorithms are available, L-BFGS-B and SLSQP. For both L-BFGS-B and SLSQP, the maximum number of iterations is set to 100 which is for the step 3 of Algorithm 1 in Scheme 1. For L-BFGS-B, the maximum number of iterations for the line search is set to 20, and the maximum number of variable matrix corrections to approx- imate the Hessian matrix is set to 20. For the rest of the control parameters, the default values from the SciPy library are used. The iteration count for the main optimization loop of Algorithm 1 in Scheme 1 is set to 20 where the local error minimization and the geometry optimization steps are iteratively repeated this many times. Therefore, for all JAX- ReaxFF experiments, the true error calculation with geometry optimization is done 20 times as the local error minimization only uses single step calculations. For experiments reported here, the percentage of the noise used to help escaping the local minima (line 11, Algorithm 1 in Scheme 1) is set to be 0.01%. Increasing the noise can potentially improve the results, but this typically results in higher training times. JAX-ReaxFF was compiled to run in single precision for all experiments except for the disulfide case due to the numerical issues described later. Each training experiment is repeated 10 times, and the lowest and median training errors are reported.

Is the submission command like this: jaxreaxff --init_FF Datasets/Co/ffield_lit             \           --params Datasets/Co/params                  \           --geo Datasets/Co/geo                        \           --train_file Datasets/Co/trainset.in         \ --opt_method  L-BFGS-B\         --num_trials 1\             --num_steps  20\             --rest_search_start  20\             --init_FF_type  fixed\              --num_e_minim_steps   200\              --e_minim_LR  1e-3\              --out_folder   ffieldCo\              --save_opt  all\              --backend  cpu\

jaxreaxff --init_FF Datasets/Co/ffield_lit             \           --params Datasets/Co/params                  \           --geo Datasets/Co/geo                        \           --train_file Datasets/Co/trainset.in         \  --opt_method  SLSQP\          --num_trials 1\             --num_steps  20\             --rest_search_start  20\             --init_FF_type  fixed\              --num_e_minim_steps   200\              --e_minim_LR  1e-3\              --out_folder   ffieldCo\              --save_opt  all\              --backend  cpu\

I don't know if the submission command is correct。

And I am optimizing other force field processes, and the result is nan. What submission commands need to be improved to obtain force field optimization? If I could receive your answer, I would greatly appreciate it.

------------------ 原始邮件 ------------------ 发件人: "cagrikymk/JAX-ReaxFF" @.>; 发送时间: 2023年5月5日(星期五) 上午8:50 @.>; @.**@.>; 主题: Re: [cagrikymk/JAX-ReaxFF] How to set up the L-BFGS-B and SLSQP methods (Issue #9)

Hi, I hardcoded the parameters for the optimizations methods (SLSQP and L-BFGS-B), so you only need to specify the optimization method using --opt_method (--opt_method L-BFGS-B or --opt_method SLSQP).

Also, I highly suggest to use the gpu backend after installing the gpu version of JAX (using --backend GPU).

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

cagrikymk commented 1 year ago

So, you were able to run it for the provided dataset but your own dataset leads to nan values? If that is the case, first thing I suggest is to make sure your parameter ranges are okay. Also, if your starting force field is really unstable, you could run it without energy minimization to get a stable enough force field (not sure if you have data structures that require energy minimization).

If these suggestions are not feasible/does not work, you can use double precision. The current implementation uses single precision for faster convergence but I think it makes sense to change the default to double since the code already runs fast enough. I will change the default precision to double later today.

Zyms425 commented 1 year ago

Dear author: Hello!I would like to ask you how to obtain the gradient graph in the abstract of this paper on jax. Excuse me again, I can't find the data and method for drawing in the file,If you could provide an answer, it would be greatly appreciated

Message ID: @.***>