ToT: strided arena kernels for complex inner cells; complex ToT scaling - #573
Open
kshitij-05 wants to merge 1 commit into
Open
ToT: strided arena kernels for complex inner cells; complex ToT scaling#573kshitij-05 wants to merge 1 commit into
kshitij-05 wants to merge 1 commit into
Conversation
…complex ToT scale/add/subt/mult
The arena strided-DGEMM ToT x ToT kernels (arena_strided_dgemm_ce_e,
_ce_ce_right, _ce_ce_left) and their ContEngine install gates were
numeric_type == double only, so every ToT contraction with
std::complex<double> inner storage silently took the generic per-cell path.
- kernels templated on the inner numeric type T, admitted through
detail::is_strided_dgemm_numeric_v<T> (float, double, complex<float>,
complex<double>); factor/beta typed T, cell pointers T*; all three operands
must share T (mixed real x complex ToT products keep the per-cell path)
- diagnostic helpers classify_run / classify_operand / gather_rescuable /
measure_segments: cell pointers made generic
- cont_engine.h ce+e / ce+ce install gates and the hc+e reuse gate: view
cells + same numeric type + the trait; static_cast<numeric_type>(factor)
- Tensor<ToT> scale/add/subt/mult fill lambdas and ArenaTensor scale_to pick
up detail's mixed complex x scalar operator* (as the non-nested scale branch
already does), so e.g. 2 * A("i;j") compiles for complex ToTs
- tests: complex<double> cases for the three kernels; a complex<double> row
in the ToT fixture type list (runs tot_expressions / tot_dist_array for
complex ToTs); typedefs case compares scalar_type against scalar_t<elem>
Measured on MPQC Kramers PNS-CCD (complex ToTs, HSeOH/cc-pVDZ): 0 -> 531
strided ce+e installs, first CC iteration 52.0 -> 20.5 s, energy unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ToT×ToT contractions with
std::complex<double>inner cells never use the strided arena kernels.arena_strided_dgemm_ce_e/_ce_ce_right/_ce_ce_leftand their install gates inContEngineare hard-coded todouble, so a complex contraction falls back to the generic per-cell path: one tiny inner op per result cell and contracted index, instead of one strided BLAS gemm per cell. The kernels themselves are only layout/stride logic on top ofblas::gemm, which already has the complex overloads.Separately, scaling a complex ToT by an integral factor (
2 * A("i;j")) does not compile: the ToT fill lambdas inTensor::scale/add/subt/multandArenaTensor::scale_touse the rawelem * factorand miss the mixed complex×scalaroperator*indetailthat the non-nestedscalebranch already uses.Changes
detail::is_strided_dgemm_numeric_v<T>admitsfloat,double,complex<float>,complex<double>. All three operands must share the type.ContEngineinstall gates and the hc+e reuse gate use the trait; the diagnostic helpers' cell pointers are made type-generic.scale/add/subt/multfill lambdas andArenaTensor::scale_topick updetail's mixed operators.complex<double>row in the ToT fixture, sotot_expressions/tot_dist_arraynow cover complex ToTs.Testing
arena_strided_dgemm,einsum*,tot_expressions,tot_dist_array_part{1,2}: 807 cases, no errors. With the change a complex ToT×ToT contraction reports strided ce+e installs where before it reported none.Not addressed
conj()on a ToT contraction does not compile (ComplexConjugate<void>has no conversion to the element type;ContractReduce<…, ComplexConjugate<void>>needs a value-returninggemm).