Skip to content

Phase 16: audit the documentation against the epic (#352) - #353

Merged
neuromechanist merged 28 commits into
feature/issue-324-epic-mlx-first-classfrom
feature/issue-352-phase16-docs-audit
Sep 23, 2026
Merged

neuromechanist merged 28 commits into
feature/issue-324-epic-mlx-first-classfrom
feature/issue-352-phase16-docs-audit

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Part of #324, closes #352 on the epic merge.

Audits the documentation against the finished epic code and cleans up what the phases left behind.
Parity figures and paper.md are untouched: they belong to #351.

What was checked

  • Every page under docs/ (concepts, guides, API, getting started, development, index, changelog) and README.md, statement by statement against the code
  • The public docstrings of AMICA, AMICAICA, AMICATorchNG, AMICAMLXNG, AMICA_NumPy and AMICANative (the API pages render them)
  • Parameter defaults against the constructors and the reference's compiled defaults (amica15_header.f90)
  • Stop reasons and the degenerate-fit contract (nan_ll, singular_ll, nan_direction, nan_params, restart_error)
  • Parameter-file support for every backend, backend selection through AMICA/AMICAICA, save/load formats and the component-row conversion, the EEGLAB export and MNE apply
  • The summary table of the differences guide: row numbers and every "row N" reference in the docs, ADRs, changelog and code comments (all resolve to the right row)
  • Real-data checks on the bundled sample: accessor shapes and the transform composition after a pcakeep=20 fit, the A-freeze iterations at the defaults, the MLX device/dtype refusals, the LLt omission after load, the params-table counts, and the raw PyTorch backend's automatic device choice
  • Links and anchors: every internal link and in-page anchor in the built site, and every link from the ADRs into the docs, resolve (checked with a throwaway script over the built HTML; not committed)

What changed

Concept pages

  • how-amica-works.md walks one iteration in the reference's order: E-step, the likelihood-decrease response and stopping checks, the exit before any update, then the update with the Newton start, the A-freeze windows (every fit, with or without sharing) and the doscaling rescale; the false "each EM iteration increases the log-likelihood" is gone, and final_ll_ at max_iter is explained
  • amica-algorithm-flow.svg redrawn: the checks and the stop decision now come before the update
  • what-is-amica.md covers the unit-norm scale convention and doscaling, and no longer claims bit-level parity; what-is-ica.md defines ZCA and points to the EEGLAB guide for ordering

Guides

Entry pages and API

  • Getting started and README: pamica is on PyPI; unreleased changes need a source install; the README called get_mixing_matrix scalp maps; the NumPy CLI takes either parameter format
  • Home page: float32 is not a general speedup
  • API overview lists AMICANative; extras install with uv; the NumPy page's n_channels claim was wrong (the raw PyTorch and MLX constructors take it); the viz page no longer cites the closed loadmodout reads W, sbeta and rho in the wrong byte order (corrupts genuine Fortran output) #159 as open
  • Docstrings: lines that began with an issue number rendered as headings on the API pages; get_mixing_matrix/get_unmixing_matrix shapes and space; restart_error; maxdecs counts decreases, not consecutive ones; Newton's default; the raw backend's device default; shared component wording

Changelog

  • The Unreleased section is one account grouped by what changed, opening with a warning that default fits differ from 0.3.3 and why; superseded entries (Phase 8's pending Use the reference's single-precision density constants #344 note, the polish round's harness note, Phase 1's remaining-gap note) are gone, duplicates merged, measurements taken before later phases marked as such; no figure changed

Code

  • Deleted choose_pdf_type (no callers anywhere, including benchmarks/, examples/, scripts/) and compute_pdf's unreachable legacy pdftype 2-4 branches with its pdftype argument; every caller used the generalized Gaussian; no test existed only for them

Agent context

  • AGENTS.md maps the shared modules (rank, schedule, initialization, component_layout, reference_constants, blocktune, restarts, fortran_params) and mne_compat/native/metrics, names amica15.f90 as the reference source, and states the epic's fitting changes
  • .context/plan.md and .context/progress_summary.md record the epic and close stale release items

Gates

  • uv run ruff check ., uv run ruff format --check ., uv run ty check ., typos
  • uv run mkdocs build --strict
  • uv run pytest (full suite)

neuromechanist and others added 28 commits September 23, 2026 12:58
choose_pdf_type had no callers, and compute_pdf's pdftype 2-4 branches
were unreachable: every caller uses the generalized Gaussian. Tested
with the pdf, reference-constant and viz suites.
Rewrap docstring lines that began with an issue number, which the API
pages rendered as headings; state the sphered-space shapes of the
wrapper's mixing and unmixing accessors; name restart_error among the
degenerate stops; drop the claim that natural gradient alone falls short
of the reference; fix the NumPy n_channels and doscaling wording.
Checked on the bundled sample (accessor shapes and composition).
The reference resets its decrease count only at each ratchet and when
Newton switches on (amica15.f90:1062-1076), as every backend does.
How AMICA works now walks one iteration as the code runs it: the E-step,
the likelihood-decrease response and stopping checks, the exit before
any update, then the update with Newton, the A-freeze windows and the
doscaling rescale. The false claim that every iteration raises the
likelihood is gone, and the flow figure shows the checks before the
update. What is AMICA covers the unit-norm scale convention.
The variance-order example took scalp maps from the sphered-space
get_mixing_matrix; it now uses get_sensor_mixing_matrix. The multi-model
note still said the per-model layout differs from the reference's, which
#159 and #334 fixed. The guide index lists all four guides.
Auto device selection picks MPS first and the wrapper redirects it to
CPU for float64; the raw AMICATorchNG raises there instead (checked on
this host). CUDA float32 is about as fast as float64, not faster, as the
same page says above. The native backend is listed, the wrappers' two
backends and their parameter-file route are stated, and a stale 'sweep
is being finalized' note points to the published sweeps.
With device=None it picks MPS first and, at the float64 default, raises
on an Apple machine; the AMICA wrapper redirects to CPU. Checked on this
host.
pamica is on PyPI (0.3.3), so getting started no longer says a release
is planned, and says unreleased changes need a source install. The
README's get_mixing_matrix comment called the sphered-space matrix
scalp maps; the examples now use get_sensor_mixing_matrix for maps. The
home page no longer calls float32 faster, the final_ll_ note covers the
max_iter case, and the NumPy CLI takes either parameter-file format.
List AMICANative in the public import surface; install extras with uv
from PyPI or a source checkout; correct the NumPy page's n_channels
claim (the raw PyTorch and MLX constructors take it) and list what that
backend lacks; drop the viz page's reference to the closed #159 as an
open question; replace em-dashes in list items.
amica15_header.f90 declares do_newton = .false.; only the bundled
input.param turns it on. The Newton docstrings and the concept page
said the reference runs Newton by default.
The reference compiles do_newton off (only the bundled input.param
turns it on); row 5 names singular_ll; the backend table gains the
variance_order, scoring and wrapper rows and the wrapper .pt save; an
obsolete pre-#334 comparison of two retired sharing metrics is replaced
by the current single-kernel account; the LLt exception names the last
iteration; table cells say none instead of an em-dash.
The degenerate-fit row still said raw backends were ungated (#306 is
done) and named only the likelihood stops; the EEGLAB section still said
multi-model files are not in the reference layout. Parity figures are
left to #351.
Group the phase entries by what changed (fitting, MLX and the wrappers,
the MNE wrapper, persistence and exports, fixes, removals, docs) and
open with a warning that default fits differ from 0.3.3 and why. Drop
the entries a later phase superseded (Phase 8's pending #344 note, the
polish round's harness and Phase 1's remaining-gap notes), merge the
duplicate pdftype-default entries, correct the n_channels claim, and
mark measurements taken before later phases. No figure is changed.
Add rank, schedule, initialization, component_layout and
reference_constants (with blocktune, restarts and the params reader) as
the shared-decision modules, plus mne_compat, native and metrics; name
amica15.f90 as the reference source; add a status line for the
reference-fidelity changes and the #306/#339 degenerate-fit extensions;
shorten the epic #278 history sentence.
Record epic #324's phases and the reference-fidelity changes, the
#306/#339 degenerate-fit extensions and the #334 sharing oracle; close
the stale release items (repository transfer, docs deploy, PyPI and
Zenodo are done) and the #15 coverage item.
The testing page names AMICA_RUN_FORTRAN=1 and the mne_tests directory;
the MNE page's source formula includes the per-channel-type scaling the
export applies.
Drop negation-contrast and candor framing outside the Validation
section, count releases as of today (nine, six on PyPI), and describe
the MEG status as end-to-end use without measured parity.
The docstring called W @ get_sphere() the full transform; transform
also subtracts the mean before sphering and the model center after.
The MIR docstrings and the metrics page now call W @ sphere the linear
part. Checked on the bundled sample with two models: the full formula
matches transform exactly, W @ sphere @ X is off by up to 4.2, and MIR
is unchanged by a shift of the data.
The opening warning said the schedule gates and component rows matter
only with Newton, rejection, restarts or sharing; they also reach plain
default fits in narrow cases (a maxdecs ratchet past newt_start, and
the per-component ndtmpsum sum near a grad-norm stop). The stopping
iteration's skipped steps are listed in code order (kurtosis switch,
share scan, MIR waypoint, rejection), in ADR 0008 too, and the #304
entry says the fit applies the file's settings.
Prose only; no figure on those lines changed.
from_params_file stores the file's settings on the instance; fit passes
them to the backend constructor as defaults and emits the warning.
Reword contrast framings in the concept page, home page, viz page and
module docstring, and the differences guide's opening, per the style
rule: say what the code does and its known effect.
@neuromechanist
neuromechanist merged commit 3fbe1ab into feature/issue-324-epic-mlx-first-class Sep 23, 2026
9 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-352-phase16-docs-audit branch September 23, 2026 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant