Open mtfishman opened 5 years ago
Agreed, it would be good to have information about this sort of thing on the website.
But I should add that this sort of behavior is not ITensor-specific. Instead, it's the order of operations that C++ itself imposes. Still something good for users to be aware of, especially if it's different in Julia.
Yeah I didn't mean to imply it was ITensor specific. But it is something that could be benign if you were not multiplying with ITensors (i.e. multiplying scalars).
The part that is ITensor/TN specific is being careful about order of operations, so maybe this is just part of a current tutorial or book page (for example http://www.itensor.org/docs.cgi?vers=cppv2&page=tutorials/cost).
It would be good to add a page somewhere with a list of performance tips for ITensor/tensor network contraction methods.
One example is a performance issue I was just running into, where I was contracting two MPS
psi
andphi
like this:and getting really bad performance (for medium to large bond dimensions). The definition of
*=
in ITensor leads to a different order of operations than I was expecting (performingpsi(n)*phi(n)
first, then contracting withO
). So a better way is to write this as:I was used to the definition of
x *= y
from Julia, where it is always lowered tox = x * y
, so it took longer than it should have for me to catch this. Anyway, just adding a note about this for future reference.