Skip to content

einsum support for generalized product involving tensor-of-tensor and regular tensor #437

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

Merged
merged 94 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
4ceb416
[unit] enabled tot x t test, does not compile @bimalgaudel will fix
evaleev Nov 8, 2023
65f4374
[WIP] T x ToT overload of einsum: first attempt.
bimalgaudel Nov 13, 2023
ab0698d
tiny step towards supporting T*ToT in expr
evaleev Nov 14, 2023
a60315d
Merge pull request #433 from ValeevGroup/gaudel/feature/t_x_tot_expr_…
bimalgaudel Nov 17, 2023
a9a6b58
[WIP]: Make binary_egine less restrictive on left and right arg types.
bimalgaudel Nov 20, 2023
c2998a5
Merge branch 'master' into gaudel/feature/t_x_tot
evaleev Nov 20, 2023
e4eb2c9
moar ToT * T progress
evaleev Nov 20, 2023
b80d1c4
[skip_ci] add permutation optimizer for general case: supports inner …
bimalgaudel Nov 21, 2023
c199457
add permutation optimizer for scaling
bimalgaudel Nov 21, 2023
bff7d28
expression-level support for ToT x T (and vice versa) implemented, ne…
evaleev Nov 21, 2023
f814cf6
Merge remote-tracking branch 'origin/gaudel/feature/t_x_tot' into gau…
bimalgaudel Nov 22, 2023
72e1bcb
[ci skip] implement 'i,j;m,n * j,k -> i,j,k;m,n' reference evaluation…
bimalgaudel Nov 22, 2023
c694053
[ci skip] more manual tot * t reference evaluation
bimalgaudel Nov 22, 2023
29b5dba
Add equality comparison for SparseShape<T>.
bimalgaudel Nov 23, 2023
f2945da
Validate outer-product type tot * t evaluation using expression layer.
bimalgaudel Nov 23, 2023
be06fbe
[unit] einsum_tot_t pulls remote tiles using strick blocking (dowork=…
evaleev Nov 27, 2023
3cd64db
[unit] einsum_tot_t must test ToT*T AND T*ToT (the latter is currentl…
evaleev Nov 27, 2023
f246756
Avoid code-duplication by generalizing the existing einsum function.
bimalgaudel Nov 28, 2023
e5ec531
In einsum, handle inner index labels when tot times t, or, t times to…
bimalgaudel Nov 29, 2023
8341bbb
amend https://github.com/ValeevGroup/tiledarray/commit/bff7d2888cd69e…
evaleev Nov 29, 2023
56b49a0
relax type requirements on tensor_init to support mixed (ToT alongsid…
evaleev Nov 29, 2023
b75b1fc
relax Tensor(left,right,binaryelemeop,permutation) ctor constraints
evaleev Nov 30, 2023
f8d4100
Support for pure hadamard product between a tot and a t: 'i,j;m,n * i…
bimalgaudel Dec 7, 2023
726ebb8
SparseShape inequality comparison added.
bimalgaudel Dec 8, 2023
7fd52d5
Disable shape comparison in ToTArrayFixture.
bimalgaudel Dec 8, 2023
cdc9db2
Default construction of result tensor tile in `einsum` made more gene…
bimalgaudel Dec 8, 2023
d2fb429
Restore (optional) shape comparison on ToTArrayFixture::are_equal fun…
bimalgaudel Dec 10, 2023
42fb41b
Relax restricitons on this->product_type() values while calling make_…
bimalgaudel Dec 10, 2023
7b7dbb8
Typo.
bimalgaudel Dec 11, 2023
02a7db7
[skip ci] einsum unit test for
bimalgaudel Dec 15, 2023
f0be0c9
Tensor::gemm involving custom elem_op supports batching
evaleev Dec 15, 2023
6e18686
Make single-valued initializer lists explicit in ambiguous cases.
bimalgaudel Dec 17, 2023
2520fe5
Use .data() method to access elements by ordinal in tensor_reduce fun…
bimalgaudel Dec 17, 2023
eacc22b
Implement Tot x T (and reverse) generalized contraction.
bimalgaudel Dec 17, 2023
5436299
bump pybind11 version to VG/v2.11
evaleev Dec 20, 2023
f7e206d
[unit] enabled tot x t test, does not compile @bimalgaudel will fix
evaleev Nov 8, 2023
e62a675
[WIP] T x ToT overload of einsum: first attempt.
bimalgaudel Nov 13, 2023
dce1bdc
tiny step towards supporting T*ToT in expr
evaleev Nov 14, 2023
8230b16
[WIP]: Make binary_egine less restrictive on left and right arg types.
bimalgaudel Nov 20, 2023
a129754
moar ToT * T progress
evaleev Nov 20, 2023
bf959a2
[skip_ci] add permutation optimizer for general case: supports inner …
bimalgaudel Nov 21, 2023
8dd614e
add permutation optimizer for scaling
bimalgaudel Nov 21, 2023
43d61f0
expression-level support for ToT x T (and vice versa) implemented, ne…
evaleev Nov 21, 2023
74e5e78
[ci skip] implement 'i,j;m,n * j,k -> i,j,k;m,n' reference evaluation…
bimalgaudel Nov 22, 2023
86f2877
[ci skip] more manual tot * t reference evaluation
bimalgaudel Nov 22, 2023
e40d882
Add equality comparison for SparseShape<T>.
bimalgaudel Nov 23, 2023
f9e4f0d
Validate outer-product type tot * t evaluation using expression layer.
bimalgaudel Nov 23, 2023
42a1dc7
[unit] einsum_tot_t pulls remote tiles using strick blocking (dowork=…
evaleev Nov 27, 2023
076f488
[unit] einsum_tot_t must test ToT*T AND T*ToT (the latter is currentl…
evaleev Nov 27, 2023
7b2a90b
Avoid code-duplication by generalizing the existing einsum function.
bimalgaudel Nov 28, 2023
c8f9542
In einsum, handle inner index labels when tot times t, or, t times to…
bimalgaudel Nov 29, 2023
f04a943
amend https://github.com/ValeevGroup/tiledarray/commit/bff7d2888cd69e…
evaleev Nov 29, 2023
178393b
relax type requirements on tensor_init to support mixed (ToT alongsid…
evaleev Nov 29, 2023
3eb8280
relax Tensor(left,right,binaryelemeop,permutation) ctor constraints
evaleev Nov 30, 2023
0f4e818
Support for pure hadamard product between a tot and a t: 'i,j;m,n * i…
bimalgaudel Dec 7, 2023
ba2b9a3
SparseShape inequality comparison added.
bimalgaudel Dec 8, 2023
be8e07a
Disable shape comparison in ToTArrayFixture.
bimalgaudel Dec 8, 2023
e96df68
Default construction of result tensor tile in `einsum` made more gene…
bimalgaudel Dec 8, 2023
5b7c3dd
Restore (optional) shape comparison on ToTArrayFixture::are_equal fun…
bimalgaudel Dec 10, 2023
df24001
Relax restricitons on this->product_type() values while calling make_…
bimalgaudel Dec 10, 2023
cbf06b1
Typo.
bimalgaudel Dec 11, 2023
c86b7d0
[skip ci] einsum unit test for
bimalgaudel Dec 15, 2023
c72f3f4
Tensor::gemm involving custom elem_op supports batching
evaleev Dec 15, 2023
657a128
Make single-valued initializer lists explicit in ambiguous cases.
bimalgaudel Dec 17, 2023
a08026c
Use .data() method to access elements by ordinal in tensor_reduce fun…
bimalgaudel Dec 17, 2023
a5b253b
Implement Tot x T (and reverse) generalized contraction.
bimalgaudel Dec 17, 2023
f001847
einsum tot x tot 'i,j;m,n * j,k;m,n -> i,jk;m,n' unit-test compares r…
bimalgaudel Dec 21, 2023
f4bba8e
Make shape comparison flags more explicit.
bimalgaudel Dec 21, 2023
06656da
Merge remote-tracking branch 'origin/gaudel/feature/t_x_tot' into gau…
bimalgaudel Dec 21, 2023
0c30bb3
use version-controlled clang-format.sh from https://github.com/Valeev…
evaleev Dec 23, 2023
ba0be00
[ut] einsum_tot/ijk_mn_eq_ij_mn_times_kj_mn : how NOT to compute ref_…
evaleev Dec 23, 2023
987040b
[ut] einsum_tot/ijk_mn_eq_ij_mn_times_kj_mn : how to compute ref_result
evaleev Dec 23, 2023
2392f20
[ut] ref result manual computation pattern from previous commit appli…
bimalgaudel Dec 23, 2023
8b365a9
[ut] typo
bimalgaudel Dec 23, 2023
6c7a9f4
[ci skip] add .batched_size() method to Tensor that returns size() mu…
bimalgaudel Dec 23, 2023
6032702
Tensor reduce works on batch_size() * volume() many elements.
bimalgaudel Dec 24, 2023
c2d4d88
Merge branch 'master' into gaudel/feature/t_x_tot
evaleev Dec 25, 2023
959c84f
Rename TA::Tensor member function 'batched_size' to 'total_size'.
bimalgaudel Dec 25, 2023
8b6bb17
Merge remote-tracking branch 'origin/gaudel/feature/t_x_tot' into gau…
bimalgaudel Dec 25, 2023
f0cd2a9
[cmake] disable clang-format use by umpire/blt
evaleev Dec 26, 2023
0d4d2b6
Rename TA::Tensor and TA::Tile member function 'batch_size' to more r…
bimalgaudel Dec 26, 2023
efb852e
Generic scalar_type instead of a cpp literal value
bimalgaudel Jan 2, 2024
c32a541
bump MADNESS tag to pull in https://github.com/m-a-d-n-e-s-s/madness/…
evaleev Jan 3, 2024
74759c7
introduced TensorImpl::local_nnz
evaleev Jan 3, 2024
f3716f8
annotate virtual DistEval class members with override
evaleev Jan 3, 2024
ee1b367
if MADNESS configured with ENABLE_WORLDOBJECT_FUTURE_TRACE trace futu…
evaleev Jan 3, 2024
886ec19
binary_wrapper.h: hush warnings due to implicitly capture of `this`
evaleev Jan 3, 2024
c3a36dc
reimplement ArrayEvalImpl::internal_eval() using TensorImpl::local_nnz()
evaleev Jan 3, 2024
a9c7e62
Bug fix.
bimalgaudel Jan 3, 2024
c16ecc1
Remove [=] capture when not needed.
bimalgaudel Jan 4, 2024
bc1b712
introduced TA_TRACE_GLOBAL_COMM_STATS CMake option that enables traci…
evaleev Jan 7, 2024
56e0e2e
if configured with TA_TRACE_GLOBAL_COMM_STATS will collect stats of D…
evaleev Jan 7, 2024
78e8ad3
DistributedStorage::get() can use (2 types of) caching if requested b…
evaleev Jan 7, 2024
989fd8e
bump MADNESS tag to pull in https://github.com/m-a-d-n-e-s-s/madness/…
evaleev Jan 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ repos:
name: Format C/C++ code using clang-format.
language: system
files: \.(c|cc|cxx|cpp|h|hpp|hxx)$
entry: clang-format -i
args: [--style=file]
entry: bin/admin/clang-format.sh
args: [--style=file -i]
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ if(TA_ENABLE_TILE_OPS_LOGGING AND NOT DEFINED TA_TILE_OPS_LOG_LEVEL)
set(TA_TILE_OPS_LOG_LEVEL 1)
endif(TA_ENABLE_TILE_OPS_LOGGING AND NOT DEFINED TA_TILE_OPS_LOG_LEVEL)

option(TA_TRACE_GLOBAL_COMM_STATS "Enable tracing of communication stats of global objects (DistEval's and DIstributedStorage) TiledArray" OFF)
add_feature_info(TASK_TRACE_DEBUG TA_TRACE_GLOBAL_COMM_STATS "Debug communication stats of global objects (DistEval's and DIstributedStorage) TiledArray")
set(TILEDARRAY_ENABLE_GLOBAL_COMM_STATS_TRACE ${TA_TRACE_GLOBAL_COMM_STATS})

option(TA_RANGEV3 "Enable Range-V3 library" OFF)
add_feature_info(TA_RANGEV3 TA_RANGEV3 "Range-V3 ranges library")

Expand Down
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Both methods are supported. However, for most users we _strongly_ recommend to b
- Boost.Range: header-only, *only used for unit testing*
- [BTAS](http://github.com/ValeevGroup/BTAS), tag bf0c376d5cdd6f668174b2a4c67b19634d1c0da7 . If usable BTAS installation is not found, TiledArray will download and compile
BTAS from source. *This is the recommended way to compile BTAS for all users*.
- [MADNESS](https://github.com/m-a-d-n-e-s-s/madness), tag c0c4ea543439c740e3ee848fdd055c633a47f6c5 .
- [MADNESS](https://github.com/m-a-d-n-e-s-s/madness), tag b1f1c39c497b86ab3ef4e560a686de63eb555cc4 .
Only the MADworld runtime and BLAS/LAPACK C API component of MADNESS is used by TiledArray.
If usable MADNESS installation is not found, TiledArray will download and compile
MADNESS from source. *This is the recommended way to compile MADNESS for all users*.
Expand Down
94 changes: 94 additions & 0 deletions bin/admin/clang-format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/bash

# these are the versions of clang-format that are supported required
# should be ordered from oldest to newest to make sure the newest is picked
supported_clang_format_versions="16 17"
preferred_clang_format_version="" # prefer most recent supported clang-format version
for v in $supported_clang_format_versions; do
preferred_clang_format_version=$v
done

# append common locations of clang-format to PATH
unameOut="$(uname -s)"
case "${unameOut}" in
Darwin*)
extra_path=""
# this prefers more recent versions
for v in $supported_clang_format_versions; do
extra_path=/opt/homebrew/opt/llvm@$v/bin:/opt/homebrew/opt/clang-format@$v/bin:$extra_path
done
# prepend paths
export PATH=$extra_path:$PATH:/opt/homebrew/bin
;;
esac

path_to_clang_format=`which clang-format`
have_supported_clang_format_version=0
if [[ "X$path_to_clang_format" != "X" ]]; then

# check clang-format version
clang_format_version=`clang-format --version | sed 's/.* version //' | awk -F'[.]' '{print $1}'`

#echo "supported_clang_format_versions=\"$supported_clang_format_versions\" clang_format_version=$clang_format_version"

# if found clang-format, but wrong version, check if docker is available
for v in $supported_clang_format_versions; do
if [[ $clang_format_version -eq $v ]]; then
have_supported_clang_format_version=1
break
fi
done
fi

if [[ $have_supported_clang_format_version -eq 0 ]]; then
echo "WARNING: found clang-format with unsupported version $clang_format_version (supported versions: $supported_clang_format_versions)"

# look for docker
path_to_docker=`which docker`
if [[ "X$path_to_docker" = "X" ]]; then
echo "ERROR: docker is not found either, PATH=$PATH, install one of supported clang-format versions (any of these: $supported_clang_format_versions) or install docker"
exit 1
fi

# if docker up?
docker info >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo "ERROR: docker is found but not running, start it"
exit 1
fi

# use docker to run clang-format
mount_path=$(readlink -f "$HOME")

# convert file names in the arguments to relative paths
args=""
for i in "$@"; do
# skip options
if [[ "$i" == -* ]]; then
args="$args $i"
continue
fi
abs_file_path=$(readlink -f "$i")
if [[ "X$abs_file_path" = "X" ]]; then
echo "ERROR: given file $i is not found"
exit 1
fi

dir=$(dirname $abs_file_path)
file_path_relative_to_project_root=$(basename $abs_file_path)
while [[ "$dir" != "$mount_path" && "$dir" != "/" ]]; do
file_path_relative_to_project_root="$(basename $dir)/$file_path_relative_to_project_root"
dir=$(dirname $dir)
#echo "dir=$dir file_path_relative_to_project_root=$file_path_relative_to_project_root"
done
if [[ "$dir" == "/" ]]; then
echo "ERROR: given file $i (absolute path $abs_file_path) is not under \$HOME=$mount_path, cannot use docker-based clang-format in this case"
exit 1
fi
args="$args /hostHOME/$file_path_relative_to_project_root"
done
docker run --platform linux/x86_64 -v $mount_path:/hostHOME xianpengshen/clang-tools:$preferred_clang_format_version clang-format $args
else
#echo "found $path_to_clang_format with required version $clang_format_version"
clang-format $*
fi
1 change: 1 addition & 0 deletions external/umpire.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ else()
-DENABLE_EXAMPLES=OFF
-DENABLE_LOGGING=OFF
-DENABLE_ASSERTS=${enable_umpire_asserts}
-DENABLE_CLANGFORMAT=OFF
)

# caveat: on recent Ubuntu default libstdc++ provides filesystem, but if using older gcc (gcc-8) must link against
Expand Down
4 changes: 2 additions & 2 deletions external/versions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ set(TA_INSTALL_EIGEN_PREVIOUS_VERSION 3.3.7)
set(TA_INSTALL_EIGEN_URL_HASH SHA256=b4c198460eba6f28d34894e3a5710998818515104d6e74e5cc331ce31e46e626)
set(TA_INSTALL_EIGEN_PREVIOUS_URL_HASH MD5=b9e98a200d2455f06db9c661c5610496)

set(TA_TRACKED_MADNESS_TAG c0c4ea543439c740e3ee848fdd055c633a47f6c5)
set(TA_TRACKED_MADNESS_PREVIOUS_TAG 03c82cf2780d9e96298cc9140ac128c73eacd3b1)
set(TA_TRACKED_MADNESS_TAG b1f1c39c497b86ab3ef4e560a686de63eb555cc4)
set(TA_TRACKED_MADNESS_PREVIOUS_TAG cf3c98053453329f35b775c8b9f561301f6a997e)
set(TA_TRACKED_MADNESS_VERSION 0.10.1)
set(TA_TRACKED_MADNESS_PREVIOUS_VERSION 0.10.1)

Expand Down
13 changes: 7 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ TiledArray/dist_eval/contraction_eval.h
TiledArray/dist_eval/dist_eval.h
TiledArray/dist_eval/unary_eval.h
TiledArray/einsum/index.h
TiledArray/einsum/index.cpp
TiledArray/einsum/range.h
TiledArray/einsum/string.h
TiledArray/expressions/add_engine.h
Expand Down Expand Up @@ -195,13 +194,10 @@ TiledArray/util/bug.h
TiledArray/util/function.h
TiledArray/util/initializer_list.h
TiledArray/util/logger.h
TiledArray/util/ptr_registry.cpp
TiledArray/util/ptr_registry.h
TiledArray/util/random.cpp
TiledArray/util/random.h
TiledArray/util/singleton.h
TiledArray/util/threads.h
TiledArray/util/threads.cpp
TiledArray/util/thread_specific.h
TiledArray/util/time.h
TiledArray/util/vector.h
Expand Down Expand Up @@ -243,10 +239,15 @@ TiledArray/tensor_impl.cpp
TiledArray/array_impl.cpp
TiledArray/dist_array.cpp
TiledArray/version.cpp
TiledArray/util/backtrace.cpp
TiledArray/util/bug.cpp
TiledArray/einsum/index.cpp
TiledArray/expressions/permopt.cpp
TiledArray/math/linalg/basic.cpp
TiledArray/math/linalg/rank-local.cpp
TiledArray/util/backtrace.cpp
TiledArray/util/bug.cpp
TiledArray/util/ptr_registry.cpp
TiledArray/util/random.cpp
TiledArray/util/threads.cpp
)
# feed TILEDARRAY_GIT_REVISION and TILEDARRAY_GIT_DESCRIPTION to TiledArray/version.cpp only to avoid recompiling everything
set_source_files_properties(
Expand Down
13 changes: 12 additions & 1 deletion src/TiledArray/array_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,18 @@ class ArrayImpl : public TensorImpl<Policy> {
/// DistributedStorage

/// @return const reference to the atomic counter of live DelayedSet requests
const madness::AtomicInt& num_live_ds() const { return data_.num_live_ds(); }
const std::atomic<std::size_t>& num_live_ds() const {
return data_.num_live_ds();
}

/// Reports the number of live DelayedForward requests for this object's
/// DistributedStorage

/// @return const reference to the atomic counter of live DelayedForward
/// requests
const std::atomic<std::size_t>& num_live_df() const {
return data_.num_live_df();
}

}; // class ArrayImpl

Expand Down
3 changes: 3 additions & 0 deletions src/TiledArray/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@
#cmakedefine TA_ENABLE_TILE_OPS_LOGGING 1
#define TA_TILE_OPS_LOG_LEVEL 0@TA_TILE_OPS_LOG_LEVEL@

/* Enables collection of communication statistics for global objects (DistEval and DistributedStorage) */
#cmakedefine TILEDARRAY_ENABLE_GLOBAL_COMM_STATS_TRACE 1

/* ----------- pragma helpers ---------------*/
#define TILEDARRAY_PRAGMA(x) _Pragma(#x)
/* same as TILEDARRAY_PRAGMA(x), but expands x */
Expand Down
Loading