Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions config/non_linear/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
The `non_linear` folder contains configuration files which customize the default behaviour of non-linear searches in
**PyAutoLens**.
**PyAutoFit**.

The default settings of each individual search (e.g. `Nautilus`, `Emcee`, `LBFGS`) are not set by configuration files.
They are the default values of the arguments of each search class's constructor, and are changed by passing those
arguments when the search is created.

# Files

- `mcmc.yaml`: Settings default behaviour of MCMC non-linear searches (e.g. Emcee).
- `nest.yaml`: Settings default behaviour of nested sampler non-linear searches (e.g. Dynesty).
- `mle.yaml`: Settings default behaviour of maximum likelihood estimator (mle) searches (e.g. LBFGS).
- `GridSearch.yaml`: Settings default behaviour of a parallelized grid search of non-linear searches (e.g. the
number of cores and the default step size).
37 changes: 25 additions & 12 deletions skills/af_configure_search.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: af_configure_search
description: Choose and configure a PyAutoFit non-linear search — nested samplers (Nautilus, DynestyStatic/Dynamic), MCMC (Emcee, Zeus, BlackJAXNUTS), and MLE optimizers (LBFGS, Drawer) — including output paths, cores, initializers and per-sampler settings. Use when the user asks "which sampler should I use", "configure the search", or wants to tune convergence/runtime. Not for actually executing the fit (that is `af_run_search`) or for composing the model (that is `af_compose_model`).
description: Choose and configure a PyAutoFit non-linear search — nested samplers (Nautilus, DynestyStatic/Dynamic, NSS), MCMC (Emcee, Zeus, BlackJAXNUTS, SMC), and MLE optimizers (LBFGS, BFGS, MultiStartAdam/ADABelief/Lion/Prodigy, Drawer) — including output paths, cores, initializers and per-sampler settings. Use when the user asks "which sampler should I use", "configure the search", or wants to tune convergence/runtime. Not for actually executing the fit (that is `af_run_search`) or for composing the model (that is `af_compose_model`).
user-invocable: true
---

Expand All @@ -18,12 +18,14 @@ distribution.
Every search class shares the same construction pattern: a `name`/`path_prefix` that
decides where output lands, `number_of_cores` for parallelisation, and per-sampler
settings (`PyAutoFit:autofit/non_linear/search/`). The installed roster (verify with
`dir(af)` — never from memory): `Nautilus`, `DynestyStatic`, `DynestyDynamic` (nested);
`Emcee`, `Zeus`, `BlackJAXNUTS` (MCMC); `LBFGS`, `Drawer` (MLE).
`dir(af)` — never from memory): `Nautilus`, `DynestyStatic`, `DynestyDynamic`, `NSS`
(nested); `Emcee`, `Zeus`, `BlackJAXNUTS`, `SMC` (MCMC); `LBFGS`, `BFGS`,
`MultiStartAdam`, `MultiStartADABelief`, `MultiStartLion`, `MultiStartProdigy`, `Drawer`
(MLE). `NSS`, `BlackJAXNUTS`, `SMC` and the `MultiStart*` searches are JAX-native and
need an analysis built with `use_jax=True`.

Read `wiki/core/concepts/non_linear_search.md` for the decision guide (until the core
wiki lands, the canonical references are `autofit_workspace:scripts/searches/nest.py`,
`mcmc.py`, `mle.py`).
Read `wiki/core/concepts/non_linear_search.md` for the decision guide; the worked
examples are `autofit_workspace:scripts/searches/nest.py`, `mcmc.py`, `mle.py`.

## Ask

Expand Down Expand Up @@ -55,7 +57,9 @@ search = af.Nautilus(
```

`af.DynestyStatic(nlive=50, ...)` / `af.DynestyDynamic(...)` are the alternative nested
samplers — long-standing, well-understood defaults with extensive literature.
samplers — long-standing, well-understood defaults with extensive literature. `af.NSS`
(nested slice sampling via BlackJAX) runs the whole sampler inside `jax.jit` and needs a
JAX-traceable likelihood.

## Branch — MCMC (posterior only)

Expand All @@ -76,7 +80,9 @@ search = af.Emcee(
```

`af.Zeus` (slice-sampling ensemble) often mixes faster on correlated posteriors;
`af.BlackJAXNUTS` is the gradient-based option when the likelihood is JAX-differentiable.
`af.BlackJAXNUTS` is the gradient-based option when the likelihood is JAX-differentiable;
`af.SMC` (BlackJAX adaptive tempered SMC with a gradient kernel) also returns the log
evidence.
Convergence is governed by auto-correlation settings (`af.AutoCorrelationsSettings`) —
see `autofit_workspace:scripts/searches/mcmc.py`.

Expand All @@ -93,16 +99,22 @@ answer of a Bayesian analysis (`PyAutoFit:autofit/non_linear/search/mle/`).
search = af.LBFGS(name="gaussian_fit_lbfgs")
```

`af.BFGS` is the full-memory scipy variant. `af.MultiStartAdam` / `MultiStartADABelief` /
`MultiStartLion` / `MultiStartProdigy` run many starts in parallel with JAX gradients
(`use_jax=True` required) and return the best basin — the better choice when the
likelihood is multi-modal or a single start gets stuck.

## Output discipline

`path_prefix` + `name` (+ `unique_tag`) map to `output/<path_prefix>/<name>/<tag>/…`.
Keep them stable across re-runs of the same fit — PyAutoFit resumes a completed search
from its output rather than re-running it, which is exactly what you want and worth
telling the user before they wonder why a second run finishes instantly.

Per-sampler defaults live in `config/non_linear/` — a project can retune a sampler
globally there instead of repeating kwargs in every script
(`PyAutoNerves:autonerves/conf.py`).
A search's defaults are the keyword defaults of its class
(`PyAutoFit:autofit/non_linear/search/`); there are no per-search YAML files, so a
non-default setting is passed as a kwarg. `config/non_linear/` holds only
`GridSearch.yaml`.

## Combine

Expand All @@ -114,7 +126,8 @@ globally there instead of repeating kwargs in every script

## Further reading

- **Student / new to inference** — HowToFit chapter 2: what a non-linear search is.
- **Student / new to inference** — `HowToFit:scripts/chapter_1_introduction/tutorial_3_non_linear_search.py`:
what a non-linear search is.
- **General reference** — [RTD: search cookbook](https://pyautofit.readthedocs.io/en/latest/cookbooks/search.html).
- **Experienced PyAutoFit user** — `autofit_workspace:scripts/searches/` (`nest.py`,
`mcmc.py`, `mle.py`, `start_point.py`).
8 changes: 4 additions & 4 deletions wiki/core/concepts/non_linear_search.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sources:
- autofit/non_linear/search/
pinned_commit: 4592990b14cacab243cde9c17789d463ff4a674f
last_updated: 2026-07-10
content_sha256: b6e938919e7b4ce44ca05f18908290d0653ca37a296a579fdd109b07dc446ed7
content_sha256: 7d5ab270e029c8b829bac65f8918a8e397ba867c30f50723add04ef52314e0ca
---

# Non-linear searches
Expand Down Expand Up @@ -53,9 +53,9 @@ local consumer refines — [[initialization_and_chaining]].

Every search takes `name` / `path_prefix` / `unique_tag` (output identity — a
completed search **reloads instead of re-running**), `number_of_cores`
(parallelisation), and an `initializer` where the family supports it. Per-sampler
defaults live in `config/non_linear/*.yaml`, so a project can retune once rather than
in every script. Execution: `search.fit(model=model, analysis=analysis)` → `Result`
(parallelisation), and an `initializer` where the family supports it. Each search's
defaults are the keyword defaults of its class — there are no per-search YAML files, so
a non-default setting is passed as a kwarg. Execution: `search.fit(model=model, analysis=analysis)` → `Result`
(`PyAutoFit:autofit/non_linear/search/abstract_search.py`).

## See also
Expand Down
13 changes: 7 additions & 6 deletions wiki/core/stack/autonerves.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sources:
- autonerves/
pinned_commit: 89c4714449797b0c049e8a95d16d499c863f4811
last_updated: 2026-07-10
content_sha256: e4eb6576a6ba6399d37707342188663758a0d224ae3c2a20bfd0952641a47c71
content_sha256: 72fb17423e00b996f512f3799ee4d7a35cee3280760ce0f0c490386db51cb4e6
---

# PyAutoNerves (`autonerves`)
Expand All @@ -15,11 +15,12 @@ The configuration layer under the whole PyAuto family. For an autofit user it
matters in three places:

1. **Config trees.** The workspace's `config/` directory is an autonerves config tree:
`general.yaml`, `logging.yaml`, `output.yaml`, `non_linear/*.yaml` (per-search
defaults), `priors/*.yaml`, `visualize/*.yaml`. Values resolve **workspace-first**:
a key present in the project's `config/` overrides the library default — which is
how a project retunes a sampler or an output policy once, globally
(`PyAutoNerves:autonerves/conf.py`).
`general.yaml`, `logging.yaml`, `output.yaml`, `non_linear/GridSearch.yaml`,
`priors/*.yaml`, `visualize/*.yaml`. Values resolve **workspace-first**: a key
present in the project's `config/` overrides the library default — which is how a
project retunes an output or visualization policy once, globally
(`PyAutoNerves:autonerves/conf.py`). Individual searches are not configured here:
their defaults are the keyword defaults of each search class.
2. **Default priors by class.** `config/priors/<Class>.yaml` (or module-level files)
supply priors for model classes so scripts need not repeat them — the right home
for a project's standard parametrisation. Note: autonerves lowercases YAML dict
Expand Down
Loading