-
Notifications
You must be signed in to change notification settings - Fork 575
Description
Bug summary
When compiling the C++ part of DeePMD-kit from source against a recent version of TensorFlow, a large number of deprecation warnings (-Wdeprecated-declarations
) are generated.
The warnings indicate that the TensorFlow custom operations in deepmd-kit
are using the deprecated error handling function tsl::errors::InvalidArgument
. The compiler suggests using absl::InvalidArgumentError
instead.
Although the compilation succeeds, it would be beneficial to update the API calls to ensure future compatibility with upcoming TensorFlow versions and to provide a cleaner build experience for users.
DeePMD-kit Version
latest of branch devel
Backend and its version
tf: 2.20.0
How did you download the software?
Built from source
Input Files, Running Commands, Error Log, etc.
Installation command:
cmake -DENABLE_TENSORFLOW=ON -DUSE_TF_PYTHON_LIBS=ON -DENABLE_PYTORCH=ON -DUSE_PT_PYTHON_LIBS=ON -DENABLE_JAX=ON -DUSE_CUDA_TOOLKIT=ON -DENABLE_NATIVE_OPTIMIZATION=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_INSTALL_PREFIX=$deepmd_root -DCMAKE_PREFIX_PATH=$CONDA_PREFIX ..
make -j && make install
Error Log (Warnings):
The log is very long, here is a representative snippet. The warnings are all similar, pointing to the usage of a deprecated function.
/home/outis/Software/deepmd-kit/source/op/tf/tabulate_multi_device.cc:722:40: warning: 'absl::lts_20250127::Status tsl::errors::InvalidArgument(Args ...) [with Args = {const char*}]' is deprecated: Use absl::InvalidArgumentError() instead. [-Wdeprecated-declarations]
722 | errors::InvalidArgument("Dim of input should be 3"));
| ^
/home/outis/miniforge3/envs/dpmd/lib/python3.13/site-packages/tensorflow/include/xla/tsl/platform/errors.h:219:14: note: declared here
219 | absl::Status InvalidArgument(Args... args) {
| ^~~~~~~~~~~~~~~
...
/home/outis/Software/deepmd-kit/source/op/tf/unaggregated_grad.cc: In member function 'void UnaggregatedDyDxSOp<Device, FPTYPE>::_Compute(tensorflow::OpKernelContext*)':
/home/outis/Software/deepmd-kit/source/op/tf/unaggregated_grad.cc:308:40: warning: 'absl::lts_20250127::Status tsl::errors::InvalidArgument(Args ...) [with Args = {const char*}]' is deprecated: Use absl::InvalidArgumentError() instead. [-Wdeprecated-declarations]
308 | errors::InvalidArgument("Dim of input should be 2"));
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/outis/miniforge3/envs/dpmd/lib/python3.13/site-packages/tensorflow/include/tsl/platform/errors.h:19,
...
/home/outis/miniforge3/envs/dpmd/lib/python3.13/site-packages/tensorflow/include/xla/tsl/platform/errors.h:219:14: note: declared here
219 | absl::Status InvalidArgument(Args... args) {
| ^~~~~~~~~~~~~~~
# [... The log continues with hundreds of similar warnings for different source files and templates ...]
Steps to Reproduce
build from source
Further Information, Files, and Links
This issue seems to be purely a matter of API evolution within TensorFlow. The old tsl::errors::InvalidArgument function is being phased out in favor of absl::InvalidArgumentError. A simple find-and-replace in the affected C++ source files within source/op/tf/ should resolve these warnings. The build is currently successful, so this is not a critical, build-breaking bug, but rather a maintenance task for code hygiene and forward compatibility.