At the moment most of SeQuant's symbolic processing routines either (implicitly) expect to be fed a flat expression or perform explicit flattening as their first processing step. However, for optimal evaluation the nesting of expressions is clearly vitally important. At the moment we entirely rely on SeQuant's own optimize function to determine the nesting (evaluation order) of our expressions. However, at least at the moment this routine only considers single-term optimizations and hence there would be value in partially factoring expressions by hand or other means (e.g. because it is known that this leads to beneficial reuse of intermediates) and for that factoring to survive all processing steps in SeQuant.
An concrete example would be the identification of patterns that typically arise after spintracing: an expression that appears twice except that the second time one tensor has permuted indices. E.g. (simplified) 2 t{a1,a2;i1,i2}:N-N-S - t{a2,a1;i2,i1}:N-N-S. Factoring this typical antisymmetrization patterns right after spintracing (and then keeping it intact until evaluation/export) would allow to exploit such patterns by e.g. using special capabilities of the numerical backend (on-the-fly antisymmetrization inside a tensor contraction expression) or simply by being sure that the rest of the expressions (which are typically identical) will only be computed once instead of twice (which might happen if caching algorithms happen to fail for one reason or another).
I believe the first step towards this is to make expression canonicalization work for nested expressions (see also #287) and once we have that, other routines can be adapted. It is clear that processing expressions that are nested in a way that retains this nesting can be a lot more complicated than always insisting on flattened expressions. However, being able to do this should significantly broaden the things SeQuant is possible to assist with.
At the moment most of SeQuant's symbolic processing routines either (implicitly) expect to be fed a flat expression or perform explicit flattening as their first processing step. However, for optimal evaluation the nesting of expressions is clearly vitally important. At the moment we entirely rely on SeQuant's own
optimizefunction to determine the nesting (evaluation order) of our expressions. However, at least at the moment this routine only considers single-term optimizations and hence there would be value in partially factoring expressions by hand or other means (e.g. because it is known that this leads to beneficial reuse of intermediates) and for that factoring to survive all processing steps in SeQuant.An concrete example would be the identification of patterns that typically arise after spintracing: an expression that appears twice except that the second time one tensor has permuted indices. E.g. (simplified)
2 t{a1,a2;i1,i2}:N-N-S - t{a2,a1;i2,i1}:N-N-S. Factoring this typical antisymmetrization patterns right after spintracing (and then keeping it intact until evaluation/export) would allow to exploit such patterns by e.g. using special capabilities of the numerical backend (on-the-fly antisymmetrization inside a tensor contraction expression) or simply by being sure that the rest of the expressions (which are typically identical) will only be computed once instead of twice (which might happen if caching algorithms happen to fail for one reason or another).I believe the first step towards this is to make expression canonicalization work for nested expressions (see also #287) and once we have that, other routines can be adapted. It is clear that processing expressions that are nested in a way that retains this nesting can be a lot more complicated than always insisting on flattened expressions. However, being able to do this should significantly broaden the things SeQuant is possible to assist with.