Commit c2209ded authored by Dmitry I. Lyakh's avatar Dmitry I. Lyakh
Browse files

Fixed in issue in tensor expansion parallel evaluation, needs testing ...


Signed-off-by: default avatarDmitry I. Lyakh <quant4me@gmail.com>
parent b2b4575b
/** ExaTN::Numerics: Numerical server
REVISION: 2021/09/30
REVISION: 2021/10/01
Copyright (C) 2018-2021 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2021 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -956,11 +956,14 @@ bool NumServer::submit(const ProcessGroup & process_group,
int procs_per_subgroup = num_procs / parallel_width;
int remainder_procs = num_procs % parallel_width;
int my_subgroup_id = -1;
int my_subgroup_size = 0;
if(local_rank < (procs_per_subgroup + 1) * remainder_procs){
my_subgroup_id = local_rank / (procs_per_subgroup + 1);
my_subgroup_size = procs_per_subgroup + 1;
}else{
my_subgroup_id = remainder_procs +
(local_rank - ((procs_per_subgroup + 1) * remainder_procs)) / procs_per_subgroup;
my_subgroup_size = procs_per_subgroup;
}
assert(my_subgroup_id >= 0 && my_subgroup_id < parallel_width);
auto process_subgroup = process_group.split(my_subgroup_id);
......@@ -1002,11 +1005,11 @@ bool NumServer::submit(const ProcessGroup & process_group,
assert(generated);
accumulation->setIndexPattern(add_pattern);
success = submit(accumulation,local_tensor_mapper); assert(success);
success = sync(*process_subgroup); assert(success);
success = allreduceTensorSync(accumulator->getName()); assert(success);
success = sync(process_group); assert(success);
//Destroy local accumulator tensors:
success = destroyTensorSync(local_accumulator->getName()); assert(success);
success = scaleTensor(accumulator->getName(),1.0/static_cast<double>(my_subgroup_size)); assert(success);
success = destroyTensor(local_accumulator->getName()); assert(success);
success = sync(process_group); assert(success);
success = allreduceTensorSync(process_group,accumulator->getName()); assert(success);
}
return success;
}
......
/** ExaTN:: Variational optimizer of a closed symmetric tensor network expansion functional
REVISION: 2021/09/25
REVISION: 2021/10/01
Copyright (C) 2018-2021 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2021 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -73,7 +73,8 @@ bool TensorNetworkOptimizer::optimize()
bool TensorNetworkOptimizer::optimize(const ProcessGroup & process_group)
{
constexpr bool NORMALIZE_WITH_METRICS = true; //whether to normalize tensor network factors with metrics or not
constexpr bool NORMALIZE_WITH_METRICS = true; //whether to normalize tensor network factors with metrics or not
constexpr double MIN_ACCEPTABLE_DENOM = 1e-13; //minimally acceptable denominator in optimal step size determination
unsigned int local_rank; //local process rank within the process group
if(!process_group.rankIsIn(exatn::getProcessRank(),&local_rank)) return true; //process is not in the group: Do nothing
......@@ -300,7 +301,7 @@ bool TensorNetworkOptimizer::optimize(const ProcessGroup & process_group)
<< (grad_norm * grad_norm) << " / " << denom << " = "
<< (grad_norm * grad_norm / denom) << std::endl;
denom = std::abs(denom);
if(denom > 1e-7){
if(denom > MIN_ACCEPTABLE_DENOM){
epsilon_ = grad_norm * grad_norm / denom;
if(TensorNetworkOptimizer::debug > 1) std::cout << " Optimal step size = " << epsilon_
<< ": Denominator = " << denom << std::endl;
......
/** ExaTN: Quantum computing related
REVISION: 2021/09/25
REVISION: 2021/10/01
Copyright (C) 2018-2021 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2021 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -8,17 +8,16 @@ Copyright (C) 2018-2021 Oak Ridge National Laboratory (UT-Battelle) **/
a) Provides utilities related to quantum circuit simulations, like quantum gates,
Pauli matrix based Hamiltonian reading, etc.
b) Normal gate action translates to the following tensor notation:
q(i0) * G(i0|i1) --> v(i1),
q(i0) q(i1) * G(i0,i1|i2,i3) --> v(i2,i3), etc.
Note that if G(i0,i1|i2,i3) is a controlled 2-body gate,
the control (senior) index is i1, not i0.
A convenient way to remember this is to use the standard
bra-ket convention such that we will have:
|v(i3,i2)> = CX(i3,i2|i1,i0) * |q(i1)q(i0)>, where
tensor leg numeration is from right to left:
(i3)--V = (i3)--CX--(i1)--q
(i2)--V (i2)--CX--(i0)--q
where the control line is i1.
q(j0) * G(j0|i0) --> v(i0),
q(j1,j0) * G(j1,j0|i1,i0) --> v(i1,i0), etc,
where the inverse order of indices and the transposed
form of the equations is a consequence of the column-wise
storage of matrix G(j1,j0|i1,i0), to match the textbook
definitions of quantum gates. Note that if G(j1,j0|i1,i0)
is a controlled 2-body gate, the control (senior) indices
are i0 and j0. A convenient way to remember this is to use
the standard bra-ket convention such that we will have:
<v(i1,i0)| = <q(j1,j0)| * CX(j1,j0|i1,i0)
**/
#ifndef EXATN_QUANTUM_HPP_
......
......@@ -45,8 +45,8 @@
#define EXATN_TEST24
#define EXATN_TEST25
#define EXATN_TEST26
#define EXATN_TEST27 //requires input file from source
#define EXATN_TEST28 //requires input file from source
//#define EXATN_TEST27 //requires input file from source
//#define EXATN_TEST28 //requires input file from source
#define EXATN_TEST30
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment