deepmodeling / deepmodeling/DeePTB

Unable to export trained model to Hamiltonian for use with other code (write_sk empty, export to PythTB hangs)

Open
#335 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
122
Forks
36
PR merge metrics
No merged PRs in 30d

Description

### Details

Hi,

I have successfully trained a model starting from an initial .skf file. The training and evaluation steps work as expected in DeePTB.

However, I am struggling to export the trained model in a usable form to other codes. I tried using the built-in write_sk task but it produces an empty output directory (no .skf files are written).

Ideally, I would like to be able to export the trained model in a way that allows full reuse outside the training framework. In particular, I would ideally like to extract the full Hamiltonian (or equivalent tight-binding representation), preferably as a sparse matrix.

If that is not possible, exporting the trained parameters back into a valid .skf to use in DFTB+ would also be acceptable.

I also attempted to export the model into a PythTB representation following the documentation:

"""
root_dir = os.path.abspath(".")
model_path = os.path.join("./nnsk_corrected/checkpoint/nnsk.best.pth")
struct_path = os.path.join("POSCAR")

import torch
from dptb.postprocess import ToPythTB

print(f"Loading model from {model_path}...")

model = build_model(model_path)
model.eval()
print(f"Model loaded on {model.device}")

exporter = ToPythTB(model, device=model.device)
print("Exporter initialized.")

print("Exporting to PythTB...")
tb_model = exporter.get_model(struct_path)
print("Successfully exported!")
print(tb_model)
"""

However, the process appears to hang indefinitely at the exporter.get_model(struct_path) step with no error message or output. It could be that the exporter is very slow would it be normal for the process to take more than an hour for a system with Ag Ico system with 561 atoms? (The model is loaded and was trained on cuda:0 not cpu which also seems to cause some problems)

Is there currently a supported way to extract the full Hamiltonian from a trained model?

Any guidance would be appreciated.

Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.