Skip to content

[BUG] Training long range model #1254

Description

@salinelake

Summary

The newly released DP-kit v2.0.3 (offline package installed through conda) seems to introduce a bug to the training of long range model. The same script runs OK with a beta (perhaps beta4) version of DP-kit and the DP/Dipole model trained accordingly.

The data_modifier part I added to a usual training script:
"modifier": {
"type": "dipole_charge",
"model_name": "dipole.pb",
"model_charge_map": [-22],
"sys_charge_map": [3, 7, 6],
"ewald_h": 1.0,
"ewald_beta": 0.40
},

Error Log:

Traceback (most recent call last):
File "/home/someone/data.gpfs/envs/deepmd203/bin/dp", line 10, in
sys.exit(main())
File "/home/someone/data.gpfs/envs/deepmd203/lib/python3.9/site-packages/deepmd/entrypoints/main.py", line 437, in main
train_dp(**dict_args)
File "/home/someone/data.gpfs/envs/deepmd203/lib/python3.9/site-packages/deepmd/entrypoints/train.py", line 103, in train
_do_work(jdata, run_opt, is_compress)
File "/home/someone/data.gpfs/envs/deepmd203/lib/python3.9/site-packages/deepmd/entrypoints/train.py", line 159, in _do_work
model.build(train_data, stop_batch)
File "/home/someone/data.gpfs/envs/deepmd203/lib/python3.9/site-packages/deepmd/train/trainer.py", line 275, in build
self.model.data_stat(data)
File "/home/someone/data.gpfs/envs/deepmd203/lib/python3.9/site-packages/deepmd/model/ener.py", line 91, in data_stat
all_stat = make_stat_input(data, self.data_stat_nbatch, merge_sys = False)
File "/home/someone/data.gpfs/envs/deepmd203/lib/python3.9/site-packages/deepmd/model/model_stat.py", line 38, in make_stat_input
stat_data = data.get_batch (sys_idx = ii)
File "/home/someone/data.gpfs/envs/deepmd203/lib/python3.9/site-packages/deepmd/utils/data_system.py", line 329, in get_batch
self._make_default_mesh()
File "/home/someone/data.gpfs/envs/deepmd203/lib/python3.9/site-packages/deepmd/utils/data_system.py", line 179, in _make_default_mesh
test_system_data = self.data_systems[ii].get_batch(self.batch_size[ii])
File "/home/someone/data.gpfs/envs/deepmd203/lib/python3.9/site-packages/deepmd/utils/data.py", line 216, in get_batch
self.modifier.modify_data(self.batch_set)
File "/home/someone/data.gpfs/envs/deepmd203/lib/python3.9/site-packages/deepmd/infer/data_modifier.py", line 420, in modify_data
tot_e, tot_f, tot_v = self.eval(coord, box, atype)
File "/home/someone/data.gpfs/envs/deepmd203/lib/python3.9/site-packages/deepmd/infer/data_modifier.py", line 279, in eval
self.force, self.virial, self.av = self.build_fv_graph()
File "/home/someone/data.gpfs/envs/deepmd203/lib/python3.9/site-packages/deepmd/infer/data_modifier.py", line 99, in build_fv_graph
return self._build_fv_graph_inner()
File "/home/someone/data.gpfs/envs/deepmd203/lib/python3.9/site-packages/deepmd/infer/data_modifier.py", line 125, in _build_fv_graph_inner
self.t_tensor_reshpe = self._enrich(self.t_tensor_reshpe, dof = 3)
File "/home/someone/data.gpfs/envs/deepmd203/lib/python3.9/site-packages/deepmd/infer/data_modifier.py", line 194, in _enrich
di = tf.zeros([tf.shape(dipole)[0], self.t_natoms[2+type_i] * dof],
File "/home/someone/data.gpfs/envs/deepmd203/lib/python3.9/site-packages/tensorflow/python/util/dispatch.py", line 206, in wrapper
return target(*args, **kwargs)
File "/home/someone/data.gpfs/envs/deepmd203/lib/python3.9/site-packages/tensorflow/python/ops/array_ops.py", line 2911, in wrapped
tensor = fun(*args, **kwargs)
File "/home/someone/data.gpfs/envs/deepmd203/lib/python3.9/site-packages/tensorflow/python/ops/array_ops.py", line 2960, in zeros
output = _constant_if_small(zero, shape, dtype, name)
File "/home/someone/data.gpfs/envs/deepmd203/lib/python3.9/site-packages/tensorflow/python/ops/array_ops.py", line 2896, in _constant_if_small
if np.prod(shape) < 1000:
File "<array_function internals>", line 5, in prod
File "/home/someone/data.gpfs/envs/deepmd203/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 3051, in prod
return _wrapreduction(a, np.multiply, 'prod', axis, dtype, out,
File "/home/someone/data.gpfs/envs/deepmd203/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 86, in _wrapreduction
return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
File "/home/someone/data.gpfs/envs/deepmd203/lib/python3.9/site-packages/tensorflow/python/framework/ops.py", line 867, in array
raise NotImplementedError(
NotImplementedError: Cannot convert a symbolic Tensor (strided_slice_1:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported

Contact me if this needs to be reproduced.

Metadata

Metadata

Assignees

No one assigned

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions