Repository navigation
Port #439 to qp3: TC-SCF fixes, Jastrow-derivative reuse, and plugin CI - #440
Merged
Merged
Conversation
…ing, from #437) The cache index ii is a 32-bit packed value (six bits per AO); the size_t conversion made i, j, k, l 64-bit, and gfortran 16 rejects mixed-kind ior() arguments. Down-cast the index differences at the nine sites; no logic change.
…(pre-existing, from #437) The size_t batch inserted 'use sizet' inside the continued argument list of get_cxcycz_j1(); no compiler accepts that. get_cxcycz_j1 declares integer(size_t) :: ii, so the statement belongs in its body (conventions.rst, placement of use sizet).
…(pre-existing, from #437) Same mangled insertion as two_e_1bgauss_j1.irp.f, in get_cxcycz_j2().
… (pre-existing, from #437) The callee takes integer(size_t) arguments; the literal 1 at two call sites made gfortran infer 32-bit dummies and warn on the size_t l. Spell 1_size_t.
…on (pre-existing, from #437) The size_t batch replaced 4*n_points_final_grid by the 32-bit local n_points4 in four dgemm calls without adding it to the SHARED clause. n_points4 is assigned before the region and only read inside it: SHARED is the only correct clause.
…ing, from #437) n_core_orb is integer(size_t) after the conversion; BLAS stays 32-bit.
… from #437) The procedure declares integer(size_t) in its body; the file-level use sizet is not hoisted into hand-written procedures (conventions.rst).
…ject.irp.f (pre-existing, from #437) h_non_hermite, exp_tau_H and project_phi0 each declare integer(size_t) in their body; the file-level use sizet is not hoisted into them.
The TC-SCF plugin still wrote its JSON with json_unit/json_*_fmt, deleted when
the result logging moved to a yyjson document. Start the document once with
json_init('tc_scf') in the program and log the per-iteration values with
json_add on /results/tc_scf/<key>, following src/casscf_cipsi/casscf.irp.f.
Fixed paths, last value wins: the per-iteration array is not recreated.
lock_io/unlock_io and the convergence control flow are unchanged.
(cherry picked from commit e3d98bf)
(cherry picked from commit 4d7bce6)
(cherry picked from commit 85c67fc)
(cherry picked from commit de40841)
(cherry picked from commit bdde103)
(cherry picked from commit 4f3cf85)
(cherry picked from commit f5a629c)
Use an OpenMP critical name distinct from the pg_label_msg variable. Intel Fortran rejects the previous shared name; changing the lock label leaves the protected region and behavior unchanged. (cherry picked from commit d35b9b1)
…ck matrix (cherry picked from commit db95cb6)
…rove them (cherry picked from commit 5be9f9e)
(cherry picked from commit cb8ccc5)
(cherry picked from commit 831068b)
Reuse each block of Jastrow derivatives for both the gradient and gradient-squared AO integrals. Keep the bounded QMCkl batches and the existing one-shot integration path. (cherry picked from commit bd48e00)
…code The qp3 branch converted integer kinds with PR #437 (see docs/source/programmers_guide/conventions.rst, "Integer kinds"), which the dev-stable code of PR #439 predates. Adapt the three files the conversion and the port both touch: - tc_integ.irp.f: keep use sizet and the 64-bit grid-index declarations of the surviving providers. - tc_integ_num.irp.f: n_blocks, n_this, ii, i_blocks and the grid indices are integer(size_t); int(x, 4) at the dgemm and write_int boundaries; the memory bound is computed in double precision then converted once. - jast_deriv_utils_vect.irp.f: the new get_grad1_u12_withsq_qmckl_block takes 64-bit grid counts and indices, uses 64-bit loop counters and size_t literals, and drops the integer*8/int(x,8) spellings. No logic change: the diff against the dev-stable blobs contains integer kinds and casts only.
…s.irp.f The dev-stable version of the file (PR #439) still logs with json_unit and json_*_fmt, which qp3 does not have. Re-apply the conversion made in 7340201 to the ported text: same paths, plus the new AO residual value as /results/tc_scf/ao_residual and the DIIS history size as /results/tc_scf/diis_size. No other change to the ported code.
…-existing, from #437) The Cholesky rank became integer(size_t) in #437, but it is passed to the interface-less dgemm at ten argument positions, and gfortran then infers the dummy kind from whichever call it saw first: it warns 'Type mismatch (INTEGER(8)/INTEGER(4))' and reads 32 bits of a 64-bit actual. Introduce the conventions.rst idiom, a cholesky_ao_num_4 boundary temporary per subroutine, and use it at every dgemm position; array bounds and loop limits keep the size_t value.
The plugins are not in the default build and no workflow installs them, so a plugin module can stay uncompilable for months: between the size_t conversion (#437) and the yyjson rewrite (5a72128) the TC closure accumulated ten defects -- all fixed earlier in this branch -- and nothing would have reported any of them. ci/plugins.txt lists what to build; `qp plugins install` resolves each name's NEED closure (three names, twelve modules), and growing coverage later is one line per plugin. The new workflow builds the core, installs and compiles the closure on a cold tree, then fails on any "Type mismatch" warning -- integer kinds across a call boundary are silent value corruption and no build gate sees them -- and runs the two tc_scf unit tests plus diis_history_qp_test. It is limited to qp3, where json_init/json_add exist. The build step is a keep-going cascade, measured rather than guessed: IRPF90's per-module graph declares no .mod outputs, and one program stub edge has no dependency that builds the sizet.mod it reads, so a cold module can compile the stub first. A serial retry cannot fix that (ninja runs independent edges in graph order even at -j1, so it fails the same way every run), and the wrapper's "Compiling all modules" edge is itself a sub-ninja that does not inherit -k 0. `-k 0` at the wrapper, `-k 0` on config/build.ninja, two keep-going passes per inner graph and a plain ninja as the real gate make the cold build deterministic without touching the generated graphs; it was proven from a fully cleaned plugin tree. TODO: fix the IRPF90 stub edge, then delete the cascade.
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.
Port of #439 to
qp3, plus the pre-existing plugin fixes it took to compile it.origin/dev-stablereceived PR #439 ("Fix TC-SCF orbital convergence and reuseJastrow derivatives in save-memory integration", by Matteo Peria) as merge
commit
38b1b86con 2026-12-01. This branch brings its 17 files toqp3,which split from dev-stable at
1b289747.The port
The 13 non-merge commits of #439 are cherry-picked with
-x, so each keeps itsauthor and carries its upstream SHA. Ten applied clean; three conflicted in
plugins/local/non_h_ints_mu/because the qp3 size_t conversion (PR #437)rewrote the integer kinds of the same regions. File by file:
src/symmetry_detgets the Intel-critical rename
pg_label_msg→pg_label_lock;tc_scfgetsthe circular-buffer DIIS history, biorthogonal orbital rescaling, level-shift
retries that restore the incoming orbitals, orbital-residual convergence in
orthonormal AO coordinates, and the three-electron double-counting fix;
non_h_ints_mugets the QMCkl block integrator and the single-pass save-memorypath;
non_hermit_davrestoreslapack_diagdfor degenerate eigenspaces.Two adaptation commits follow the cherry-picks:
non_h_ints_mure-applies the qp3 conventions(
docs/source/programmers_guide/conventions.rst, "Integer kinds") to theported code:
integer(size_t)for grid counts and indices,int(x, 4)at theBLAS/IO boundary,
integer*8/int(x, 8)removed from the new QMCkl routine.tc_scfre-applies the yyjson logging on the portedrh_tcscf_diis.irp.f,which upstream still writes with the
json_unit/json_*_fmtAPI that qp3deleted in
5a721280. Same/results/tc_scf/<key>paths as in the fix below,plus the ported
AO residualvalue.Apart from those two adaptations, every ported file is byte-identical to its
dev-stable blob (checked mechanically, 17/17).
Pre-existing qp3 fixes carried by this branch
The plugins are not part of the default build, so the qp3 CI never compiles
them: the TC plugin closure has not built since the size_t conversion (#437)
and the JSON rewrite (
5a721280). Compiling the ported code means reachingthose modules, so this branch fixes them first, one commit per file, boundary
casts and statement placement only — no logic change:
ior()in the AO cache index; twouse sizetstatements mangled into a continued argument list; size_t literals at a call
site; a 32-bit local used in a
DEFAULT(NONE)OpenMP region but missing fromits SHARED clause;
int(n_core_orb, 4)at a dgemm argument;use sizetmissing inside four hand-written procedures that declare
integer(size_t);the Cholesky rank passed to the interface-less
dgemmintc_scf/fock_tc_core.irp.f, now through acholesky_ao_num_4boundarytemporary as
conventions.rstprescribes (gfortran warnedType mismatch (INTEGER(8)/INTEGER(4))there).5a721280leftovers —tc_scf.irp.fandrh_tcscf_diis.irp.flogged throughthe deleted JSON API; they now use
json_init+json_addon/results/tc_scf/<key>(fixed paths, last value wins, as insrc/casscf_cipsi/casscf.irp.f).Verification
qp plugins install tc_scf non_h_ints_mu non_hermit_dav, 12 modules) green on the base, before the port — that iswhat separates pre-existing breakage from port breakage.
ninja, 88/88 edges, exit 0), on macOS arm64with gfortran 16.2.
diis_history.f90,biorthogonal_scaling.f90) and their programs were linked(
diis_history_qp_test,biorthogonal_scaling_provider).Type mismatchwarning remains in the closure.before.
Not run: the numerical TC-SCF / save-memory paths, and the two unit tests
committed under
plugins/local/tc_scf/tests/(they build standalone withgfortran -llapack -lblas, which works on this machine).CI: the plugin layer is compiled from now on
The ten defects above were invisible because nothing compiles a plugin. This
branch adds the missing coverage:
ci/plugins.txt— the plugin list (tc_scf,non_h_ints_mu,non_hermit_dav;qp plugins installresolves the 12-module NEED closure).Growing coverage later is one line per plugin.
.github/workflows/plugins.yml— aqp3-only job that builds the core, theninstalls and compiles the closure on a cold tree, then:
Type mismatchwarning (the silent-corruption class no buildgate catches today);
tc_scfunit tests anddiis_history_qp_test.The build step is a keep-going cascade, and the reason is measured: IRPF90's
per-module graph declares no
.modoutputs, and exactly one program stub edgehas no dependency that would build the
sizet.modit reads, so a cold modulebuild can compile the stub before
sizet.f90. A serial retry cannot fix it(ninja runs independent edges in graph order even at
-j1), and the wrapper's"Compiling all modules" edge is itself a sub-ninja that does not inherit
-k 0.The cascade (
-k 0at the wrapper,-k 0onconfig/build.ninja, twokeep-going passes per inner graph, then a plain
ninjaas the real gate) makesthe cold build deterministic without touching the generated graphs; it was
proven from a fully cleaned plugin tree, and it carries a TODO pointing at the
IRPF90 fix that would let it go.
First run on this PR: green in 9 m 56 s
(
Compilation (plugins), run 46787494568). The gate is not vacuous — before thecholesky_ao_num_4commit the same build emitted fiveType mismatchwarningsin
tc_scf/fock_tc_core.irp.f, and zero after it.Not covered yet, by design: the two files still on the deleted JSON API
(
fci_tc_bi,cipsi_tc_bi_ortho) and the rest ofplugins/local. Add them toci/plugins.txtas they are fixed.Known and left out
plugins/local/fci_tc_bi/fci_tc_bi_ortho.irp.fandplugins/local/cipsi_tc_bi_ortho/write_cipsi_json.irp.fstill call the deletedJSON API; they are outside the closure and deserve a separate commit.