QuantumLab-ZY / HamGNN

An E(3) equivariant Graph Neural Network for predicting electronic Hamiltonian matrix
GNU General Public License v3.0
63 stars 15 forks source link

The usage of graph_data_gen #17

Open flamingoXu opened 6 months ago

flamingoXu commented 6 months ago

Dear Zhong Yang when I try to use the model(https://zenodo.org/records/10929472) to predict to Hamiltonian of a twist TMD heterostructure, the program raises an err Traceback (most recent call last): File "/root/anaconda3/envs/GPU/bin/HamGNN", line 33, in <module> sys.exit(load_entry_point('HamGNN==0.1.0', 'console_scripts', 'HamGNN')()) File "/root/anaconda3/envs/GPU/lib/python3.9/site-packages/HamGNN-0.1.0-py3.9.egg/HamGNN/main.py", line 306, in HamGNN train_and_eval(configure) File "/root/anaconda3/envs/GPU/lib/python3.9/site-packages/HamGNN-0.1.0-py3.9.egg/HamGNN/main.py", line 291, in train_and_eval trainer.test(model=model, datamodule=data) File "/root/anaconda3/envs/GPU/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 911, in test return self._call_and_handle_interrupt(self._test_impl, model, dataloaders, ckpt_path, verbose, datamodule) File "/root/anaconda3/envs/GPU/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 685, in _call_and_handle_interrupt return trainer_fn(*args, **kwargs) File "/root/anaconda3/envs/GPU/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 954, in _test_impl results = self._run(model, ckpt_path=self.tested_ckpt_path) File "/root/anaconda3/envs/GPU/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 1199, in _run self._dispatch() File "/root/anaconda3/envs/GPU/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 1275, in _dispatch self.training_type_plugin.start_evaluating(self) File "/root/anaconda3/envs/GPU/lib/python3.9/site-packages/pytorch_lightning/plugins/training_type/training_type_plugin.py", line 206, in start_evaluating self._results = trainer.run_stage() File "/root/anaconda3/envs/GPU/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 1286, in run_stage return self._run_evaluate() File "/root/anaconda3/envs/GPU/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 1328, in _run_evaluate self._evaluation_loop._reload_evaluation_dataloaders() File "/root/anaconda3/envs/GPU/lib/python3.9/site-packages/pytorch_lightning/loops/dataloader/evaluation_loop.py", line 168, in _reload_evaluation_dataloaders self.trainer.reset_test_dataloader() File "/root/anaconda3/envs/GPU/lib/python3.9/site-packages/pytorch_lightning/trainer/data_loading.py", line 568, in reset_test_dataloader self.num_test_batches, self.test_dataloaders = self._reset_eval_dataloader( File "/root/anaconda3/envs/GPU/lib/python3.9/site-packages/pytorch_lightning/trainer/data_loading.py", line 508, in _reset_eval_dataloader if has_len_all_ranks(dataloader, self.training_type_plugin, module) File "/root/anaconda3/envs/GPU/lib/python3.9/site-packages/pytorch_lightning/utilities/data.py", line 118, in has_len_all_ranks raise MisconfigurationException( pytorch_lightning.utilities.exceptions.MisconfigurationException: Total length ofDataloaderacross ranks is zero. Please make sure that it returns at least 1 batch. " the procedure i obtian .npz file is as follows: 1.convert POSCAR to openmx.dat 2.run openmx_postprocess to get overlap.scfout 3.transform the overlap.scfout into graph_date.npz

data.zip Thank you.

QuantumLab-ZY commented 6 months ago

The following parameter is incorrect: scfout_paths: '/root/test/bandprediction/npz/get_overlap.scfout'. scfout_paths should be a path instead of a file name. Your graph_data.npz file did not generate successfully, it is a very small empty file.

flamingoXu commented 6 months ago

Dear Zhong Yang: i had change my file name "get_overlao.scfou" into "get_overlao_scfout" where saves the overlap.scfout, but the problem still exsits.

QuantumLab-ZY commented 6 months ago

How large is the file graph_data.npz that you generated?

flamingoXu commented 6 months ago

the overlap.scfout is over 500M, but npz is only 418B.

QuantumLab-ZY commented 6 months ago

Please check if there are .scfout files and openmx .dat files in the scfout_paths directory.

flamingoXu commented 6 months ago

there is image

QuantumLab-ZY commented 6 months ago

try this std_file_name: null

QuantumLab-ZY commented 6 months ago

null is also None in .yaml file

flamingoXu commented 6 months ago

it seems not works: (GPU) root@bohrium-11924-1124454:~/test/bandpredicton/npz# graph_data_gen --config graph_data_gen.yaml 0%| | 0/1 [00:26<?, ?it/s] Traceback (most recent call last): File "/root/anaconda3/envs/GPU/bin/graph_data_gen", line 33, in <module> sys.exit(load_entry_point('HamGNN==0.1.0', 'console_scripts', 'graph_data_gen')()) File "/root/anaconda3/envs/GPU/lib/python3.9/site-packages/HamGNN-0.1.0-py3.9.egg/utils_openmx/graph_data_gen.py", line 300, in main mask[basis_def[src][:,None], basis_def[src][None,:]] = 1 KeyError: 74

QuantumLab-ZY commented 6 months ago

In fact, it's correct after the correction. The error is that your structure contains the element W, whose atomic number is 74.

QuantumLab-ZY commented 6 months ago

When nao_max is 19, basis_def does not define W. You can use nao_max=26, which includes all the elements supported by openmx. Additionally, this trained model needs to use a value of 26 for nao_max.

flamingoXu commented 6 months ago

after changing the parameter "non_max" to 26, the correct npz file had be obtained. thank you.