Git Product home page Git Product logo

deeptb's People

Contributors

asymmetrychou avatar baixiaokuang avatar dependabot[bot] avatar floatingcatty avatar njzjz-bot avatar qg-phy avatar qqgu avatar sharplonde avatar shishirkrpandey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

deeptb's Issues

Optimizing eigenvalue parsing in ABACUS calculation

Background

Should support both scf and nscf output. Currently, it only reads the running_scf.log file. It needs to be fixed.

Describe the solution you'd like

Support parsing the nscf output also.

Additional Context

No response

Change the rotation of SK transform into rotation of e3 group

Describe Current Status and Possible Solution

mainly, the change will be focused on the rotation Hamiltonian part, including:

  1. Change transform module to e3 transform, which can support batchlize transformation matrix construction and rotation. The transformation is performed atomwise, or orbital pairwise. It is left to be determined in the implementation.

  2. Change the Hamiltonian construction from onsite and hopping blocks according to the rotation level (e.p. if it is rotated at atom level, then Hamiltonian should be constructed without the functions to get onsite and hopping blocks, and another situation should be discussed later.)

  3. Try to construct and save the rotation matrix in begins of the training, then we need no further rotational matrix construction, but how to achieve this? (If save it in file, then we need to modify the structure class to consistently read files from disk).

  4. try to write a general e3 matrix construction class, which can also be useful in the following development that supports the fitting of various e3 equivariant quantities.

Additional Context

No response

Adding Non-equilibrium Green's Function module into postprocessing of DeePTB

Describe Current Status and Possible Solution

An important application of the Tight-Binding Model is to simulate transport phenomena with Non-equilibrium Green's Function NEGF methods. This module was determined to enable DeePTB to model electronic devices with multiple electrodes and simulate transport properties accurately. Basic sub-modules are:

  1. The NEGF sub-module, which performs the NEGF calculations;
  2. The Lead and Device structure modules, which support modelling Devices with scattering regions that are concatenated with several electrodes. Both periodic systems and confined systems are supported.
  3. The interfaces between the NEGF module and the Postprocessing module of DeePTB.

Additional Context

No response

Export the full trained PyTorch model to device-and-system-independent forms

Background

By "device-and-system-independent forms", I mean a full model (not just its trained parameters) stored in a format that can be imported and used by programming languages other than Python. The format can, but is not limited to, e.g., *.onnx.

Describe the solution you'd like

The present stored model is a *.pth file, which I am not sure is the full model or just the trained parameters. It would be highly appreciated if in just one line of command the *.pth file is transformed into a *.onnx file.

Additional Context

No response

Add support for data batchlization of structures with different shapes of kpoints and eigenvalues.

Background

Now errors will occur when people load the dataset, therefore batching structures with different shapes of points and eigenvalues. This should be supported in the latest updates.

Describe the solution you'd like

This might be resolved by utilizing the nest tensor format. But this would require modification of a lot of data-related things. including but not limited to:

  1. The auto data type checking, including the checking in initialization and checking after batching.
  2. The information generated when doing batchlization, which records how to recover separate subgraphs from the combined batch.
  3. The Cat dims when doing catechization.
  4. The impact of changing the default type of some tensors to nested tensors. This might affect some computation steps, such as the loss function part.
  5. In The data loading part, some values need to be loaded as nested tensors by default.

Additional Context

No response

Add E3NN represent Hamiltonian

Background

to direct learn the Hamiltonian matrix from LCAO DFT packages.

Describe the solution you'd like

add this feature.

Additional Context

No response

CUDA bug

Describe the bug

Trace
.//set.*
.//set.*
.//set.*
initial rotate H or S func.
Traceback (most recent call last):
File "/home/marcel/.local/bin/dptb", line 8, in
sys.exit(main())
File "/home/marcel/.local/lib/python3.10/site-packages/dptb/entrypoints/main.py", line 317, in main
train(**dict_args)
File "/home/marcel/.local/lib/python3.10/site-packages/dptb/entrypoints/train.py", line 276, in train
trainer.run(trainer.num_epoch)
File "/home/marcel/.local/lib/python3.10/site-packages/dptb/nnops/base_trainer.py", line 52, in run
self.train()
File "/home/marcel/.local/lib/python3.10/site-packages/dptb/nnops/train_nnsk.py", line 245, in train
self.optimizer.step(closure)
File "/home/marcel/.local/lib/python3.10/site-packages/torch/optim/lr_scheduler.py", line 68, in wrapper
return wrapped(*args, **kwargs)
File "/home/marcel/.local/lib/python3.10/site-packages/torch/optim/optimizer.py", line 373, in wrapper
out = func(*args, **kwargs)
File "/home/marcel/.local/lib/python3.10/site-packages/torch/optim/optimizer.py", line 76, in _use_grad
ret = func(self, *args, **kwargs)
File "/home/marcel/.local/lib/python3.10/site-packages/torch/optim/adam.py", line 143, in step
loss = closure()
File "/home/marcel/.local/lib/python3.10/site-packages/dptb/nnops/train_nnsk.py", line 229, in closure
pred, label = self.calc(*data, decompose=self.decompose)
File "/home/marcel/.local/lib/python3.10/site-packages/dptb/nnops/train_nnsk.py", line 179, in calc
self.hamileig.get_hs_blocks(bonds_onsite=bond_onsites,
File "/home/marcel/.local/lib/python3.10/site-packages/dptb/hamiltonian/hamil_eig_sk_crt.py", line 276, in get_hs_blocks
onsiteH, onsiteS, bonds_onsite = self.get_hs_onsite(bonds_onsite=bonds_onsite, onsite_envs=onsite_envs)
File "/home/marcel/.local/lib/python3.10/site-packages/dptb/hamiltonian/hamil_eig_sk_crt.py", line 161, in get_hs_onsite
sub_hamil_block[ist:ist+norbi, ist:ist+norbi] = th.eye(norbi, dtype=self.dtype, device=self.device) * self.onsiteEs[ib][indx]
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

Expected behavior

Run using cuda

To Reproduce

input.json:
"device": "cuda",
"dtype": "float32",

Environment

Ubuntu 22.04
pyTorch 2.1

Additional Context

No response

fix error when using e3 module to plot band structure

Describe the bug

The bandstructure plotting function, which uses hr2hk transform, would raise error in e3 module since its data structure usually does not contains soc-related keys. This need to be fixed

Expected behavior

No response

To Reproduce

No response

Environment

No response

Additional Context

No response

KeyError When Accessing '1d' in Dictionary During Checkpoint Loading for NNSK Training

Describe the bug

Traceback (most recent call last):
File "/home/usr/anaconda3/envs/dptb-gpu/bin/dptb", line 8, in
sys.exit(main())
File "/home/usr/anaconda3/envs/dptb-gpu/lib/python3.9/site-packages/dptb/entrypoints/main.py", line 401, in main
train(**dict_args)
File "/home/usr/anaconda3/envs/dptb-gpu/lib/python3.9/site-packages/dptb/entrypoints/train.py", line 186, in train
model = build_model(checkpoint=checkpoint, model_options=jdata["model_options"], common_options=jdata["common_options"], statistics=train_datasets.E3statistics())
File "/home/usr/anaconda3/envs/dptb-gpu/lib/python3.9/site-packages/dptb/nn/build.py", line 172, in build_model
model = NNSK.from_reference(checkpoint, **model_options["nnsk"], **common_options)
File "/home/usr/anaconda3/envs/dptb-gpu/lib/python3.9/site-packages/dptb/nn/nnsk.py", line 531, in from_reference
riorb, rjorb = ref_idp.full_basis_to_basis[iasym][rfiorb], ref_idp.full_basis_to_basis[jasym][rfjorb]
KeyError: '1d'

Expected behavior

Greetings,

I encountered an issue while loading a checkpoint for NNSK training and need some assistance. The problem involves a KeyError when accessing '1d' in a dictionary, which seems to halt the process. I have attached the relevant files and a detailed error log to help reproduce the bug.

Thank you very much for your time and support! Please let me know if there's any more information I can provide or steps I should try.

To Reproduce

ISSUE_01_Basis.zip

Environment

No response

Additional Context

No response

Add get HR example.

Background

need to output the H(R) hamiltonian matrix elements.

Describe the solution you'd like

Creat an example for generating H(R).

Additional Context

No response

Bug in validation

Describe the bug

in train, the validation loss is sum of the loss from all the test data set, which should not be that.

Expected behavior

change to show only one test batch loss.

To Reproduce

No response

Environment

No response

Additional Context

No response

[docs] update deeptb docs

Details

We use the doc template from abacus team, but now we need to update the template to suit our deeptb case.

Add support for fermi level alignment.

Describe Current Status and Possible Solution

Current Status: The NEGF module now attains a constant fermi-energy input for the device and both leads. This is practical when the system is homogeneous and its size is sufficiently large, but it may fail when with confined systems, and Heterogeneous in leads and devices.

Possible Solutions:

  1. We need to define the fermi-energy for devices and leads separately. The tag should be moved from negf's options into its submodule stru_option.
  2. Further, a fermi-level alignment method needs to be implemented. Possible references are ASE.transport module.

Additional Context

No response

refactor dptb test command

Describe Current Status and Possible Solution

now to run dptb test one need to supply input json which should be exactly the same as training input, which should not be!

Additional Context

No response

a unified Data test

Background

In case we add multiple DFT output dependence. A unified test of data parsing and dataset building is essential. The test can be divided into two steps:

  1. The parsing test of each DFT package's interfaces.
  2. The unified test of data set building from parsing results.

Describe the solution you'd like

Implement the function to support this test.

Additional Context

No response

add remove norb in common options.

Background

The basis used in DFT calculations is more than that in the TB model. there are some bands that should be excluded for training the TB model. previously we asked the users to exclude the bands when preparing training data. now we want to set a parameter to control the number of bands or orbitals to be excluded in common options.

Describe the solution you'd like

modify the code to accept the common options.

Additional Context

No response

Optimizing module import

Describe Current Status and Possible Solution

some functions are hidden deep inside modules, but are very useful, they should be initialized in the module init.py so they can be imported more easily.

Additional Context

No response

Use Wannier TB for initial training SK TB parameters.

Background

Usually training the SKTB for the initial TB parameters is quite important and usually not that easy to train. Therefore, we can at least try to use Wannier TB as initialization may be a good starting point.

Describe the solution you'd like

Add this feature and test it with some examples.

Additional Context

No response

test will add new file to tracked files in repository

Describe the bug

when run pytest, it will generate some configure or checkpoint files. these files are already tracked by git. therefore will be updated. This is not needed!

Expected behavior

remove the useless output files from tests in the repository.

To Reproduce

No response

Environment

No response

Additional Context

No response

Training on GPU?

Details

Hello,

I am testing DeepTB on a set of ~5000 structures. I copied an input file from the first step of the BN example and made only small changes for my dataset (paths, atomic species). (I know this set of parameters is not great, I am just trying to make sure I can make the code work on my dataset for now--it already worked on the example).

Because of the dataset size, training with the CPU (the default) is very slow, so I tried training on the GPU by adding "device" : "cuda" to the input json under "common_options".
I then train using dptb train -sk input.json -o ./first > log_first 2>&1 & .

When I do so, the DeepTB crashes with the error RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

Here's the full traceback:

Traceback (most recent call last):
  File "/home/ali/venv3.10-deeptb/bin/dptb", line 8, in <module>
    sys.exit(main())
  File "/home/ali/venv3.10-deeptb/lib/python3.10/site-packages/dptb/entrypoints/main.py", line 317, in main
    train(**dict_args)
  File "/home/ali/venv3.10-deeptb/lib/python3.10/site-packages/dptb/entrypoints/train.py", line 276, in train
    trainer.run(trainer.num_epoch)
  File "/home/ali/venv3.10-deeptb/lib/python3.10/site-packages/dptb/nnops/base_trainer.py", line 52, in run
    self.train()
  File "/home/ali/venv3.10-deeptb/lib/python3.10/site-packages/dptb/nnops/train_nnsk.py", line 245, in train
    self.optimizer.step(closure)
  File "/home/ali/venv3.10-deeptb/lib/python3.10/site-packages/torch/optim/lr_scheduler.py", line 69, in wrapper
    return wrapped(*args, **kwargs)
  File "/home/ali/venv3.10-deeptb/lib/python3.10/site-packages/torch/optim/optimizer.py", line 280, in wrapper
    out = func(*args, **kwargs)
  File "/home/ali/venv3.10-deeptb/lib/python3.10/site-packages/torch/optim/optimizer.py", line 33, in _use_grad
    ret = func(self, *args, **kwargs)
  File "/home/ali/venv3.10-deeptb/lib/python3.10/site-packages/torch/optim/adam.py", line 121, in step
    loss = closure()
  File "/home/ali/venv3.10-deeptb/lib/python3.10/site-packages/dptb/nnops/train_nnsk.py", line 229, in closure
    pred, label = self.calc(*data, decompose=self.decompose)
  File "/home/ali/venv3.10-deeptb/lib/python3.10/site-packages/dptb/nnops/train_nnsk.py", line 179, in calc
    self.hamileig.get_hs_blocks(bonds_onsite=bond_onsites,
  File "/home/ali/venv3.10-deeptb/lib/python3.10/site-packages/dptb/hamiltonian/hamil_eig_sk_crt.py", line 276, in get_hs_blocks
    onsiteH, onsiteS, bonds_onsite = self.get_hs_onsite(bonds_onsite=bonds_onsite, onsite_envs=onsite_envs)
  File "/home/ali/venv3.10-deeptb/lib/python3.10/site-packages/dptb/hamiltonian/hamil_eig_sk_crt.py", line 161, in get_hs_onsite
    sub_hamil_block[ist:ist+norbi, ist:ist+norbi] = th.eye(norbi, dtype=self.dtype, device=self.device) * self.onsiteEs[ib][indx]
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

Here is my full input file (renamed to .txt because github does not allow me to upload .json):
input.txt

Is there an error in my input file? Or is the way to train on a GPU different from the one I tried?

Thanks!
-Ali

Optimizing data difference between dataset building and AtomicData.from_points/from_ase/...

Background

The user often uses the latter api to perform calculations on jupyter notebook, however, it does not have some vital properties as the one gets from AtomicData built from dataset. Including:

  1. some initialized node/edge/overlap features
  2. SOC related features
  3. atom/bond type features that are mapped from idp.

This is very hurtful since the user tends not to know where the AtomicData are getting from,causing troubles for our daily usage.

Describe the solution you'd like

Figure out a way to optimizing this, either by unify the process of getting atomic data class, or making the dependence on the parameters such as SOC and bond/atom type implicit.

Additional Context

No response

Refactoring the data module

Describe Current Status and Possible Solution

For better fitting to the graph-based network, and enabling GPU and multi workers penalization, it is a common requirement to refactoring the data module with original packages supported by pytorch. To do so, we need to:

reframe structure(BaseStructure) class using torch-geometric.data.

instead of using processor, rewrote the function with datasets, inmemory datasets and dataloader with pytorch and torch-geomeric

Additional Context

No response

Add support for NRL TB formula.

Background

NRL TB is short for Naval Research Laboratory Tight-Binding models, that were popularly used. There are many existing SKTB model parameters. The DeePTB framework is flexible and in principle can easily support the formula of NRL-TB. If we do so, we can immediately have all the NRL- TB parameters as our models for further investigation.

Describe the solution you'd like

add this feature asap.

Additional Context

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.