You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use `PEPSSweepOptimizer.optimize_axis(...)` or `optimize_global(...)` with `solver` and `solver_options`.
4
+
5
+
## Quick comparison
6
+
7
+
-`solver="adam"`: best default for noisy or sensitive objectives.
8
+
-`solver="lbfgs"`: defaults to SciPy `L-BFGS-B` in sweep APIs.
9
+
-`solver="torch-lbfgs"`: torch-native quasi-Newton, often faster near convergence.
10
+
-`solver="scipy-lbfgs"`: robust CPU `L-BFGS-B`, supports bounds.
11
+
-`solver="nlopt-lbfgs"`: flexible stopping controls and algorithm variants.
12
+
13
+
## Recipe: Torch LBFGS
14
+
15
+
```python
16
+
result = sweeper.optimize_global(
17
+
axes=("y", "x"),
18
+
n_cycles=1,
19
+
n_round_trips=1,
20
+
solver="torch-lbfgs",
21
+
solver_options={
22
+
"max_iter": 1, # one inner LBFGS step per outer sweep step
23
+
"history_size": 20,
24
+
"line_search_fn": "strong_wolfe",
25
+
},
26
+
lr=1.0,
27
+
n_steps=60,
28
+
log_every=20,
29
+
env_n_iter=4,
30
+
pbar=True,
31
+
)
32
+
```
33
+
34
+
Practical notes:
35
+
36
+
- Keep `max_iter=1` so `n_steps` remains the main outer control knob.
37
+
- Start with `lr=1.0`; reduce if updates oscillate.
38
+
39
+
## Recipe: SciPy L-BFGS-B
40
+
41
+
```python
42
+
result = sweeper.optimize_global(
43
+
axes=("y", "x"),
44
+
n_cycles=1,
45
+
n_round_trips=1,
46
+
solver="scipy-lbfgs",
47
+
solver_options={
48
+
"method": "L-BFGS-B",
49
+
"maxiter": 80,
50
+
"ftol": 1e-12,
51
+
},
52
+
n_steps=80,
53
+
log_every=20,
54
+
env_n_iter=4,
55
+
pbar=True,
56
+
)
57
+
```
58
+
59
+
Practical notes:
60
+
61
+
- This backend optimizes on CPU `float64` vectors internally.
62
+
- You can set bounds with either `bounds=[(lo, hi), ...]` or `lower_bounds` / `upper_bounds`.
63
+
64
+
## Recipe: NLopt LBFGS
65
+
66
+
```python
67
+
result = sweeper.optimize_global(
68
+
axes=("y", "x"),
69
+
n_cycles=1,
70
+
n_round_trips=1,
71
+
solver="nlopt-lbfgs",
72
+
solver_options={
73
+
"algorithm": "LD_LBFGS",
74
+
"maxeval": 100,
75
+
"ftol_rel": 1e-10,
76
+
"xtol_rel": 1e-10,
77
+
},
78
+
n_steps=100,
79
+
log_every=20,
80
+
env_n_iter=4,
81
+
pbar=True,
82
+
)
83
+
```
84
+
85
+
Practical notes:
86
+
87
+
-`maxeval` is the main NLopt iteration cap.
88
+
- If needed, switch `algorithm` to another NLopt gradient method.
89
+
- This path is more sensitive to stopping settings; for a robust default start from `scipy-lbfgs`.
90
+
91
+
## Best-parameter behavior
92
+
93
+
All sweep solvers now return and apply the **best-loss parameters** seen during the run, not just the last iterate. This is important for non-monotonic trajectories.
94
+
95
+
## Numerical stability and backend transitions
96
+
97
+
- External solvers (`scipy-lbfgs`, `nlopt-lbfgs`) flatten params to CPU NumPy `float64`.
98
+
- Complex parameters are split into real/imag blocks during optimization and reconstructed afterward.
99
+
- Returned parameters are cast back to original tensor dtype/device before being applied to the PEPS state.
100
+
101
+
This design keeps optimizer interoperability while minimizing conversion-induced drift.
0 commit comments