Skip to content

[Code scan] Align CALYPSO DP optimization default command with prepared model file #352

Description

@njzjz

Found by Codex global repository scan of deepmodeling/dpgen2 at commit 2679611a3704f5c2646c8cb353e34177518db758.

PrepCalyDPOptim first looks for TensorFlow frozen models and symlinks the selected model under that filename:

group_size = ip["template_slice_config"].get("group_size", len(poscar_list))
model_name = "frozen_model.pb"
model_list = [model.resolve() for model in models_dir.rglob(model_name)]
if len(model_list) == 0:
model_name = "model.ckpt.pt"
model_list = [model.resolve() for model in models_dir.rglob(model_name)]
model_list = sorted(model_list, key=lambda x: str(x).split(".")[1])
model_file = model_list[0]

with set_directory(opt_path):
for poscar in _poscar_list:
Path(poscar.name).symlink_to(poscar)
Path(model_name).symlink_to(model_file)
Path(caly_run_opt_file.name).symlink_to(caly_run_opt_file)

But RunCalyDPOptim defaults to a PyTorch checkpoint filename:

config = ip["config"] if ip["config"] is not None else {}
command = config.get(
"run_opt_command", "python -u calypso_run_opt.py model.ckpt.pt"
)
work_dir = Path(ip["task_name"])
with set_directory(work_dir):
# link input files
for ii in input_files:
iname = ii.name
Path(iname).symlink_to(ii)
if finished == "false":
ret, out, err = run_command(command, shell=True)

For the default TensorFlow path, the task directory contains frozen_model.pb, while the default command tries to load model.ckpt.pt. The optimization step fails unless users manually override run_opt_command.

Suggested fix: make the default command match the model file that PrepCalyDPOptim symlinks, or pass the selected model filename explicitly into the generated command.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions