-
Notifications
You must be signed in to change notification settings - Fork 198
feat: support DPA4 and DPA4C model formats #1926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
1591ecf
ff667d3
4374ce7
1ad5296
40adff3
bbdb223
95c0339
c4de737
8c52d30
eb9aedd
5368e55
2c633cc
d481bfb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,7 +59,7 @@ def make_lammps_input( | |
| while power < nbeads: | ||
| power *= 10 | ||
| ret += "variable ibead uloop %d pad\n" % (power - 1) # noqa: UP031 | ||
| if nbeads is not None: | ||
| if nbeads is not None or jdata.get("model_format") == "pt2": | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P1] The resolved default PT2 path still misses atom mapping in native generated inputs.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in c4de737. The native generation path now passes the resolved deployment format derived from |
||
| ret += "atom_modify map yes\n" | ||
| ret += "variable THERMO_FREQ equal %d\n" % trj_freq # noqa: UP031 | ||
| ret += "variable DUMP_FREQ equal %d\n" % trj_freq # noqa: UP031 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,8 +29,27 @@ | |
| calypso_model_devi_name = "model_devi_results" | ||
|
|
||
|
|
||
| def _find_models(path, model_suffix=".pb"): | ||
| """Return model-deviation artifacts for the resolved deployment format.""" | ||
| return glob.glob(os.path.join(path, f"graph*{model_suffix}")) | ||
|
|
||
|
|
||
| def _make_calypso_opt_command(deepmdkit_python, model_name): | ||
| """Return the CALYPSO optimization command for the resolved model.""" | ||
| return ( | ||
| f"{deepmdkit_python} calypso_run_opt.py --model ../{model_name} " | ||
| "1>> model_devi.log 2>> model_devi.log" | ||
| ) | ||
|
|
||
|
|
||
| def gen_structures( | ||
| iter_index, jdata, mdata, caly_run_path, current_idx, length_of_caly_runopt_list | ||
| iter_index, | ||
| jdata, | ||
| mdata, | ||
| caly_run_path, | ||
| current_idx, | ||
| length_of_caly_runopt_list, | ||
| model_suffix=".pb", | ||
| ): | ||
| # run calypso | ||
| # vsc means generate elemental, binary and ternary at the same time | ||
|
|
@@ -50,13 +69,11 @@ def gen_structures( | |
| calypso_path = mdata.get("model_devi_calypso_path") | ||
| # calypso_input_path = jdata.get('calypso_input_path') | ||
|
|
||
| all_models = glob.glob(os.path.join(calypso_run_opt_path, "graph*pb")) | ||
| all_models = _find_models(calypso_run_opt_path, model_suffix) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This now discovers and forwards
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in d481bfb. CALYPSO optimization submissions now pass the first resolved committee model as --model ../graph.000., and calypso_run_opt.py uses that argument while retaining ../graph.000.pb as its backward-compatible default. The regression test covers a graph.000.pt2 submission command. Validation: 10 focused backend/CALYPSO tests passed and all pre-commit hooks passed. |
||
| model_names = [os.path.basename(ii) for ii in all_models] | ||
|
|
||
| deepmdkit_python = mdata.get("model_devi_deepmdkit_python") | ||
| command = ( | ||
| f"{deepmdkit_python} calypso_run_opt.py 1>> model_devi.log 2>> model_devi.log" | ||
| ) | ||
| command = _make_calypso_opt_command(deepmdkit_python, sorted(model_names)[0]) | ||
| # command = "%s calypso_run_opt.py %s 1>> model_devi.log 2>> model_devi.log" % (deepmdkit_python,os.path.abspath(calypso_run_opt_path)) | ||
| # command += " || %s check_outcar.py %s " % (deepmdkit_python,os.path.abspath(calypso_run_opt_path)) | ||
| command += f" || {deepmdkit_python} check_outcar.py " | ||
|
|
@@ -335,7 +352,7 @@ def gen_structures( | |
| os.chdir(cwd) | ||
|
|
||
|
|
||
| def gen_main(iter_index, jdata, mdata, caly_run_opt_list, gen_idx): | ||
| def gen_main(iter_index, jdata, mdata, caly_run_opt_list, gen_idx, model_suffix=".pb"): | ||
| iter_name = make_iter_name(iter_index) | ||
| work_path = os.path.join(iter_name, model_devi_name) | ||
|
|
||
|
|
@@ -353,7 +370,13 @@ def gen_main(iter_index, jdata, mdata, caly_run_opt_list, gen_idx): | |
| for iidx, temp_path in enumerate(caly_run_opt_list): | ||
| if iidx >= indice: | ||
| gen_structures( | ||
| iter_index, jdata, mdata, temp_path, iidx, len(caly_run_opt_list) | ||
| iter_index, | ||
| jdata, | ||
| mdata, | ||
| temp_path, | ||
| iidx, | ||
| len(caly_run_opt_list), | ||
| model_suffix=model_suffix, | ||
| ) | ||
|
|
||
|
|
||
|
|
@@ -448,7 +471,7 @@ def analysis(iter_index, jdata, calypso_model_devi_path): | |
| os.chdir(cwd) | ||
|
|
||
|
|
||
| def run_calypso_model_devi(iter_index, jdata, mdata): | ||
| def run_calypso_model_devi(iter_index, jdata, mdata, model_suffix=".pb"): | ||
| dlog.info("start running CALYPSO") | ||
|
|
||
| iter_name = make_iter_name(iter_index) | ||
|
|
@@ -483,7 +506,14 @@ def run_calypso_model_devi(iter_index, jdata, mdata): | |
| if lines[-1].strip().strip("\n").split()[0] == "1": | ||
| # Gen Structures | ||
| gen_index = lines[-1].strip().strip("\n").split()[1] | ||
| gen_main(iter_index, jdata, mdata, caly_run_opt_list, gen_index) | ||
| gen_main( | ||
| iter_index, | ||
| jdata, | ||
| mdata, | ||
| caly_run_opt_list, | ||
| gen_index, | ||
| model_suffix=model_suffix, | ||
| ) | ||
|
|
||
| elif lines[-1].strip().strip("\n") == "2": | ||
| # Analysis & to deepmd/raw | ||
|
|
@@ -492,7 +522,7 @@ def run_calypso_model_devi(iter_index, jdata, mdata): | |
| elif lines[-1].strip().strip("\n") == "3": | ||
| # Model Devi | ||
| _calypso_run_opt_path = os.path.abspath(caly_run_opt_list[0]) | ||
| all_models = glob.glob(os.path.join(_calypso_run_opt_path, "graph*pb")) | ||
| all_models = _find_models(_calypso_run_opt_path, model_suffix) | ||
| cwd = os.getcwd() | ||
| os.chdir(calypso_model_devi_path) | ||
| args = " ".join( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] This only fixes native inputs built by
make_lammps_input. Themodel_devi_jobs[].templatepath copies and revises the user template via_make_model_devi_revmatand never calls this function, so a.pt2template without its ownatom_modify map yesstill reaches LAMMPS and fails. Please insert or validate the command beforeread_data/read_restartin the template workflow too, and cover that path with a test.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in bbdb223. The
revise_templatepath now validates thatatom_modify map yesappears beforeread_dataorread_restartfor.pt2, with both focused unit coverage and an integration test throughmake_model_devi.