-
Notifications
You must be signed in to change notification settings - Fork 526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pt: support dpa2 model parallel inference #3657
Conversation
for more information, see https://pre-commit.ci
TODO: add ut |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
|
||
int** recvlist = reinterpret_cast<int**>(sendlist_tensor.data_ptr()); | ||
// swap send and recv here | ||
int* recvproc = sendproc_tensor.data_ptr<int>(); |
Check notice
Code scanning / CodeQL
Unused local variable Note
sendnum_tensor, recvnum_tensor, communicator_tensor, | ||
nlocal_tensor, nghost_tensor}); | ||
int** sendlist = reinterpret_cast<int**>(sendlist_tensor.data_ptr()); | ||
int* sendproc = sendproc_tensor.data_ptr<int>(); |
Check notice
Code scanning / CodeQL
Unused local variable Note
nlocal_tensor, nghost_tensor}); | ||
int** sendlist = reinterpret_cast<int**>(sendlist_tensor.data_ptr()); | ||
int* sendproc = sendproc_tensor.data_ptr<int>(); | ||
int* recvproc = recvproc_tensor.data_ptr<int>(); |
Check notice
Code scanning / CodeQL
Unused local variable Note
communicator_tensor, nlocal_tensor, nghost_tensor); | ||
} | ||
|
||
TORCH_LIBRARY_FRAGMENT(deepmd, m) { m.def("border_op", border_op); } |
Check notice
Code scanning / CodeQL
Unused static function Note
TORCH_LIBRARY_FRAGMENT_static_init_deepmd_2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstr of comm_dict
missed in all the python classes.
I am unable to compile
The error is related to these two lines: It seems
My environment is:
This might related to: https://stackoverflow.com/questions/67584843/pytorch-tensordata-ptrlong-long-not-working-on-linux |
@chazeon could you send a PR? In a 64-bit system, |
deepmd-kit/source/api_cc/src/DeepPotPT.cc Lines 199 to 213 in ebd809b
|
Following the discussion in #3657 this pull request addresses the usage of `long` or `long int` by replacing them with `int64_t` in multiple instances. This change aims to enhance code compatibility across different platforms and improve code clarity. The `int64_t` type is a feature introduced in C++11, defined in the [`<cstdint>`](https://en.cppreference.com/w/cpp/header/cstdint) header. Due to historical reasons, the compilation behavior of `int64_t` is platform- and system-specific. On Linux, `int64_t` is compiled to `long`, whereas on macOS, it's compiled to `long long`. In relevant codebases such as PyTorch and TensorFlow, `int64_t` is preferred over explicit declarations of `long` or `long long`. Consequently, for precompiled libraries, on Linux, symbols are defined exclusively to `long`, while on macOS, symbols are defined exclusively based on `long long`. For these reasons, `data_ptr<long int>()` is unable to compile on macOS. ## References * https://stackoverflow.com/questions/67584843/pytorch-tensordata-ptrlong-long-not-working-on-linux * https://github.com/llvm/llvm-project/blob/c7910ee1f0af64501bf068cdfec154ea359ff832/clang/test/Preprocessor/init.c ## Examples ### Example 1 For the code used here, `torch::from_blob`, is defined using ```cpp inline at::Tensor from_blob( void* data, at::IntArrayRef sizes, const at::TensorOptions& options = at::TensorOptions()) { ``` where `IntArrayRef` is defined as ```cpp using IntArrayRef = c10::ArrayRef<int64_t>; ``` ### Example 2 Dumping the symbols in `libtorch_cpu.dylib` on macOS ``` -> % nm -gU libtorch_cpu.dylib | llvm-cxxfilt | grep TensorBase | grep ::data_ptr 0000000002153398 T c10::Float8_e5m2* at::TensorBase::data_ptr<c10::Float8_e5m2>() const 0000000002153524 T c10::Float8_e4m3fn* at::TensorBase::data_ptr<c10::Float8_e4m3fn>() const 0000000002152738 T c10::Half* at::TensorBase::data_ptr<c10::Half>() const 00000000021536b0 T c10::qint8* at::TensorBase::data_ptr<c10::qint8>() const 00000000021539c8 T c10::qint32* at::TensorBase::data_ptr<c10::qint32>() const 000000000215383c T c10::quint8* at::TensorBase::data_ptr<c10::quint8>() const 0000000002152bdc T c10::complex<c10::Half>* at::TensorBase::data_ptr<c10::complex<c10::Half>>() const 0000000002152ef4 T c10::complex<double>* at::TensorBase::data_ptr<c10::complex<double>>() const 0000000002152d68 T c10::complex<float>* at::TensorBase::data_ptr<c10::complex<float>>() const 000000000215320c T c10::BFloat16* at::TensorBase::data_ptr<c10::BFloat16>() const 0000000002153ce0 T c10::quint2x4* at::TensorBase::data_ptr<c10::quint2x4>() const 0000000002153b54 T c10::quint4x2* at::TensorBase::data_ptr<c10::quint4x2>() const 0000000002152108 T signed char* at::TensorBase::data_ptr<signed char>() const 0000000002153080 T bool* at::TensorBase::data_ptr<bool>() const 0000000002152a50 T double* at::TensorBase::data_ptr<double>() const 00000000021528c4 T float* at::TensorBase::data_ptr<float>() const 0000000002151f7c T unsigned char* at::TensorBase::data_ptr<unsigned char>() const 0000000002152420 T int* at::TensorBase::data_ptr<int>() const 0000000002152294 T short* at::TensorBase::data_ptr<short>() const 00000000021525ac T long long* at::TensorBase::data_ptr<long long>() const ``` dumping symbols in `libtorch_cpu.dylib` on Linux ``` -> % nm -gU libtorch_cpu.so | c++filt | grep TensorBase | grep ::data_ptr 00000000031ec0d0 T c10::Float8_e5m2* at::TensorBase::data_ptr<c10::Float8_e5m2>() const 00000000031ec2f0 T c10::Float8_e4m3fn* at::TensorBase::data_ptr<c10::Float8_e4m3fn>() const 00000000031ec730 T c10::Float8_e4m3fnuz* at::TensorBase::data_ptr<c10::Float8_e4m3fnuz>() const 00000000031ec510 T c10::Float8_e5m2fnuz* at::TensorBase::data_ptr<c10::Float8_e5m2fnuz>() const 00000000031eb030 T c10::Half* at::TensorBase::data_ptr<c10::Half>() const 00000000031ec950 T c10::qint8* at::TensorBase::data_ptr<c10::qint8>() const 00000000031ecd80 T c10::qint32* at::TensorBase::data_ptr<c10::qint32>() const 00000000031ecb70 T c10::quint8* at::TensorBase::data_ptr<c10::quint8>() const 00000000031eb660 T c10::complex<c10::Half>* at::TensorBase::data_ptr<c10::complex<c10::Half> >() const 00000000031eba80 T c10::complex<double>* at::TensorBase::data_ptr<c10::complex<double> >() const 00000000031eb870 T c10::complex<float>* at::TensorBase::data_ptr<c10::complex<float> >() const 00000000031ebeb0 T c10::BFloat16* at::TensorBase::data_ptr<c10::BFloat16>() const 00000000031ed1c0 T c10::quint2x4* at::TensorBase::data_ptr<c10::quint2x4>() const 00000000031ecfa0 T c10::quint4x2* at::TensorBase::data_ptr<c10::quint4x2>() const 00000000031ea7f0 T signed char* at::TensorBase::data_ptr<signed char>() const 00000000031ebca0 T bool* at::TensorBase::data_ptr<bool>() const 00000000031eb450 T double* at::TensorBase::data_ptr<double>() const 00000000031eb240 T float* at::TensorBase::data_ptr<float>() const 00000000031ea5d0 T unsigned char* at::TensorBase::data_ptr<unsigned char>() const 00000000031eac10 T int* at::TensorBase::data_ptr<int>() const 00000000031ed5e0 T unsigned int* at::TensorBase::data_ptr<unsigned int>() const 00000000031eae20 T long* at::TensorBase::data_ptr<long>() const 00000000031ed7f0 T unsigned long* at::TensorBase::data_ptr<unsigned long>() const 00000000031eaa00 T short* at::TensorBase::data_ptr<short>() const 00000000031ed3d0 T unsigned short* at::TensorBase::data_ptr<unsigned short>() const ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Improved data type consistency across various components for handling larger data sizes more reliably. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Signed-off-by: Jinzhe Zeng <[email protected]> Signed-off-by: Lysithea <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jinzhe Zeng <[email protected]> Co-authored-by: Han Wang <[email protected]>
Following the discussion in deepmodeling#3657 this pull request addresses the usage of `long` or `long int` by replacing them with `int64_t` in multiple instances. This change aims to enhance code compatibility across different platforms and improve code clarity. The `int64_t` type is a feature introduced in C++11, defined in the [`<cstdint>`](https://en.cppreference.com/w/cpp/header/cstdint) header. Due to historical reasons, the compilation behavior of `int64_t` is platform- and system-specific. On Linux, `int64_t` is compiled to `long`, whereas on macOS, it's compiled to `long long`. In relevant codebases such as PyTorch and TensorFlow, `int64_t` is preferred over explicit declarations of `long` or `long long`. Consequently, for precompiled libraries, on Linux, symbols are defined exclusively to `long`, while on macOS, symbols are defined exclusively based on `long long`. For these reasons, `data_ptr<long int>()` is unable to compile on macOS. ## References * https://stackoverflow.com/questions/67584843/pytorch-tensordata-ptrlong-long-not-working-on-linux * https://github.com/llvm/llvm-project/blob/c7910ee1f0af64501bf068cdfec154ea359ff832/clang/test/Preprocessor/init.c ## Examples ### Example 1 For the code used here, `torch::from_blob`, is defined using ```cpp inline at::Tensor from_blob( void* data, at::IntArrayRef sizes, const at::TensorOptions& options = at::TensorOptions()) { ``` where `IntArrayRef` is defined as ```cpp using IntArrayRef = c10::ArrayRef<int64_t>; ``` ### Example 2 Dumping the symbols in `libtorch_cpu.dylib` on macOS ``` -> % nm -gU libtorch_cpu.dylib | llvm-cxxfilt | grep TensorBase | grep ::data_ptr 0000000002153398 T c10::Float8_e5m2* at::TensorBase::data_ptr<c10::Float8_e5m2>() const 0000000002153524 T c10::Float8_e4m3fn* at::TensorBase::data_ptr<c10::Float8_e4m3fn>() const 0000000002152738 T c10::Half* at::TensorBase::data_ptr<c10::Half>() const 00000000021536b0 T c10::qint8* at::TensorBase::data_ptr<c10::qint8>() const 00000000021539c8 T c10::qint32* at::TensorBase::data_ptr<c10::qint32>() const 000000000215383c T c10::quint8* at::TensorBase::data_ptr<c10::quint8>() const 0000000002152bdc T c10::complex<c10::Half>* at::TensorBase::data_ptr<c10::complex<c10::Half>>() const 0000000002152ef4 T c10::complex<double>* at::TensorBase::data_ptr<c10::complex<double>>() const 0000000002152d68 T c10::complex<float>* at::TensorBase::data_ptr<c10::complex<float>>() const 000000000215320c T c10::BFloat16* at::TensorBase::data_ptr<c10::BFloat16>() const 0000000002153ce0 T c10::quint2x4* at::TensorBase::data_ptr<c10::quint2x4>() const 0000000002153b54 T c10::quint4x2* at::TensorBase::data_ptr<c10::quint4x2>() const 0000000002152108 T signed char* at::TensorBase::data_ptr<signed char>() const 0000000002153080 T bool* at::TensorBase::data_ptr<bool>() const 0000000002152a50 T double* at::TensorBase::data_ptr<double>() const 00000000021528c4 T float* at::TensorBase::data_ptr<float>() const 0000000002151f7c T unsigned char* at::TensorBase::data_ptr<unsigned char>() const 0000000002152420 T int* at::TensorBase::data_ptr<int>() const 0000000002152294 T short* at::TensorBase::data_ptr<short>() const 00000000021525ac T long long* at::TensorBase::data_ptr<long long>() const ``` dumping symbols in `libtorch_cpu.dylib` on Linux ``` -> % nm -gU libtorch_cpu.so | c++filt | grep TensorBase | grep ::data_ptr 00000000031ec0d0 T c10::Float8_e5m2* at::TensorBase::data_ptr<c10::Float8_e5m2>() const 00000000031ec2f0 T c10::Float8_e4m3fn* at::TensorBase::data_ptr<c10::Float8_e4m3fn>() const 00000000031ec730 T c10::Float8_e4m3fnuz* at::TensorBase::data_ptr<c10::Float8_e4m3fnuz>() const 00000000031ec510 T c10::Float8_e5m2fnuz* at::TensorBase::data_ptr<c10::Float8_e5m2fnuz>() const 00000000031eb030 T c10::Half* at::TensorBase::data_ptr<c10::Half>() const 00000000031ec950 T c10::qint8* at::TensorBase::data_ptr<c10::qint8>() const 00000000031ecd80 T c10::qint32* at::TensorBase::data_ptr<c10::qint32>() const 00000000031ecb70 T c10::quint8* at::TensorBase::data_ptr<c10::quint8>() const 00000000031eb660 T c10::complex<c10::Half>* at::TensorBase::data_ptr<c10::complex<c10::Half> >() const 00000000031eba80 T c10::complex<double>* at::TensorBase::data_ptr<c10::complex<double> >() const 00000000031eb870 T c10::complex<float>* at::TensorBase::data_ptr<c10::complex<float> >() const 00000000031ebeb0 T c10::BFloat16* at::TensorBase::data_ptr<c10::BFloat16>() const 00000000031ed1c0 T c10::quint2x4* at::TensorBase::data_ptr<c10::quint2x4>() const 00000000031ecfa0 T c10::quint4x2* at::TensorBase::data_ptr<c10::quint4x2>() const 00000000031ea7f0 T signed char* at::TensorBase::data_ptr<signed char>() const 00000000031ebca0 T bool* at::TensorBase::data_ptr<bool>() const 00000000031eb450 T double* at::TensorBase::data_ptr<double>() const 00000000031eb240 T float* at::TensorBase::data_ptr<float>() const 00000000031ea5d0 T unsigned char* at::TensorBase::data_ptr<unsigned char>() const 00000000031eac10 T int* at::TensorBase::data_ptr<int>() const 00000000031ed5e0 T unsigned int* at::TensorBase::data_ptr<unsigned int>() const 00000000031eae20 T long* at::TensorBase::data_ptr<long>() const 00000000031ed7f0 T unsigned long* at::TensorBase::data_ptr<unsigned long>() const 00000000031eaa00 T short* at::TensorBase::data_ptr<short>() const 00000000031ed3d0 T unsigned short* at::TensorBase::data_ptr<unsigned short>() const ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Improved data type consistency across various components for handling larger data sizes more reliably. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
No description provided.