Skip to content

Commit 66d45ef

Browse files
committed
move HF reference config under pretrain.*
Move Hartree-Fock reference settings out of `system.*` so the system config only describes the physical problem and the workflow stages own their SCF reference settings.
1 parent a8f9555 commit 66d45ef

21 files changed

Lines changed: 262 additions & 101 deletions

File tree

docs/api-reference/atomic.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ Atom definitions, element properties, electronic structure (SCF), orbital evalua
5353
## Pretraining
5454

5555
```{eval-rst}
56+
.. autoclass:: jaqmc.utils.atomic.pretrain.PretrainReferenceConfig
57+
5658
.. autofunction:: jaqmc.utils.atomic.pretrain.make_pretrain_log_amplitude
5759
.. autofunction:: jaqmc.utils.atomic.pretrain.make_pretrain_loss
5860
```

docs/systems/molecule/index.md

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ boundary conditions. Most runs start from a YAML definition and a
55
single `jaqmc molecule train` command. JaQMC then follows the standard
66
molecular workflow:
77

8-
1. **Hartree-Fock (HF)** computes reference orbitals with PySCF.
8+
1. **Hartree-Fock (HF)** computes a reference electronic-structure solution with
9+
PySCF.
910
2. **Pretraining** matches the neural wavefunction to those orbitals.
1011
3. **VMC training** performs the main energy optimization.
1112

@@ -76,14 +77,13 @@ that generate the underlying configuration for you.
7677
### Single Atoms
7778

7879
For a single atom, `system.module=atom` is a shortcut. You provide the element
79-
symbol and optional HF settings, and JaQMC fills in the matching electron spin
80-
configuration automatically.
80+
symbol, and JaQMC fills in the matching electron spin configuration
81+
automatically.
8182

8283
```yaml
8384
system:
8485
module: atom
8586
symbol: Li # Element symbol (H, He, Li, Be, ...)
86-
basis: sto-3g # Basis set for SCF initialization
8787
# ecp: ccecp # Optional: effective core potential
8888
```
8989

@@ -106,7 +106,6 @@ system:
106106
bond_length: 3.015 # Distance between atoms
107107
unit: bohr # Length unit for bond_length
108108
spin: 0 # n_up - n_down for the full molecule
109-
basis: cc-pvdz
110109
```
111110
112111
Save as `li_h_diatomic.yml`, then run:
@@ -118,33 +117,57 @@ jaqmc molecule train --yml li_h_diatomic.yml workflow.save_path=./runs/li_h_diat
118117
(molecule-basis-sets-and-ecps)=
119118
## Basis Sets and ECPs
120119

121-
The `basis` parameter controls the basis set used for the HF calculation. Any basis set supported by PySCF works:
120+
The examples above keep the Hartree-Fock reference at its default settings so
121+
you can focus on defining the system. When you do need to change the reference
122+
calculation itself, add a `pretrain.reference` section. That is where you set
123+
the HF basis and method. The `system` section still describes the physical
124+
system, including `system.ecp`.
125+
126+
For example, to use a different HF basis:
127+
128+
```yaml
129+
pretrain:
130+
reference:
131+
basis: cc-pvdz
132+
```
133+
134+
Any basis set supported by PySCF works:
122135

123136
- Minimal: `sto-3g` (default, fast)
124137
- Split-valence: `6-31g`, `6-311g`
125138
- Correlation-consistent: `cc-pvdz`, `cc-pvtz`, `cc-pvqz`
126139

127-
For heavy elements (transition metals, lanthanides), use an effective core potential (ECP) to replace core electrons with a pseudopotential, reducing the number of electrons treated explicitly:
140+
For heavy elements (transition metals, lanthanides), use an effective core
141+
potential (ECP) to replace core electrons with a pseudopotential, reducing the
142+
number of electrons treated explicitly:
128143

129144
```yaml
130145
system:
131146
module: atom
132147
symbol: Fe
133-
basis: ccecpccpvdz
134148
ecp: ccecp
149+
pretrain:
150+
reference:
151+
basis: ccecpccpvdz
135152
```
136153

137154
Both `basis` and `ecp` can be specified per element:
138155

139156
```yaml
157+
pretrain:
158+
reference:
159+
basis:
160+
Fe: ccecpccpvdz
161+
O: cc-pvdz
140162
system:
141-
basis:
142-
Fe: ccecpccpvdz
143-
O: cc-pvdz
144163
ecp:
145164
Fe: ccecp
146165
```
147166

167+
If you need more control, the same `pretrain.reference` section also lets you
168+
change the HF method and pass extra PySCF options. See <project:train.md> for
169+
the full reference.
170+
148171
## Estimators
149172

150173
The training stage computes energy from several components: kinetic energy,

docs/systems/molecule/train.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,16 @@ Initializes the neural network to approximate Hartree-Fock orbitals before VMC
185185
training. It uses the same run, sampler, and writer schemas as the train stage,
186186
but with a different optimizer default and a workflow-wired supervised loss.
187187

188+
### Reference (`pretrain.reference.*`)
189+
190+
The Hartree-Fock reference is the PySCF calculation JaQMC uses to generate the
191+
target orbitals for pretraining. Most runs can keep the default settings.
192+
193+
```{eval-rst}
194+
.. config-defaults:: jaqmc.app.molecule.config.base.MoleculePretrainReferenceConfig
195+
:prefix: pretrain.reference
196+
```
197+
188198
### Run options (`pretrain.run.*`)
189199

190200
```{eval-rst}

docs/systems/solid/eval.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ are identical to the [training system config](#solid-train-system).
3131
Must match the training run. The effective defaults and built-in module choices
3232
are identical to the [training wavefunction config](#solid-train-wf).
3333

34+
## Reference (`reference.*`)
35+
36+
The Hartree-Fock reference is the PySCF calculation JaQMC uses when it needs
37+
reference orbitals or related setup from that calculation. Itis recommended to
38+
set the values to match the reference configuration used during training.
39+
40+
```{eval-rst}
41+
.. config-defaults:: jaqmc.app.solid.config.base.SolidPretrainReferenceConfig
42+
:prefix: reference
43+
```
44+
3445
## Run Options (`run.*`)
3546

3647
Evaluation reuses the same checkpointing and sampling controls as training, but

docs/systems/solid/index.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ boundary conditions. Most runs start from a YAML definition and a
55
single `jaqmc solid train` command. JaQMC then follows the same three-stage
66
workflow used for [molecules](../molecule/index.md):
77

8-
1. **Hartree-Fock (HF)** computes reference orbitals with PySCF.
8+
1. **Hartree-Fock (HF)** computes a reference electronic-structure solution with
9+
PySCF.
910
2. **Pretraining** matches the neural wavefunction to those orbitals.
1011
3. **VMC training** performs the main energy optimization.
1112

@@ -47,7 +48,6 @@ system:
4748
- symbol: H
4849
coords: [3.78, 3.78, 3.78]
4950
electron_spins: [2, 2] # [n_up, n_down] per primitive cell
50-
basis: sto-3g
5151
```
5252
5353
Then run training:
@@ -88,7 +88,6 @@ system:
8888
lattice_constant: 4.0 # in angstrom by default
8989
unit: angstrom # or "bohr"
9090
# supercell: [2, 2, 2] # Optional diagonal supercell shorthand
91-
basis: sto-3g
9291
```
9392

9493
Save as `rock_salt.yml`, then run:
@@ -111,7 +110,6 @@ system:
111110
unit: bohr # or "angstrom"
112111
spin: 0 # n_up - n_down per primitive cell
113112
# supercell: 4 # Optional repetition along the chain direction
114-
basis: sto-3g
115113
```
116114

117115
Save as `two_atom_chain.yml`, then run:
@@ -120,8 +118,18 @@ Save as `two_atom_chain.yml`, then run:
120118
jaqmc solid train --yml two_atom_chain.yml workflow.save_path=./runs/two_atom_chain
121119
```
122120

121+
The examples above also keep the Hartree-Fock reference at its default
122+
settings. If you need a different HF basis or method, add a
123+
`pretrain.reference` section, for example:
124+
125+
```yaml
126+
pretrain:
127+
reference:
128+
basis: cc-pvdz
129+
```
130+
123131
Basis sets and ECPs work the same as for
124-
[molecules](#molecule-basis-sets-and-ecps).
132+
<project:#molecule-basis-sets-and-ecps>.
125133
126134
## Supercell Expansion
127135

docs/systems/solid/train.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,16 @@ Initializes the neural network to approximate Hartree-Fock orbitals before VMC
172172
training. It uses the same run, sampler, and writer schemas as the train stage,
173173
but with a different optimizer default and a workflow-wired supervised loss.
174174

175+
### Reference (`pretrain.reference.*`)
176+
177+
The Hartree-Fock reference is the PySCF calculation JaQMC uses to generate the
178+
target orbitals for pretraining. Most runs can keep the default settings.
179+
180+
```{eval-rst}
181+
.. config-defaults:: jaqmc.app.solid.config.base.SolidPretrainReferenceConfig
182+
:prefix: pretrain.reference
183+
```
184+
175185
### Run options (`pretrain.run.*`)
176186

177187
```{eval-rst}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright (c) 2025-2026 Bytedance Ltd. and/or its affiliates
22
# SPDX-License-Identifier: Apache-2.0
33

4-
from .base import MoleculeConfig
4+
from .base import MoleculeConfig, MoleculePretrainReferenceConfig
55

6-
__all__ = ["MoleculeConfig"]
6+
__all__ = ["MoleculeConfig", "MoleculePretrainReferenceConfig"]

src/jaqmc/app/molecule/config/atom.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@
1111
def atom_config(
1212
symbol: str = "H",
1313
electron_init_width: float = 1.0,
14-
basis: str = "sto-3g",
1514
ecp: str | None = None,
1615
):
1716
"""Create a MoleculeConfig for a single atom.
1817
1918
Args:
2019
symbol: Element symbol (e.g., "H", "Li", "Fe").
2120
electron_init_width: Width of Gaussian for electron initialization.
22-
basis: Basis set name.
2321
ecp: Effective core potential name. Can be None (no ECP) or
2422
a string (e.g., "ccecp").
2523
@@ -41,6 +39,5 @@ def atom_config(
4139
atoms=[atom],
4240
electron_spins=electron_spins,
4341
electron_init_width=electron_init_width,
44-
basis=basis,
4542
ecp=ecp,
4643
)

src/jaqmc/app/molecule/config/base.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
from dataclasses import field
5+
from typing import Literal
56

67
from jaqmc.utils.atomic import Atom
78
from jaqmc.utils.atomic.atomic_system import AtomicSystemConfig
9+
from jaqmc.utils.atomic.pretrain import PretrainReferenceConfig
810
from jaqmc.utils.config import configurable_dataclass
911

10-
__all__ = ["MoleculeConfig"]
12+
__all__ = ["MoleculeConfig", "MoleculePretrainReferenceConfig"]
1113

1214

1315
@configurable_dataclass
@@ -16,3 +18,9 @@ class MoleculeConfig(AtomicSystemConfig):
1618
electron_spins: tuple[int, int] = (1, 0)
1719
fixed_spins_per_atom: list[tuple[int, int]] | None = None
1820
electron_init_width: float = 1.0
21+
22+
23+
@configurable_dataclass
24+
class MoleculePretrainReferenceConfig(PretrainReferenceConfig):
25+
method: Literal["RHF", "UHF"] = "UHF"
26+
"Variants of Hartree-Fock method."

src/jaqmc/app/molecule/config/diatomic.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ def diatomic_config(
5151
formula: str = "H2",
5252
bond_length: float = 1.4,
5353
unit: LengthUnit = LengthUnit.bohr,
54-
basis: str | dict[str, str] = "sto-3g",
5554
ecp: str | dict[str, str] | None = None,
5655
spin: int = 0,
5756
electron_init_width: float = 1.0,
@@ -66,8 +65,6 @@ def diatomic_config(
6665
bond_length: Distance between the two atoms.
6766
unit: Length unit for ``bond_length`` and atom coordinates.
6867
Either ``"bohr"`` or ``"angstrom"``.
69-
basis: Basis set name, or per-element mapping
70-
(e.g., ``{"Li": "ccecpccpvdz", "H": "cc-pvdz"}``).
7168
ecp: Effective core potential specification. Can be ``None``
7269
(all-electron), a string (e.g., ``"ccecp"``), or a
7370
per-element mapping (e.g., ``{"Li": "ccecp"}``).
@@ -117,6 +114,5 @@ def diatomic_config(
117114
atoms=atoms,
118115
electron_spins=(n_alpha, n_beta),
119116
electron_init_width=electron_init_width,
120-
basis=basis,
121117
ecp=ecp,
122118
)

0 commit comments

Comments
 (0)